1170 lines
53 KiB
PHP
1170 lines
53 KiB
PHP
<?php
|
|
|
|
namespace App\Views;
|
|
|
|
class TeacherPortal
|
|
{
|
|
public static function render(): string
|
|
{
|
|
return <<<'HTML'
|
|
<!DOCTYPE html>
|
|
<html lang="ar" dir="rtl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>بوابة المعلم — استوديو صَقِل التعليمي</title>
|
|
<!-- Google Fonts: Cairo -->
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800;900&display=swap" rel="stylesheet">
|
|
|
|
<!-- Pure Self-Contained Luxury CSS (Zero External CDN Dependency) -->
|
|
<style>
|
|
:root {
|
|
--bg-dark: #0B132B;
|
|
--bg-card: #16203D;
|
|
--bg-card-hover: #1E2C52;
|
|
--bg-input: #090E20;
|
|
--border: #2A3B66;
|
|
--border-focus: #FFD166;
|
|
--text-primary: #FFFFFF;
|
|
--text-secondary: #CBD5E1;
|
|
--text-muted: #8E9FB8;
|
|
--accent-gold: #FFD166;
|
|
--accent-gold-dark: #F59E0B;
|
|
--accent-cyan: #00F5D4;
|
|
--accent-red: #EF4444;
|
|
--accent-green: #10B981;
|
|
--accent-purple: #A78BFA;
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
font-family: 'Cairo', system-ui, -apple-system, sans-serif;
|
|
}
|
|
|
|
body {
|
|
background-color: var(--bg-dark);
|
|
color: var(--text-primary);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: space-between;
|
|
background-image:
|
|
radial-gradient(circle at 15% 15%, rgba(255, 209, 102, 0.07) 0%, transparent 40%),
|
|
radial-gradient(circle at 85% 85%, rgba(0, 245, 212, 0.05) 0%, transparent 40%),
|
|
linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
|
|
linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
|
|
background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 0 20px;
|
|
width: 100%;
|
|
}
|
|
|
|
/* Header */
|
|
header {
|
|
border-bottom: 1px solid var(--border);
|
|
background-color: rgba(11, 19, 43, 0.95);
|
|
backdrop-filter: blur(12px);
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 50;
|
|
}
|
|
|
|
.header-content {
|
|
height: 68px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.logo-area {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.logo-badge {
|
|
width: 42px;
|
|
height: 42px;
|
|
border-radius: 12px;
|
|
background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #0B132B;
|
|
font-size: 20px;
|
|
font-weight: 900;
|
|
box-shadow: 0 0 20px rgba(255, 209, 102, 0.35);
|
|
}
|
|
|
|
.brand-title {
|
|
font-size: 20px;
|
|
font-weight: 900;
|
|
color: #FFFFFF;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.portal-pill {
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
padding: 2px 10px;
|
|
border-radius: 999px;
|
|
background: rgba(255, 209, 102, 0.12);
|
|
color: var(--accent-gold);
|
|
border: 1px solid rgba(255, 209, 102, 0.35);
|
|
margin-right: 8px;
|
|
}
|
|
|
|
.nav-link {
|
|
font-size: 13px;
|
|
color: var(--text-secondary);
|
|
text-decoration: none;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
transition: 0.2s;
|
|
}
|
|
|
|
.nav-link:hover { color: var(--accent-cyan); }
|
|
.nav-link-highlight { color: var(--accent-cyan); font-weight: 800; text-decoration: underline; }
|
|
|
|
/* Main Layout */
|
|
main {
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 40px 0;
|
|
}
|
|
|
|
.auth-card-wrapper {
|
|
width: 100%;
|
|
max-width: 520px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.auth-header {
|
|
text-align: center;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.icon-box {
|
|
width: 64px;
|
|
height: 64px;
|
|
border-radius: 18px;
|
|
background: var(--bg-card);
|
|
border: 1px solid rgba(255, 209, 102, 0.4);
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: var(--accent-gold);
|
|
margin-bottom: 16px;
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.auth-title {
|
|
font-size: 24px;
|
|
font-weight: 900;
|
|
color: #FFFFFF;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.auth-subtitle {
|
|
font-size: 13px;
|
|
color: var(--text-muted);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.auth-box {
|
|
background: var(--bg-card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 20px;
|
|
padding: 32px;
|
|
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
|
|
position: relative;
|
|
}
|
|
|
|
/* Forms */
|
|
.form-group {
|
|
margin-bottom: 18px;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.input-text {
|
|
width: 100%;
|
|
background: var(--bg-input);
|
|
border: 1px solid var(--border);
|
|
border-radius: 12px;
|
|
padding: 12px 16px;
|
|
font-size: 14px;
|
|
color: #FFFFFF;
|
|
outline: none;
|
|
transition: border-color 0.2s, box-shadow 0.2s;
|
|
}
|
|
|
|
.input-text:focus {
|
|
border-color: var(--accent-gold);
|
|
box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.2);
|
|
}
|
|
|
|
.input-text::placeholder { color: #52607D; }
|
|
|
|
.phone-input-group {
|
|
display: flex;
|
|
align-items: center;
|
|
direction: ltr;
|
|
position: relative;
|
|
}
|
|
|
|
.country-badge {
|
|
position: absolute;
|
|
left: 10px;
|
|
background: #121A33;
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
padding: 6px 10px;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
color: var(--accent-gold);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
user-select: none;
|
|
}
|
|
|
|
.input-phone {
|
|
padding-left: 96px !important;
|
|
font-family: monospace;
|
|
font-size: 15px;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.form-hint {
|
|
font-size: 11px;
|
|
color: var(--text-muted);
|
|
margin-top: 6px;
|
|
display: block;
|
|
}
|
|
|
|
/* Buttons */
|
|
.btn-primary {
|
|
width: 100%;
|
|
padding: 14px;
|
|
background: linear-gradient(135deg, #FFD166 0%, #F59E0B 100%);
|
|
color: #0B132B !important;
|
|
border: none;
|
|
border-radius: 12px;
|
|
font-size: 15px;
|
|
font-weight: 900 !important;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
box-shadow: 0 8px 24px rgba(255, 209, 102, 0.35);
|
|
transition: transform 0.15s, opacity 0.15s;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.btn-primary:hover { opacity: 0.95; transform: translateY(-1px); }
|
|
.btn-primary:active { transform: translateY(0); }
|
|
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
|
|
|
|
.btn-secondary {
|
|
background: none;
|
|
border: none;
|
|
color: var(--text-muted);
|
|
font-size: 12px;
|
|
cursor: pointer;
|
|
padding: 6px 0;
|
|
transition: color 0.2s;
|
|
}
|
|
.btn-secondary:hover { color: #FFFFFF; }
|
|
.btn-link-gold { color: var(--accent-gold); font-weight: 700; text-decoration: underline; }
|
|
|
|
.otp-input {
|
|
text-align: center;
|
|
font-size: 26px;
|
|
font-family: monospace;
|
|
letter-spacing: 10px;
|
|
font-weight: 900;
|
|
color: var(--accent-gold);
|
|
border-color: rgba(255, 209, 102, 0.5);
|
|
padding: 14px;
|
|
}
|
|
|
|
/* Multi-Select Pills for Grades */
|
|
.pills-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
|
|
gap: 8px;
|
|
margin-top: 6px;
|
|
}
|
|
|
|
.pill-checkbox {
|
|
position: relative;
|
|
}
|
|
|
|
.pill-checkbox input {
|
|
position: absolute;
|
|
opacity: 0;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.pill-label {
|
|
display: block;
|
|
background: var(--bg-input);
|
|
border: 1px solid var(--border);
|
|
padding: 8px 12px;
|
|
border-radius: 10px;
|
|
font-size: 11.5px;
|
|
font-weight: 700;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
user-select: none;
|
|
}
|
|
|
|
.pill-checkbox input:checked + .pill-label {
|
|
background: rgba(255, 209, 102, 0.15);
|
|
border-color: var(--accent-gold);
|
|
color: var(--accent-gold);
|
|
box-shadow: 0 0 10px rgba(255, 209, 102, 0.2);
|
|
}
|
|
|
|
/* Alerts */
|
|
.alert {
|
|
padding: 12px 16px;
|
|
border-radius: 12px;
|
|
font-size: 12.5px;
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
line-height: 1.5;
|
|
}
|
|
.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); color: #FCA5A5; }
|
|
.alert-success { background: rgba(255, 209, 102, 0.15); border: 1px solid rgba(255, 209, 102, 0.4); color: var(--accent-gold); }
|
|
|
|
/* Dashboard Tabs & Cards */
|
|
.dashboard-hero {
|
|
background: linear-gradient(135deg, var(--bg-card), var(--bg-card-hover));
|
|
border: 1px solid var(--border);
|
|
border-radius: 24px;
|
|
padding: 28px 32px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 24px;
|
|
flex-wrap: wrap;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.stats-grid {
|
|
display: flex;
|
|
gap: 16px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.stat-card {
|
|
background: rgba(11, 19, 43, 0.85);
|
|
border: 1px solid var(--border);
|
|
border-radius: 16px;
|
|
padding: 16px 24px;
|
|
text-align: center;
|
|
min-width: 130px;
|
|
}
|
|
.stat-card.gold-glow { border-color: rgba(255, 209, 102, 0.5); box-shadow: 0 0 20px rgba(255, 209, 102, 0.15); }
|
|
.stat-label { font-size: 11px; font-weight: 700; color: var(--text-muted); display: block; margin-bottom: 4px; }
|
|
.stat-val { font-size: 24px; font-weight: 900; }
|
|
.val-cyan { color: var(--accent-cyan); }
|
|
.val-gold { color: var(--accent-gold); }
|
|
.val-purple { color: var(--accent-purple); }
|
|
|
|
/* Tabs Navigation */
|
|
.tabs-nav {
|
|
display: flex;
|
|
gap: 12px;
|
|
border-bottom: 1px solid var(--border);
|
|
margin-bottom: 24px;
|
|
padding-bottom: 12px;
|
|
}
|
|
|
|
.tab-btn {
|
|
background: none;
|
|
border: 1px solid transparent;
|
|
padding: 10px 20px;
|
|
border-radius: 12px;
|
|
font-size: 13px;
|
|
font-weight: 800;
|
|
color: var(--text-secondary);
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.tab-btn.active {
|
|
background: rgba(255, 209, 102, 0.12);
|
|
border-color: rgba(255, 209, 102, 0.4);
|
|
color: var(--accent-gold);
|
|
}
|
|
|
|
.studio-card {
|
|
background: var(--bg-card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 20px;
|
|
padding: 28px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.chat-box {
|
|
background: rgba(11, 19, 43, 0.9);
|
|
border: 1px solid var(--border);
|
|
border-radius: 16px;
|
|
height: 380px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.chat-messages {
|
|
flex: 1;
|
|
padding: 20px;
|
|
overflow-y: auto;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 14px;
|
|
}
|
|
|
|
.chat-msg {
|
|
max-width: 75%;
|
|
padding: 12px 16px;
|
|
border-radius: 14px;
|
|
font-size: 13px;
|
|
line-height: 1.5;
|
|
}
|
|
.chat-msg.student { align-self: flex-start; background: #1B284F; color: #E2E8F0; border-bottom-right-radius: 2px; }
|
|
.chat-msg.teacher { align-self: flex-end; background: linear-gradient(135deg, #FFD166, #F59E0B); color: #0B132B; font-weight: 700; border-bottom-left-radius: 2px; }
|
|
|
|
.chat-input-bar {
|
|
display: flex;
|
|
gap: 10px;
|
|
padding: 14px;
|
|
border-top: 1px solid var(--border);
|
|
background: #121A33;
|
|
}
|
|
|
|
.spinner {
|
|
width: 18px;
|
|
height: 18px;
|
|
border: 3px solid rgba(11, 19, 43, 0.3);
|
|
border-top-color: #0B132B;
|
|
border-radius: 50%;
|
|
animation: spin 0.8s linear infinite;
|
|
}
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
|
|
/* Footer */
|
|
footer {
|
|
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
|
padding: 20px 0;
|
|
background: var(--bg-dark);
|
|
color: var(--text-muted);
|
|
font-size: 12px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- Header -->
|
|
<header>
|
|
<div class="container">
|
|
<div class="header-content">
|
|
<a href="/teacher" class="logo-area">
|
|
<div class="logo-badge">صـ</div>
|
|
<div>
|
|
<span class="brand-title">صَقِل</span>
|
|
<span class="portal-pill">استوديو المعلمين</span>
|
|
</div>
|
|
</a>
|
|
|
|
<div id="header_user_actions">
|
|
<a href="/student" class="nav-link" id="switch_to_student_link">
|
|
<span>أنت طالب؟</span>
|
|
<span class="nav-link-highlight">بوابة الطلاب ←</span>
|
|
</a>
|
|
<div id="auth_user_badge" style="display: none; align-items: center; gap: 12px;">
|
|
<span style="font-size: 13px; color: var(--text-secondary);" id="teacher_display_name"></span>
|
|
<button onclick="handleLogout()" style="background: none; border: 1px solid rgba(239,68,68,0.4); color: #F87171; border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer;">
|
|
تسجيل الخروج
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Main Content -->
|
|
<main>
|
|
<div class="container">
|
|
|
|
<!-- ==================================================== -->
|
|
<!-- 1. AUTHENTICATION & ONBOARDING CONTAINER -->
|
|
<!-- ==================================================== -->
|
|
<div id="auth_container" class="auth-card-wrapper">
|
|
|
|
<div class="auth-header">
|
|
<div class="icon-box">
|
|
<svg width="28" height="28" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
|
|
</svg>
|
|
</div>
|
|
<h1 class="auth-title" id="auth_main_title">استوديو صَقِل للمعلمين</h1>
|
|
<p class="auth-subtitle" id="auth_main_subtitle">توثيق الحساب عبر الواتساب والانضمام لنخبة معلمين المملكة</p>
|
|
</div>
|
|
|
|
<div class="auth-box">
|
|
|
|
<!-- Alerts -->
|
|
<div id="alert_box_error" class="alert alert-error" style="display: none;">
|
|
<span>⚠️</span>
|
|
<span id="alert_error_msg"></span>
|
|
</div>
|
|
<div id="alert_box_success" class="alert alert-success" style="display: none;">
|
|
<span>✓</span>
|
|
<span id="alert_success_msg"></span>
|
|
</div>
|
|
|
|
<!-- STEP 1: Phone Number -->
|
|
<div id="step_phone_container">
|
|
<div class="form-group">
|
|
<label class="form-label">رقم هاتف المعلم (الواتساب) <span style="color: #EF4444;">*</span></label>
|
|
<div class="phone-input-group">
|
|
<div class="country-badge">🇯🇴 +962</div>
|
|
<input type="tel" id="teacher_phone" required placeholder="790000000" class="input-text input-phone">
|
|
</div>
|
|
<span class="form-hint">يصلك رمز التحقق مباشرة على الواتساب المعتمد.</span>
|
|
</div>
|
|
|
|
<button type="button" id="btn_send_otp" onclick="handleSendOtp(event)" class="btn-primary">
|
|
<span id="btn_send_text">إرسال رمز الدخول (OTP) ←</span>
|
|
<div id="btn_send_spinner" class="spinner" style="display: none;"></div>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- STEP 2: OTP Verification -->
|
|
<div id="step_otp_container" style="display: none;">
|
|
<div style="text-align: center; margin-bottom: 20px;">
|
|
<span style="font-size: 12px; color: var(--text-muted);">تم إرسال رمز التحقق إلى:</span>
|
|
<div style="font-family: monospace; font-size: 15px; font-weight: 800; color: var(--accent-gold); margin-top: 4px;" id="otp_target_display"></div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label" style="text-align: center;">أدخل رمز التحقق (6 أرقام)</label>
|
|
<input type="text" id="teacher_otp_code" maxlength="6" autofocus placeholder="• • • • • •" class="input-text otp-input">
|
|
</div>
|
|
|
|
<button type="button" id="btn_verify_otp" onclick="handleVerifyOtp(event)" class="btn-primary">
|
|
<span id="btn_verify_text">تأكيد الدخول للاستوديو 🎓</span>
|
|
<div id="btn_verify_spinner" class="spinner" style="display: none;"></div>
|
|
</button>
|
|
|
|
<div style="display: flex; align-items: center; justify-content: space-between; margin-top: 18px;">
|
|
<button type="button" onclick="switchToPhoneStep()" class="btn-secondary">← تعديل الرقم</button>
|
|
<span id="resend_timer_label" style="font-size: 12px; color: var(--text-muted); display: none;"></span>
|
|
<button type="button" id="btn_resend" onclick="handleSendOtp(event)" class="btn-secondary btn-link-gold" style="display: none;">إعادة إرسال الرمز ↺</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- STEP 3: Teacher Onboarding (For New Teachers) -->
|
|
<div id="step_onboarding_container" style="display: none;">
|
|
<div style="background: rgba(255,209,102,0.1); border: 1px solid rgba(255,209,102,0.3); border-radius: 12px; padding: 12px 16px; margin-bottom: 20px;">
|
|
<span style="font-size: 13px; font-weight: 800; color: var(--accent-gold);">👋 مرحباً بك معنا!</span>
|
|
<p style="font-size: 12px; color: var(--text-secondary); margin-top: 2px;">يرجى توثيق ملفك الأكاديمي وتعيين كلمة مرور سرية لحسابك.</p>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">الاسم الكامل ولقب التدريس <span style="color: #EF4444;">*</span></label>
|
|
<input type="text" id="onboard_fullname" placeholder="مثال: الأستاذ حمزة النجار" class="input-text" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">التخصص والمادة العلمية <span style="color: #EF4444;">*</span></label>
|
|
<select id="onboard_specialization" class="input-text" required>
|
|
<option value="رياضيات علمي">رياضيات — الفرع العلمي والمهني</option>
|
|
<option value="فيزياء">الفيزياء — التوجيهي والأول ثانوي</option>
|
|
<option value="كيمياء">الكيمياء — توجيهي 2007 و 2008</option>
|
|
<option value="علوم حياتية">العلوم الحياتية (أحياء)</option>
|
|
<option value="لغة عربية">اللغة العربية والتخصص</option>
|
|
<option value="لغة إنجليزية">اللغة الإنجليزية</option>
|
|
<option value="تاريخ الأردن وتربية إسلامية">تاريخ الأردن والتربية الإسلامية</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">المراحل والصفوف التدريسية (اختر ما يناسبك)</label>
|
|
<div class="pills-grid">
|
|
<label class="pill-checkbox">
|
|
<input type="checkbox" name="grades" value="tawjihi_2008" checked>
|
|
<span class="pill-label">توجيهي 2008</span>
|
|
</label>
|
|
<label class="pill-checkbox">
|
|
<input type="checkbox" name="grades" value="tawjihi_2007" checked>
|
|
<span class="pill-label">توجيهي 2007</span>
|
|
</label>
|
|
<label class="pill-checkbox">
|
|
<input type="checkbox" name="grades" value="grade_11">
|
|
<span class="pill-label">الأول ثانوي</span>
|
|
</label>
|
|
<label class="pill-checkbox">
|
|
<input type="checkbox" name="grades" value="grade_10">
|
|
<span class="pill-label">العاشر الأساسي</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">تعيين كلمة المرور السرية للحساب <span style="color: #EF4444;">*</span></label>
|
|
<input type="password" id="onboard_password" placeholder="8 خانات على الأقل (أحرف وأرقام)" class="input-text" required>
|
|
<span class="form-hint">تستخدم كلمة المرور لتأكيد الدخول المستقبلي والحماية المتقدمة.</span>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">نبذة عن خبرتك التدريسية (اختياري)</label>
|
|
<textarea id="onboard_bio" rows="2" placeholder="مثال: خبرة 12 عاماً في تدريس التوجيهي العلمي ومدارس الثقافة العسكرية..." class="input-text" style="resize: none;"></textarea>
|
|
</div>
|
|
|
|
<button type="button" id="btn_complete_onboarding" onclick="handleCompleteOnboarding(event)" class="btn-primary">
|
|
<span id="btn_onboard_text">حفظ وتفعيل لوحة التحكم 🚀</span>
|
|
<div id="btn_onboard_spinner" class="spinner" style="display: none;"></div>
|
|
</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ==================================================== -->
|
|
<!-- 2. TEACHER DASHBOARD (AUTHENTICATED & ACTIVE) -->
|
|
<!-- ==================================================== -->
|
|
<div id="dashboard_container" style="width: 100%; display: none;">
|
|
|
|
<!-- Hero & Stats Header -->
|
|
<div class="dashboard-hero">
|
|
<div>
|
|
<span style="display: inline-block; font-size: 11px; font-weight: 800; color: var(--accent-gold); background: rgba(255,209,102,0.12); border: 1px solid rgba(255,209,102,0.3); padding: 4px 12px; border-radius: 999px; margin-bottom: 12px;">استوديو المعلم المعتمد</span>
|
|
<h2 style="font-size: 26px; font-weight: 900; color: #FFFFFF;" id="dashboard_welcome_title">أهلاً بك يا أستاذنا 👨🏫</h2>
|
|
<p style="font-size: 13px; color: var(--text-secondary); margin-top: 4px;" id="dashboard_specialization_badge">مادة الرياضيات — التوجيهي العلمي</p>
|
|
</div>
|
|
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<span class="stat-label">إجمالي الكورسات</span>
|
|
<span class="stat-val val-cyan" id="stat_courses_count">3</span>
|
|
</div>
|
|
<div class="stat-card">
|
|
<span class="stat-label">الطلاب المشتركون</span>
|
|
<span class="stat-val val-purple" id="stat_students_count">840</span>
|
|
</div>
|
|
<div class="stat-card gold-glow">
|
|
<span class="stat-label">متوسط إكمال الدروس</span>
|
|
<span class="stat-val val-gold">91.4%</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tabs Bar -->
|
|
<div class="tabs-nav">
|
|
<button class="tab-btn active" onclick="switchDashboardTab('courses')">📚 دوراتي وحصص الفيديو</button>
|
|
<button class="tab-btn" onclick="switchDashboardTab('students')">👥 متابعة الطلاب ونبض المشاهدة</button>
|
|
<button class="tab-btn" onclick="switchDashboardTab('chat')">💬 الشات الفوري مع الطلاب</button>
|
|
</div>
|
|
|
|
<!-- TAB 1: Courses & Lessons -->
|
|
<div id="tab_courses_content" class="studio-card">
|
|
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;">
|
|
<div>
|
|
<h3 style="font-size: 18px; font-weight: 900;">إدارة الكورسات والحصص المصورة 🎬</h3>
|
|
<p style="font-size: 12px; color: var(--text-muted); margin-top: 4px;">فيديوهات مشفرة ومحمية بـ DRM وتوليد كويزات تفاعلية تلقائياً عبر الذكاء الاصطناعي.</p>
|
|
</div>
|
|
<button onclick="alert('سيتم فتح نافذة رفع الحصص المربوطة بـ Bunny Stream')" class="btn-primary" style="width: auto; padding: 10px 20px; font-size: 13px;">+ إضافة درس جديد</button>
|
|
</div>
|
|
|
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px;" id="courses_list_container">
|
|
<!-- Loaded Dynamically -->
|
|
</div>
|
|
</div>
|
|
|
|
<!-- TAB 2: Students Monitoring -->
|
|
<div id="tab_students_content" class="studio-card" style="display: none;">
|
|
<h3 style="font-size: 18px; font-weight: 900; margin-bottom: 8px;">نبض المشاهدة وتفاعل الطلاب 📊</h3>
|
|
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 20px;">تتبع دقيق لثواني المشاهدة وحل الكويزات السقراطية لكل طالب مشترك.</p>
|
|
|
|
<div style="background: rgba(11,19,43,0.8); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;">
|
|
<table style="width: 100%; border-collapse: collapse; text-align: right; font-size: 13px;">
|
|
<thead>
|
|
<tr style="border-bottom: 1px solid var(--border); background: #121A33; color: var(--text-muted);">
|
|
<th style="padding: 14px 18px;">اسم الطالب</th>
|
|
<th style="padding: 14px 18px;">الصف / الفرع</th>
|
|
<th style="padding: 14px 18px;">نسبة الإنجاز</th>
|
|
<th style="padding: 14px 18px;">نقاط الكويزات الذكية</th>
|
|
<th style="padding: 14px 18px;">آخر نشاط</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr style="border-bottom: 1px solid rgba(255,255,255,0.05);">
|
|
<td style="padding: 14px 18px; font-weight: 700; color: #FFFFFF;">أحمد خالد الشوابكة</td>
|
|
<td style="padding: 14px 18px; color: var(--text-secondary);">توجيهي 2008 (علمي)</td>
|
|
<td style="padding: 14px 18px;"><span style="color: var(--accent-cyan); font-weight: 800;">94%</span></td>
|
|
<td style="padding: 14px 18px; color: var(--accent-gold);">18 / 20</td>
|
|
<td style="padding: 14px 18px; color: var(--text-muted);">قبل 10 دقائق</td>
|
|
</tr>
|
|
<tr style="border-bottom: 1px solid rgba(255,255,255,0.05);">
|
|
<td style="padding: 14px 18px; font-weight: 700; color: #FFFFFF;">سارة محمود العبادي</td>
|
|
<td style="padding: 14px 18px; color: var(--text-secondary);">توجيهي 2008 (علمي)</td>
|
|
<td style="padding: 14px 18px;"><span style="color: var(--accent-cyan); font-weight: 800;">88%</span></td>
|
|
<td style="padding: 14px 18px; color: var(--accent-gold);">16 / 20</td>
|
|
<td style="padding: 14px 18px; color: var(--text-muted);">اليوم 04:15 م</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- TAB 3: Realtime Chat -->
|
|
<div id="tab_chat_content" class="studio-card" style="display: none;">
|
|
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;">
|
|
<div>
|
|
<h3 style="font-size: 18px; font-weight: 900;">غرفة الأسئلة والمحادثة الفورية ⚡</h3>
|
|
<p style="font-size: 12px; color: var(--text-muted);">تواصل فوري مع طلابك المشتركين مدعوم بمحرك WebSocket فائق السرعة.</p>
|
|
</div>
|
|
<span style="font-size: 11px; font-weight: 800; background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.4); color: #34D399; padding: 4px 12px; border-radius: 999px;">
|
|
● المتصلون الآن (Workerman Live)
|
|
</span>
|
|
</div>
|
|
|
|
<div class="chat-box">
|
|
<div class="chat-messages" id="chat_messages_area">
|
|
<div class="chat-msg student">
|
|
<span style="font-size: 10.5px; font-weight: 800; color: var(--accent-gold); display: block; margin-bottom: 2px;">أحمد الشوابكة (توجيهي 2008)</span>
|
|
أستاذ، في سؤال الاشتقاق الضمني بالدقيقة 14:20 ليش ضربنا بـ dy/dx عند الحد الأخير؟
|
|
</div>
|
|
<div class="chat-msg teacher">
|
|
<span style="font-size: 10.5px; opacity: 0.8; display: block; margin-bottom: 2px;">أنت (المعلم)</span>
|
|
أهلاً يا أحمد! لأن y اقتران ضمني بالنسبة لـ x، فحسب قاعدة السلسلة نشتق الحد ثم نضرب بمشتقة y. ارجع لـ Checkpoint 2 بالفيديو وستجد سؤالاً توضيحياً مماثلاً.
|
|
</div>
|
|
</div>
|
|
|
|
<div class="chat-input-bar">
|
|
<input type="text" id="teacher_chat_input" placeholder="اكتب ردك الأكاديمي للطالب..." class="input-text" style="background: var(--bg-input);">
|
|
<button onclick="sendChatMessage()" class="btn-primary" style="width: auto; padding: 0 24px;">إرسال ↵</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</main>
|
|
|
|
<!-- Footer -->
|
|
<footer>
|
|
<div class="container">
|
|
<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;">
|
|
<span>منصة صَقِل التعليمية — نظام استوديو المعلمين المعتمد © 2026</span>
|
|
<span style="color: var(--accent-cyan);">الخادم متصل ومحمي بـ JWT & Redis 🔒</span>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
<!-- Logic Controller -->
|
|
<script>
|
|
let countdownTimer = null;
|
|
let timerSeconds = 0;
|
|
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
const token = localStorage.getItem('saqel_teacher_jwt');
|
|
if (token) {
|
|
await checkTeacherSession(token);
|
|
}
|
|
});
|
|
|
|
function showError(msg) {
|
|
document.getElementById('alert_box_success').style.display = 'none';
|
|
const errBox = document.getElementById('alert_box_error');
|
|
document.getElementById('alert_error_msg').textContent = msg;
|
|
errBox.style.display = 'flex';
|
|
}
|
|
|
|
function showSuccess(msg) {
|
|
document.getElementById('alert_box_error').style.display = 'none';
|
|
const okBox = document.getElementById('alert_box_success');
|
|
document.getElementById('alert_success_msg').textContent = msg;
|
|
okBox.style.display = 'flex';
|
|
}
|
|
|
|
function clearAlerts() {
|
|
document.getElementById('alert_box_error').style.display = 'none';
|
|
document.getElementById('alert_box_success').style.display = 'none';
|
|
}
|
|
|
|
function switchToPhoneStep() {
|
|
document.getElementById('step_otp_container').style.display = 'none';
|
|
document.getElementById('step_onboarding_container').style.display = 'none';
|
|
document.getElementById('step_phone_container').style.display = 'block';
|
|
clearAlerts();
|
|
clearInterval(countdownTimer);
|
|
}
|
|
|
|
function switchToOtpStep(maskedPhone, debugOtp) {
|
|
document.getElementById('step_phone_container').style.display = 'none';
|
|
document.getElementById('step_onboarding_container').style.display = 'none';
|
|
document.getElementById('step_otp_container').style.display = 'block';
|
|
document.getElementById('otp_target_display').textContent = maskedPhone;
|
|
|
|
const otpInput = document.getElementById('teacher_otp_code');
|
|
otpInput.value = debugOtp || '';
|
|
otpInput.focus();
|
|
startTimer(60);
|
|
}
|
|
|
|
function switchToOnboardingStep(prefilledName) {
|
|
document.getElementById('auth_main_title').textContent = 'استكمال توثيق بيانات المعلم';
|
|
document.getElementById('auth_main_subtitle').textContent = 'خطوة واحدة للبدء في نشر حصصك والتواصل مع طلابك';
|
|
document.getElementById('step_phone_container').style.display = 'none';
|
|
document.getElementById('step_otp_container').style.display = 'none';
|
|
document.getElementById('step_onboarding_container').style.display = 'block';
|
|
|
|
if (prefilledName && prefilledName !== 'معلم جديد') {
|
|
document.getElementById('onboard_fullname').value = prefilledName;
|
|
}
|
|
clearAlerts();
|
|
}
|
|
|
|
function startTimer(seconds) {
|
|
timerSeconds = seconds;
|
|
clearInterval(countdownTimer);
|
|
const timerLabel = document.getElementById('resend_timer_label');
|
|
const resendBtn = document.getElementById('btn_resend');
|
|
resendBtn.style.display = 'none';
|
|
timerLabel.style.display = 'inline';
|
|
timerLabel.textContent = `إعادة الإرسال بعد (${timerSeconds}ث)`;
|
|
|
|
countdownTimer = setInterval(() => {
|
|
timerSeconds--;
|
|
if (timerSeconds > 0) {
|
|
timerLabel.textContent = `إعادة الإرسال بعد (${timerSeconds}ث)`;
|
|
} else {
|
|
clearInterval(countdownTimer);
|
|
timerLabel.style.display = 'none';
|
|
resendBtn.style.display = 'inline';
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
// 1. Send OTP
|
|
async function handleSendOtp(e) {
|
|
if (e) e.preventDefault();
|
|
clearAlerts();
|
|
|
|
const phoneInput = document.getElementById('teacher_phone');
|
|
const sendBtn = document.getElementById('btn_send_otp');
|
|
const sendText = document.getElementById('btn_send_text');
|
|
const sendSpinner = document.getElementById('btn_send_spinner');
|
|
const phone = phoneInput.value.trim();
|
|
|
|
if (!phone) {
|
|
showError('يرجى إدخال رقم الهاتف المسجل');
|
|
phoneInput.focus();
|
|
return;
|
|
}
|
|
|
|
sendBtn.disabled = true;
|
|
sendText.textContent = 'جارٍ الإرسال عبر الواتساب...';
|
|
sendSpinner.style.display = 'block';
|
|
|
|
try {
|
|
const res = await fetch('/api/auth/otp/request', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ phone_number: phone, role: 'teacher' })
|
|
});
|
|
const data = await res.json();
|
|
if (res.ok && data.status === 'success') {
|
|
showSuccess(data.message || 'تم إرسال رمز التحقق عبر الواتساب');
|
|
switchToOtpStep(data.data?.phone_masked || phone, data.debug_otp);
|
|
} else {
|
|
showError(data.message || 'فشل إرسال رمز التحقق');
|
|
}
|
|
} catch (err) {
|
|
showError('حدث خطأ في الاتصال بالخادم.');
|
|
} finally {
|
|
sendBtn.disabled = false;
|
|
sendText.textContent = 'إرسال رمز الدخول (OTP) ←';
|
|
sendSpinner.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// 2. Verify OTP
|
|
async function handleVerifyOtp(e) {
|
|
if (e) e.preventDefault();
|
|
clearAlerts();
|
|
|
|
const phone = document.getElementById('teacher_phone').value.trim();
|
|
const otpCode = document.getElementById('teacher_otp_code').value.trim();
|
|
const verifyBtn = document.getElementById('btn_verify_otp');
|
|
const verifyText = document.getElementById('btn_verify_text');
|
|
const verifySpinner = document.getElementById('btn_verify_spinner');
|
|
|
|
if (!otpCode || otpCode.length < 6) {
|
|
showError('يرجى إدخال رمز التحقق المكون من 6 أرقام');
|
|
return;
|
|
}
|
|
|
|
verifyBtn.disabled = true;
|
|
verifyText.textContent = 'جارٍ التحقق...';
|
|
verifySpinner.style.display = 'block';
|
|
|
|
try {
|
|
const res = await fetch('/api/auth/otp/verify', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
phone_number: phone,
|
|
otp: otpCode,
|
|
role: 'teacher'
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
if (res.ok && data.status === 'success' && data.data?.token) {
|
|
const token = data.data.token;
|
|
localStorage.setItem('saqel_teacher_jwt', token);
|
|
|
|
const user = data.data.user;
|
|
// Immediate UI Transition
|
|
if (user && user.name && user.name !== 'معلم جديد' && user.name !== 'مستخدم صَقِل') {
|
|
renderDashboard(user);
|
|
} else {
|
|
switchToOnboardingStep(user?.name || '');
|
|
}
|
|
|
|
// Sync profile status in background
|
|
checkTeacherSession(token);
|
|
} else {
|
|
showError(data.message || 'رمز التحقق غير صحيح');
|
|
}
|
|
} catch (err) {
|
|
showError('حدث خطأ في التحقق من الرمز.');
|
|
} finally {
|
|
verifyBtn.disabled = false;
|
|
verifyText.textContent = 'تأكيد الدخول للاستوديو 🎓';
|
|
verifySpinner.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// 3. Complete Onboarding Profile (Password + Grades + Subjects)
|
|
async function handleCompleteOnboarding(e) {
|
|
if (e) e.preventDefault();
|
|
clearAlerts();
|
|
|
|
const token = localStorage.getItem('saqel_teacher_jwt');
|
|
const fullName = document.getElementById('onboard_fullname').value.trim();
|
|
const spec = document.getElementById('onboard_specialization').value;
|
|
const password = document.getElementById('onboard_password').value.trim();
|
|
const bio = document.getElementById('onboard_bio').value.trim();
|
|
|
|
const checkedGrades = Array.from(document.querySelectorAll('input[name="grades"]:checked')).map(cb => cb.value);
|
|
|
|
if (!fullName) {
|
|
showError('يرجى إدخال اسمك ولقب التدريس');
|
|
return;
|
|
}
|
|
if (!password || password.length < 8) {
|
|
showError('كلمة المرور يجب أن تكون 8 خانات على الأقل لضمان أمان حسابك');
|
|
return;
|
|
}
|
|
|
|
const btn = document.getElementById('btn_complete_onboarding');
|
|
const btnText = document.getElementById('btn_onboard_text');
|
|
const spinner = document.getElementById('btn_onboard_spinner');
|
|
|
|
btn.disabled = true;
|
|
btnText.textContent = 'جارٍ حفظ وتأمين الملف...';
|
|
spinner.style.display = 'block';
|
|
|
|
try {
|
|
const res = await fetch('/api/teacher/profile/setup', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Bearer ' + token
|
|
},
|
|
body: JSON.stringify({
|
|
full_name: fullName,
|
|
specialization: spec,
|
|
password: password,
|
|
grade_levels: checkedGrades,
|
|
bio: bio
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
if (res.ok && data.status === 'success') {
|
|
showSuccess('تم توثيق وتفعيل حسابك بنجاح! أهلاً بك في استوديو صَقِل.');
|
|
// Immediate Direct Transition to Studio Dashboard
|
|
renderDashboard({ full_name: fullName }, { specialization: spec });
|
|
// Sync in background
|
|
checkTeacherSession(token);
|
|
} else {
|
|
showError(data.message || 'فشل حفظ الملف الشخصي.');
|
|
}
|
|
} catch (err) {
|
|
showError('حدث خطأ في الاتصال بالخادم.');
|
|
} finally {
|
|
btn.disabled = false;
|
|
btnText.textContent = 'حفظ وتفعيل لوحة التحكم 🚀';
|
|
spinner.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Check if teacher is new or existing
|
|
async function checkTeacherSession(token) {
|
|
try {
|
|
const res = await fetch('/api/teacher/profile/status', {
|
|
headers: { 'Authorization': 'Bearer ' + token }
|
|
});
|
|
const data = await res.json();
|
|
|
|
if (res.ok && data.status === 'success') {
|
|
if (data.is_completed) {
|
|
renderDashboard(data.user, data.profile);
|
|
} else {
|
|
switchToOnboardingStep(data.user?.full_name);
|
|
}
|
|
} else {
|
|
localStorage.removeItem('saqel_teacher_jwt');
|
|
}
|
|
} catch (e) {
|
|
console.error('Session check failed:', e);
|
|
}
|
|
}
|
|
|
|
function renderDashboard(user, profile) {
|
|
document.getElementById('auth_container').style.display = 'none';
|
|
document.getElementById('dashboard_container').style.display = 'block';
|
|
document.getElementById('switch_to_student_link').style.display = 'none';
|
|
document.getElementById('auth_user_badge').style.display = 'flex';
|
|
|
|
const name = user?.full_name || 'أستاذنا الفاضل';
|
|
const spec = profile?.specialization || 'المعلم المعتمد';
|
|
|
|
document.getElementById('teacher_display_name').textContent = `أهلاً، ${name}`;
|
|
document.getElementById('dashboard_welcome_title').textContent = `أهلاً بك يا ${name} 👨🏫`;
|
|
document.getElementById('dashboard_specialization_badge').textContent = `${spec} — استوديو صَقِل التفاعلي`;
|
|
|
|
loadDashboardStats(localStorage.getItem('saqel_teacher_jwt'));
|
|
loadTeacherCourses(localStorage.getItem('saqel_teacher_jwt'));
|
|
}
|
|
|
|
async function loadDashboardStats(token) {
|
|
try {
|
|
const res = await fetch('/api/teacher/dashboard', {
|
|
headers: { 'Authorization': 'Bearer ' + token }
|
|
});
|
|
const data = await res.json();
|
|
if (res.ok && data.data) {
|
|
document.getElementById('stat_courses_count').textContent = data.data.courses_count || '0';
|
|
document.getElementById('stat_students_count').textContent = data.data.students_count || '0';
|
|
}
|
|
} catch(e) {}
|
|
}
|
|
|
|
async function loadTeacherCourses(token) {
|
|
const container = document.getElementById('courses_list_container');
|
|
try {
|
|
const res = await fetch('/api/teacher/courses', {
|
|
headers: { 'Authorization': 'Bearer ' + token }
|
|
});
|
|
const data = await res.json();
|
|
if (res.ok && data.data && data.data.length > 0) {
|
|
container.innerHTML = data.data.map(c => `
|
|
<div style="background: rgba(11,19,43,0.8); border: 1px solid var(--border); border-radius: 16px; padding: 20px;">
|
|
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px;">
|
|
<h4 style="font-size: 16px; font-weight: 800; color: #FFFFFF;">${c.title}</h4>
|
|
<span style="font-size: 11px; background: rgba(255,209,102,0.15); color: var(--accent-gold); padding: 2px 8px; border-radius: 6px; font-weight: 700;">${c.price_jod} د.أ</span>
|
|
</div>
|
|
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 16px;">${c.description || 'لا يوجد وصف مسجل'}</p>
|
|
<div style="display: flex; justify-content: space-between; align-items: center; border-top: 1px solid rgba(255,255,255,0.06); padding-top: 12px; font-size: 12px;">
|
|
<span style="color: var(--accent-cyan);">🎬 ${c.lessons_total || 0} دروس تفاعلية</span>
|
|
<a href="#" style="color: var(--accent-gold); font-weight: 700; text-decoration: none;">إدارة المحتوى ←</a>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
} else {
|
|
container.innerHTML = `
|
|
<div style="grid-column: 1 / -1; text-align: center; padding: 40px; background: rgba(11,19,43,0.5); border: 1px dashed var(--border); border-radius: 16px;">
|
|
<span style="font-size: 32px; display: block; margin-bottom: 8px;">📚</span>
|
|
<h4 style="color: #FFFFFF; font-size: 15px; font-weight: 800;">لم تقم بإنشاء أي دورات بعد</h4>
|
|
<p style="color: var(--text-muted); font-size: 12px; margin-top: 4px;">ابدأ بإضافة دورتك الأولى واربط دروس الفيديو المشفرة بسهولة.</p>
|
|
</div>
|
|
`;
|
|
}
|
|
} catch (e) {}
|
|
}
|
|
|
|
function switchDashboardTab(tab) {
|
|
document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
|
|
event.currentTarget.classList.add('active');
|
|
|
|
document.getElementById('tab_courses_content').style.display = (tab === 'courses') ? 'block' : 'none';
|
|
document.getElementById('tab_students_content').style.display = (tab === 'students') ? 'block' : 'none';
|
|
document.getElementById('tab_chat_content').style.display = (tab === 'chat') ? 'block' : 'none';
|
|
}
|
|
|
|
function sendChatMessage() {
|
|
const input = document.getElementById('teacher_chat_input');
|
|
const text = input.value.trim();
|
|
if (!text) return;
|
|
|
|
const area = document.getElementById('chat_messages_area');
|
|
const msgDiv = document.createElement('div');
|
|
msgDiv.className = 'chat-msg teacher';
|
|
msgDiv.innerHTML = `<span style="font-size: 10.5px; opacity: 0.8; display: block; margin-bottom: 2px;">أنت (المعلم)</span>${text}`;
|
|
area.appendChild(msgDiv);
|
|
area.scrollTop = area.scrollHeight;
|
|
input.value = '';
|
|
}
|
|
|
|
function handleLogout() {
|
|
const token = localStorage.getItem('saqel_teacher_jwt');
|
|
if (token) {
|
|
fetch('/api/auth/logout', {
|
|
method: 'POST',
|
|
headers: { 'Authorization': 'Bearer ' + token }
|
|
}).catch(() => {});
|
|
}
|
|
localStorage.removeItem('saqel_teacher_jwt');
|
|
location.reload();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
HTML;
|
|
}
|
|
}
|