933 lines
36 KiB
PHP
933 lines
36 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;
|
|
}
|
|
|
|
* {
|
|
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: 1140px;
|
|
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 Content */
|
|
main {
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 40px 0;
|
|
}
|
|
|
|
/* Auth Card */
|
|
.auth-card-wrapper {
|
|
width: 100%;
|
|
max-width: 460px;
|
|
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 & Inputs */
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
/* High Contrast 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;
|
|
}
|
|
|
|
/* 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);
|
|
}
|
|
|
|
.auth-footer {
|
|
margin-top: 24px;
|
|
padding-top: 16px;
|
|
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
|
text-align: center;
|
|
font-size: 11.5px;
|
|
color: var(--text-muted);
|
|
}
|
|
|
|
/* Dashboard Styles */
|
|
.dashboard-hero {
|
|
background: linear-gradient(135deg, var(--bg-card), var(--bg-card-hover));
|
|
border: 1px solid var(--border);
|
|
border-radius: 24px;
|
|
padding: 32px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 24px;
|
|
flex-wrap: wrap;
|
|
margin-bottom: 28px;
|
|
}
|
|
|
|
.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: 140px;
|
|
}
|
|
|
|
.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); }
|
|
|
|
.studio-card {
|
|
background: var(--bg-card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 24px;
|
|
padding: 32px;
|
|
}
|
|
|
|
.grid-2 {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 20px;
|
|
background: rgba(11, 19, 43, 0.8);
|
|
border: 1px solid var(--border);
|
|
border-radius: 16px;
|
|
padding: 24px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.grid-2 { grid-template-columns: 1fr; }
|
|
.dashboard-hero { padding: 24px; }
|
|
}
|
|
|
|
/* Footer */
|
|
footer {
|
|
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
|
padding: 24px 0;
|
|
background: var(--bg-dark);
|
|
color: var(--text-muted);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.footer-content {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
}
|
|
|
|
.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); }
|
|
}
|
|
</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 BOX (LOGIN / OTP) -->
|
|
<!-- ========================================== -->
|
|
<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">استوديو صَقِل للمعلمين</h1>
|
|
<p class="auth-subtitle">حماية محتواك بـ DRM وأرباح متنامية بنظام الشراكة التفاعلية</p>
|
|
</div>
|
|
|
|
<div class="auth-box">
|
|
|
|
<!-- Alert Messages -->
|
|
<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 (Always Visible First) -->
|
|
<div id="step_phone_container">
|
|
<div class="form-group">
|
|
<label class="form-label">اسم الأستاذ / المعلم (اختياري)</label>
|
|
<input type="text" id="teacher_fullname" placeholder="مثال: الأستاذ حمزة النجار" class="input-text">
|
|
</div>
|
|
|
|
<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 (Hidden Initially) -->
|
|
<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>
|
|
|
|
<div class="auth-footer">
|
|
<span>حماية محتوى DRM كاملة + تقاسم أرباح 45%–50% شفاف ومؤتمت</span>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- ========================================== -->
|
|
<!-- 2. TEACHER DASHBOARD (AUTHENTICATED) -->
|
|
<!-- ========================================== -->
|
|
<div id="dashboard_container" style="width: 100%; display: none;">
|
|
|
|
<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;">إدارة دوراتك، إدراج كويزات الفيديو التفاعلية، ومتابعة نمو طلابك.</p>
|
|
</div>
|
|
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<span class="stat-label">إجمالي الطلاب</span>
|
|
<span class="stat-val val-cyan">1,240</span>
|
|
</div>
|
|
<div class="stat-card gold-glow">
|
|
<span class="stat-label">أرباحك المتراكمة</span>
|
|
<span class="stat-val val-gold">19,530 د.أ</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div 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;">حدد الثانية الزمنية في الفيديو التي سيتوقف عندها الشرح لفحص فهم الطالب.</p>
|
|
</div>
|
|
<span style="font-size: 11px; font-weight: 700; background: rgba(0,245,212,0.1); border: 1px solid rgba(0,245,212,0.3); color: var(--accent-cyan); padding: 4px 12px; border-radius: 8px;">Bunny Stream Synced</span>
|
|
</div>
|
|
|
|
<div class="grid-2">
|
|
<div>
|
|
<div class="form-group">
|
|
<label class="form-label">اختر الدورة والدرس</label>
|
|
<select class="input-text">
|
|
<option>الرياضيات العلمي — الدرس 4: قواعد الاشتقاق الأساسية</option>
|
|
<option>الرياضيات العلمي — الدرس 5: الاشتقاق الضمني</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">توقيت ظهور الكويز (بالدقيقة والثانية)</label>
|
|
<input type="text" value="08:30" class="input-text" style="color: var(--accent-cyan); font-family: monospace;">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">عقوبة الخطأ (الإرجاع العلاجي)</label>
|
|
<select class="input-text">
|
|
<option>إرجاع الطالب 45 ثانية للخلف (مستحسن)</option>
|
|
<option>إرجاع الطالب 60 ثانية للخلف</option>
|
|
<option>إعادة مشاهدة المقطع بالكامل</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="form-group">
|
|
<label class="form-label">نص السؤال التفاعلي</label>
|
|
<textarea rows="3" placeholder="اكتب السؤال الذي سيظهر أمام الطالب..." class="input-text" style="resize: none; height: 80px;"></textarea>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<input type="text" placeholder="الخيار الأول (الصحيح)" class="input-text" style="margin-bottom: 8px; border-color: rgba(16,185,129,0.4); color: #6EE7B7;">
|
|
<input type="text" placeholder="الخيار الثاني (الخاطئ)" class="input-text">
|
|
</div>
|
|
|
|
<button type="button" class="btn-primary" style="padding: 10px;">حفظ الكويز داخل الفيديو ✓</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</main>
|
|
|
|
<!-- Footer -->
|
|
<footer>
|
|
<div class="container">
|
|
<div class="footer-content">
|
|
<span>منصة صَقِل التعليمية — نظام استوديو المعلمين © 2026</span>
|
|
<div style="display: flex; gap: 16px;">
|
|
<a href="/student" class="nav-link">بوابة الطلاب</a>
|
|
<span style="color: var(--accent-cyan);">الخادم متصل ومشفر 🔒</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
<!-- Pure Bulletproof Vanilla JavaScript Logic (100% Native Reliability) -->
|
|
<script>
|
|
let countdownTimer = null;
|
|
let timerSeconds = 0;
|
|
|
|
// On Page Load: Check existing session
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
const token = localStorage.getItem('saqel_teacher_jwt');
|
|
if (token) {
|
|
await checkActiveSession(token);
|
|
}
|
|
});
|
|
|
|
function showError(msg) {
|
|
const errBox = document.getElementById('alert_box_error');
|
|
const errSpan = document.getElementById('alert_error_msg');
|
|
const okBox = document.getElementById('alert_box_success');
|
|
okBox.style.display = 'none';
|
|
errSpan.textContent = msg;
|
|
errBox.style.display = 'flex';
|
|
}
|
|
|
|
function showSuccess(msg) {
|
|
const okBox = document.getElementById('alert_box_success');
|
|
const okSpan = document.getElementById('alert_success_msg');
|
|
const errBox = document.getElementById('alert_box_error');
|
|
errBox.style.display = 'none';
|
|
okSpan.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_phone_container').style.display = 'block';
|
|
clearAlerts();
|
|
clearInterval(countdownTimer);
|
|
}
|
|
|
|
function switchToOtpStep(maskedPhone) {
|
|
document.getElementById('step_phone_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 = '';
|
|
otpInput.focus();
|
|
startTimer(60);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
async function getDeviceFingerprint() {
|
|
try {
|
|
const raw = [
|
|
navigator.userAgent,
|
|
screen.width + 'x' + screen.height,
|
|
Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
].join('###');
|
|
const msgUint8 = new TextEncoder().encode(raw);
|
|
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
|
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
} catch (e) {
|
|
return 'teacher_web_' + Math.random().toString(36).substring(2);
|
|
}
|
|
}
|
|
|
|
// 1. Send OTP Handler
|
|
async function handleSendOtp(e) {
|
|
if (e) e.preventDefault();
|
|
clearAlerts();
|
|
|
|
const phoneInput = document.getElementById('teacher_phone');
|
|
const nameInput = document.getElementById('teacher_fullname');
|
|
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();
|
|
const fullName = nameInput.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',
|
|
full_name: fullName
|
|
})
|
|
});
|
|
|
|
const data = await res.json();
|
|
console.log('Nabeh OTP Response:', data);
|
|
|
|
if (res.ok && data.status === 'success') {
|
|
showSuccess(data.message || 'تم إرسال بطاقة التحقق عبر الواتساب!');
|
|
switchToOtpStep(data.data?.phone_masked || phone, data.debug_otp);
|
|
} else {
|
|
showError(data.message || 'فشل إرسال رمز التحقق من منصة نبيه.');
|
|
}
|
|
} catch (err) {
|
|
console.error('Fetch error:', err);
|
|
showError('حدث خطأ في الاتصال بالسيرفر. تأكد من اتصال الإنترنت.');
|
|
} finally {
|
|
sendBtn.disabled = false;
|
|
sendText.textContent = 'دخول استوديو المعلم (OTP) ←';
|
|
sendSpinner.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// 2. Verify OTP Handler
|
|
async function handleVerifyOtp(e) {
|
|
if (e) e.preventDefault();
|
|
clearAlerts();
|
|
|
|
const phone = document.getElementById('teacher_phone').value.trim();
|
|
const fullName = document.getElementById('teacher_fullname').value.trim();
|
|
const otpInput = document.getElementById('teacher_otp_code');
|
|
const otpCode = otpInput.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 أرقام');
|
|
otpInput.focus();
|
|
return;
|
|
}
|
|
|
|
verifyBtn.disabled = true;
|
|
verifyText.textContent = 'جارٍ التحقق وتأكيد الجلسة...';
|
|
verifySpinner.style.display = 'block';
|
|
|
|
try {
|
|
const fingerprint = await getDeviceFingerprint();
|
|
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',
|
|
full_name: fullName,
|
|
device_fingerprint: fingerprint
|
|
})
|
|
});
|
|
|
|
const data = await res.json();
|
|
console.log('Verify Response:', data);
|
|
|
|
if (res.ok && data.status === 'success' && data.data?.token) {
|
|
localStorage.setItem('saqel_teacher_jwt', data.data.token);
|
|
renderDashboard(data.data.user);
|
|
} else {
|
|
showError(data.message || 'رمز التحقق غير صحيح أو منتهي الصلاحية');
|
|
}
|
|
} catch (err) {
|
|
console.error('Verify error:', err);
|
|
showError('حدث خطأ في التحقق من الرمز.');
|
|
} finally {
|
|
verifyBtn.disabled = false;
|
|
verifyText.textContent = 'تأكيد الدخول للاستوديو 🎓';
|
|
verifySpinner.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
async function checkActiveSession(token) {
|
|
try {
|
|
const res = await fetch('/api/auth/me', {
|
|
headers: { 'Authorization': 'Bearer ' + token }
|
|
});
|
|
const data = await res.json();
|
|
if (res.ok && data.data && (data.data.role === 'teacher' || data.data.role === 'super_admin')) {
|
|
renderDashboard({
|
|
name: data.data.full_name,
|
|
phone: data.data.phone_number
|
|
});
|
|
} else {
|
|
localStorage.removeItem('saqel_teacher_jwt');
|
|
}
|
|
} catch (e) {
|
|
console.error('Session check error:', e);
|
|
}
|
|
}
|
|
|
|
function renderDashboard(user) {
|
|
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 displayName = user?.name || 'أستاذنا الفاضل';
|
|
document.getElementById('teacher_display_name').textContent = `أهلاً، ${displayName}`;
|
|
document.getElementById('dashboard_welcome_title').textContent = `أهلاً بك، ${displayName} 👨🏫`;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|