Initial commit (code), runtime ignoré, secrets exclus
This commit is contained in:
777
enseignant/dashboard.php
Normal file
777
enseignant/dashboard.php
Normal file
@ -0,0 +1,777 @@
|
||||
<?php
|
||||
/**
|
||||
* Tableau de bord enseignant
|
||||
* Fichier : dashboard_enseignant.php
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
require_once __DIR__ . '/../config/session.php';
|
||||
|
||||
// Vérifier que l'utilisateur est connecté et est un enseignant
|
||||
// if (!SessionManager::isEnseignant()) {
|
||||
// header('Location: ../login.php?error=session');
|
||||
// exit();
|
||||
// }
|
||||
|
||||
$user = SessionManager::getUser();
|
||||
|
||||
try {
|
||||
$db = Database::getInstance()->getConnection();
|
||||
|
||||
// Récupérer les statistiques globales
|
||||
$stmt = $db->query("
|
||||
SELECT
|
||||
(SELECT COUNT(*) FROM utilisateurs WHERE id_type IN (2,3)) as nb_eleves,
|
||||
(SELECT COUNT(*) FROM classes WHERE actif = 1) as nb_classes,
|
||||
(SELECT COUNT(*) FROM utilisateurs WHERE id_type = 1) as nb_enseignants,
|
||||
(SELECT COUNT(*) FROM evaluations WHERE actif = 1) as nb_evaluations_actives,
|
||||
(SELECT COUNT(*) FROM evaluations) as nb_evaluations_total
|
||||
");
|
||||
$stats = $stmt->fetch();
|
||||
|
||||
// Récupérer les évaluations récentes
|
||||
$stmt = $db->query("
|
||||
SELECT
|
||||
e.id_evaluation,
|
||||
e.titre,
|
||||
e.type,
|
||||
e.actif,
|
||||
e.duree_minutes,
|
||||
e.note_totale,
|
||||
COUNT(DISTINCT q.id_question) as nb_questions,
|
||||
COUNT(DISTINCT t.id_eleve) as nb_participants
|
||||
FROM evaluations e
|
||||
LEFT JOIN questions q ON e.id_evaluation = q.id_evaluation
|
||||
LEFT JOIN tentatives_eleves t ON e.id_evaluation = t.id_evaluation
|
||||
GROUP BY e.id_evaluation
|
||||
ORDER BY e.id_evaluation DESC
|
||||
LIMIT 5
|
||||
");
|
||||
$evaluations_recentes = $stmt->fetchAll();
|
||||
|
||||
// Récupérer la liste des classes avec le nombre d'élèves
|
||||
$stmt = $db->query("
|
||||
SELECT
|
||||
c.id_classe,
|
||||
c.nom_classe,
|
||||
c.niveau,
|
||||
c.type_classe,
|
||||
COUNT(u.id_utilisateur) as nb_eleves
|
||||
FROM classes c
|
||||
LEFT JOIN utilisateurs u ON c.id_classe = u.id_classe AND u.actif = 1
|
||||
WHERE c.actif = 1
|
||||
GROUP BY c.id_classe
|
||||
ORDER BY c.niveau, c.nom_classe
|
||||
");
|
||||
$classes = $stmt->fetchAll();
|
||||
|
||||
// Récupérer les dernières connexions
|
||||
$stmt = $db->query("
|
||||
SELECT
|
||||
u.login,
|
||||
u.nom,
|
||||
u.prenom,
|
||||
c.nom_classe,
|
||||
u.date_derniere_connexion
|
||||
FROM utilisateurs u
|
||||
LEFT JOIN classes c ON u.id_classe = c.id_classe
|
||||
WHERE u.id_type IN (2,3) AND u.date_derniere_connexion IS NOT NULL
|
||||
ORDER BY u.date_derniere_connexion DESC
|
||||
LIMIT 10
|
||||
");
|
||||
$dernieres_connexions = $stmt->fetchAll();
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log("Erreur dashboard enseignant : " . $e->getMessage());
|
||||
$stats = ['nb_eleves' => 0, 'nb_classes' => 0, 'nb_enseignants' => 0, 'nb_evaluations_actives' => 0, 'nb_evaluations_total' => 0];
|
||||
$classes = [];
|
||||
$evaluations_recentes = [];
|
||||
$dernieres_connexions = [];
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="theme-color" content="#1976d2">
|
||||
<title>Dashboard Enseignant - <?= htmlspecialchars($user['prenom']) ?></title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||
background: #f5f5f5;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.header {
|
||||
background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
|
||||
color: white;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.header-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-logout {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
color: white;
|
||||
padding: 8px 15px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.user-info p {
|
||||
margin: 5px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.user-info strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Container */
|
||||
.container {
|
||||
padding: 20px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* Cartes de statistiques */
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
gap: 15px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.08);
|
||||
text-align: center;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.stat-card .icon {
|
||||
font-size: 36px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.stat-card .value {
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
color: #1976d2;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.stat-card .label {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* Section */
|
||||
.section {
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.08);
|
||||
}
|
||||
|
||||
.section h2 {
|
||||
font-size: 20px;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* Table */
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
th {
|
||||
background: #f8f9fa;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
td {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 4px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge-primary {
|
||||
background: #e3f2fd;
|
||||
color: #1976d2;
|
||||
}
|
||||
|
||||
.badge-success {
|
||||
background: #e8f5e9;
|
||||
color: #2e7d32;
|
||||
}
|
||||
|
||||
.badge-warning {
|
||||
background: #fff3e0;
|
||||
color: #f57c00;
|
||||
}
|
||||
|
||||
.badge-secondary {
|
||||
background: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* Boutons d'action */
|
||||
.action-buttons {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 15px 20px;
|
||||
border-radius: 12px;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
transition: all 0.2s;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-info {
|
||||
background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #f5f5f5;
|
||||
color: #333;
|
||||
border: 2px solid #e0e0e0;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Temps relatif */
|
||||
.time-relative {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Empty state */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-state .icon {
|
||||
font-size: 48px;
|
||||
margin-bottom: 15px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* Evaluation card */
|
||||
.eval-card {
|
||||
border: 2px solid #e0e0e0;
|
||||
border-radius: 10px;
|
||||
padding: 15px;
|
||||
margin-bottom: 15px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.eval-card:hover {
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 3px 10px rgba(102, 126, 234, 0.2);
|
||||
}
|
||||
|
||||
.eval-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: start;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.eval-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.eval-meta {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
flex-wrap: wrap;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.eval-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
.container {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
table {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<div class="header-top">
|
||||
<h1>👨🏫 Dashboard Enseignant</h1>
|
||||
<a href="../logout.php" class="btn-logout">Déconnexion</a>
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<p><strong><?= htmlspecialchars($user['prenom'] . ' ' . $user['nom']) ?></strong></p>
|
||||
<p>🎓 Enseignant de Mathématiques</p>
|
||||
<p>Login : <?= htmlspecialchars($user['login']) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Container principal -->
|
||||
<div class="container">
|
||||
<!-- Statistiques globales -->
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="icon">👥</div>
|
||||
<div class="value"><?= $stats['nb_eleves'] ?></div>
|
||||
<div class="label">Élèves</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="icon">🏫</div>
|
||||
<div class="value"><?= $stats['nb_classes'] ?></div>
|
||||
<div class="label">Classes</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="icon">📝</div>
|
||||
<div class="value"><?= $stats['nb_evaluations_actives'] ?></div>
|
||||
<div class="label">Évaluations actives</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="icon">📚</div>
|
||||
<div class="value"><?= $stats['nb_evaluations_total'] ?></div>
|
||||
<div class="label">Total évaluations</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Actions rapides -->
|
||||
<div class="section">
|
||||
<h2>⚡ Gestion des évaluations</h2>
|
||||
<div class="action-buttons">
|
||||
<a href="../importer_evaluation.php" class="btn btn-primary">
|
||||
📥 Importer une évaluation
|
||||
</a>
|
||||
<a href="#liste-evaluations" class="btn btn-info">
|
||||
📋 Voir toutes les évaluations
|
||||
</a>
|
||||
<a href="statistiques/index.php" class="btn btn-secondary">
|
||||
📊 Statistiques détaillées
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Évaluations récentes -->
|
||||
<div class="section" id="liste-evaluations">
|
||||
<h2>📝 Évaluations récentes</h2>
|
||||
<?php if (count($evaluations_recentes) > 0): ?>
|
||||
<?php foreach ($evaluations_recentes as $eval): ?>
|
||||
<div class="eval-card">
|
||||
<div class="eval-header">
|
||||
<div>
|
||||
<div class="eval-title"><?= htmlspecialchars($eval['titre']) ?></div>
|
||||
<div class="eval-meta">
|
||||
<span>📋 <?= $eval['nb_questions'] ?> question(s)</span>
|
||||
<span>⏱️ <?= $eval['duree_minutes'] ?> min</span>
|
||||
<span>📊 <?= $eval['note_totale'] ?> pts</span>
|
||||
<span>👥 <?= $eval['nb_participants'] ?> participant(s)</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="badge <?= $eval['actif'] ? 'badge-success' : 'badge-secondary' ?>">
|
||||
<?= $eval['actif'] ? '✓ Active' : '✕ Inactive' ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="eval-actions">
|
||||
<a href="../gerer_evaluation.php?id=<?= $eval['id_evaluation'] ?>" class="btn btn-primary btn-sm">
|
||||
⚙️ Gérer
|
||||
</a>
|
||||
<a href="../resultat_evaluation.php?id=<?= $eval['id_evaluation'] ?>" class="btn btn-info btn-sm">
|
||||
📊 Résultats
|
||||
</a>
|
||||
<a href="../passer_evaluation.php?id_evaluation=<?= $eval['id_evaluation'] ?>&apercu=1" target="_blank" class="btn btn-secondary btn-sm">
|
||||
<a href="monitoring.php?id_evaluation=<?= $eval['id_evaluation'] ?>"
|
||||
class="btn-action"
|
||||
style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white;"
|
||||
title="Monitoring temps réel">
|
||||
📊 Monitoring
|
||||
</a>
|
||||
👁️ Aperçu
|
||||
</a>
|
||||
<a href="export.php?id_evaluation=<?= $eval['id_evaluation'] ?>&format=csv"
|
||||
class="btn btn-success btn-sm"
|
||||
title="Télécharger CSV (Excel)">
|
||||
📥 CSV
|
||||
</a>
|
||||
<a href="export.php?id_evaluation=<?= $eval['id_evaluation'] ?>&format=json"
|
||||
class="btn btn-warning btn-sm"
|
||||
title="Télécharger JSON (Archive)">
|
||||
📥 JSON
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="empty-state">
|
||||
<div class="icon">📝</div>
|
||||
<p>Aucune évaluation créée</p>
|
||||
<p style="margin-top: 10px;">
|
||||
<a href="../importer_evaluation.php" class="btn btn-primary">
|
||||
📥 Importer votre première évaluation
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Actions secondaires -->
|
||||
<div class="section">
|
||||
<h2>⚡ Autres actions</h2>
|
||||
<div class="action-buttons">
|
||||
<button class="btn btn-secondary" disabled title="Fonctionnalité en développement">➕ Ajouter un élève</button>
|
||||
<button class="btn btn-secondary" disabled title="Fonctionnalité en développement">📝 Créer un exercice</button>
|
||||
<button class="btn btn-secondary" disabled title="Fonctionnalité en développement">⚙️ Paramètres</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Liste des classes -->
|
||||
<div class="section">
|
||||
<h2>🏫 Mes classes</h2>
|
||||
<div class="table-responsive">
|
||||
<?php if (count($classes) > 0): ?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Classe</th>
|
||||
<th>Niveau</th>
|
||||
<th>Type</th>
|
||||
<th>Élèves</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($classes as $classe): ?>
|
||||
<tr>
|
||||
<td><strong><?= htmlspecialchars($classe['nom_classe']) ?></strong></td>
|
||||
<td><?= htmlspecialchars($classe['niveau']) ?></td>
|
||||
<td>
|
||||
<span class="badge <?= $classe['type_classe'] == 'reguliere' ? 'badge-primary' : 'badge-secondary' ?>">
|
||||
<?= ucfirst($classe['type_classe']) ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><?= $classe['nb_eleves'] ?> élève(s)</td>
|
||||
<td>
|
||||
<button class="btn btn-primary btn-sm" onclick="voirEleves(<?php echo $classe['id_classe']; ?>, '<?php echo htmlspecialchars($classe['nom_classe'], ENT_QUOTES); ?>')">👥 Voir</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<div class="empty-state">
|
||||
<div class="icon">📚</div>
|
||||
<p>Aucune classe active</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Dernières connexions -->
|
||||
<div class="section">
|
||||
<h2>🕒 Dernières connexions</h2>
|
||||
<div class="table-responsive">
|
||||
<?php if (count($dernieres_connexions) > 0): ?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Élève</th>
|
||||
<th>Classe</th>
|
||||
<th>Dernière connexion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($dernieres_connexions as $connexion): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?= htmlspecialchars($connexion['prenom'] . ' ' . $connexion['nom']) ?></strong>
|
||||
<div class="time-relative"><?= htmlspecialchars($connexion['login']) ?></div>
|
||||
</td>
|
||||
<td><?= htmlspecialchars($connexion['nom_classe'] ?? '-') ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$date = new DateTime($connexion['date_derniere_connexion']);
|
||||
echo $date->format('d/m/Y à H:i');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<div class="empty-state">
|
||||
<div class="icon">👤</div>
|
||||
<p>Aucune connexion récente</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Renouvellement automatique de la session
|
||||
setInterval(() => {
|
||||
fetch('api/renew_session.php', { method: 'POST' })
|
||||
.catch(err => console.error('Erreur renouvellement:', err));
|
||||
}, 600000); // Toutes les 10 minutes
|
||||
</script>
|
||||
|
||||
<!-- Modal pour voir les élèves -->
|
||||
<div id="modalEleves" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000;">
|
||||
<div style="background: white; margin: 50px auto; max-width: 800px; border-radius: 10px; padding: 30px; max-height: 80vh; overflow-y: auto;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
||||
<h2 id="modalTitre" style="margin: 0;">Liste des élèves</h2>
|
||||
<button onclick="fermerModal()" style="background: #e74c3c; color: white; border: none; padding: 10px 15px; border-radius: 5px; cursor: pointer;">✕ Fermer</button>
|
||||
</div>
|
||||
<div id="modalContenu">
|
||||
<div style="text-align: center; padding: 40px;">
|
||||
<p>Chargement des élèves...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function voirEleves(idClasse, nomClasse) {
|
||||
document.getElementById('modalEleves').style.display = 'block';
|
||||
document.getElementById('modalTitre').textContent = 'Élèves de ' + nomClasse;
|
||||
|
||||
fetch('get_eleves_classe.php?id_classe=' + idClasse)
|
||||
.then(response => {
|
||||
console.log('Réponse get_eleves_classe:', response);
|
||||
if (!response.ok) {
|
||||
console.error('Erreur HTTP:', response.status);
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then(text => {
|
||||
console.log('Contenu brut:', text.substring(0, 200));
|
||||
return JSON.parse(text);
|
||||
})
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
afficherEleves(data.eleves);
|
||||
} else {
|
||||
document.getElementById('modalContenu').innerHTML = '<div class="alert alert-danger">Erreur : ' + data.message + '</div>';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
document.getElementById('modalContenu').innerHTML = '<div class="alert alert-danger">Erreur : ' + error.message + '</div>';
|
||||
});
|
||||
}
|
||||
|
||||
function afficherEleves(eleves) {
|
||||
if (eleves.length === 0) {
|
||||
document.getElementById('modalContenu').innerHTML = '<div class="alert alert-info">Aucun élève dans cette classe</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Message mot de passe en haut
|
||||
let html = '<div class="alert alert-info mb-3">';
|
||||
html += '<strong>🔑 Mot de passe par défaut :</strong> <code class="bg-white text-dark px-2 py-1" style="font-size: 1.1em;">eleve2025</code>';
|
||||
html += '<p class="mb-0 mt-2"><small>Ce mot de passe est utilisé pour tous les élèves lors de l\'import.</small></p>';
|
||||
html += '</div>';
|
||||
|
||||
// Tableau avec colonne mot de passe
|
||||
html += '<table class="table table-striped"><thead><tr><th>Login</th><th>Nom</th><th>Prénom</th><th>Mot de passe</th><th>Statut</th><th>Actions</th></tr></thead><tbody>';
|
||||
|
||||
eleves.forEach(eleve => {
|
||||
let statut = eleve.actif == 1 ? '<span class="badge badge-success">Actif</span>' : '<span class="badge badge-secondary">Inactif</span>';
|
||||
html += '<tr>';
|
||||
html += '<td><code>' + eleve.login + '</code></td>';
|
||||
html += '<td>' + eleve.nom + '</td>';
|
||||
html += '<td>' + eleve.prenom + '</td>';
|
||||
html += '<td><code class="text-primary">eleve2025</code></td>';
|
||||
html += '<td>' + statut + '</td>';
|
||||
html += '<td><button class="btn btn-sm btn-warning" onclick="resetMotDePasse(' + eleve.id_utilisateur + ', \'' + eleve.login + '\', \'' + eleve.prenom + ' ' + eleve.nom + '\')">🔄 Reset</button></td>';
|
||||
html += '</tr>';
|
||||
});
|
||||
|
||||
html += '</tbody></table><p class="text-muted"><strong>Total :</strong> ' + eleves.length + ' élève(s)</p>';
|
||||
document.getElementById('modalContenu').innerHTML = html;
|
||||
}
|
||||
|
||||
function fermerModal() {
|
||||
document.getElementById('modalEleves').style.display = 'none';
|
||||
}
|
||||
|
||||
function resetMotDePasse(idEleve, login, nomComplet) {
|
||||
if (!confirm('Réinitialiser le mot de passe de ' + nomComplet + ' (login: ' + login + ') ?\n\nLe mot de passe sera remis à la valeur par défaut.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Afficher loader
|
||||
const btn = event.target;
|
||||
const textOriginal = btn.innerHTML;
|
||||
btn.innerHTML = '⏳';
|
||||
btn.disabled = true;
|
||||
|
||||
// Appel AJAX
|
||||
fetch('../api/reset_password_eleve.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
credentials: 'include',
|
||||
body: 'id_eleve=' + idEleve
|
||||
})
|
||||
.then(response => {
|
||||
console.log('Réponse reset_password:', response);
|
||||
if (!response.ok) {
|
||||
console.error('Erreur HTTP:', response.status);
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then(text => {
|
||||
console.log('Contenu brut reset:', text.substring(0, 200));
|
||||
return JSON.parse(text);
|
||||
})
|
||||
.then(data => {
|
||||
btn.innerHTML = textOriginal;
|
||||
btn.disabled = false;
|
||||
|
||||
if (data.success) {
|
||||
alert('✅ Mot de passe réinitialisé avec succès !\n\nLogin: ' + data.data.login + '\nNouveau mot de passe: ' + data.data.nouveau_mdp);
|
||||
// Rafraîchir la liste si besoin
|
||||
} else {
|
||||
alert('❌ Erreur: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
btn.innerHTML = textOriginal;
|
||||
btn.disabled = false;
|
||||
alert('❌ Erreur de communication avec le serveur');
|
||||
console.error('Erreur:', error);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('click', function(event) {
|
||||
const modal = document.getElementById('modalEleves');
|
||||
if (event.target === modal) fermerModal();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
268
enseignant/export.php
Normal file
268
enseignant/export.php
Normal file
@ -0,0 +1,268 @@
|
||||
<?php
|
||||
/**
|
||||
* EXPORT ÉVALUATION - BASÉ SUR STRUCTURE RÉELLE BDD
|
||||
* Structure vérifiée via diagnostic_structure_bdd.php
|
||||
*/
|
||||
|
||||
require_once '../config/config.php';
|
||||
require_once '../config/database.php';
|
||||
require_once '../config/session.php';
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
SessionManager::startSession();
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['type_libelle'] !== 'enseignant') {
|
||||
die('Accès refusé');
|
||||
}
|
||||
|
||||
$id_evaluation = $_GET['id_evaluation'] ?? null;
|
||||
$format = $_GET['format'] ?? 'csv';
|
||||
|
||||
if (!$id_evaluation || !in_array($format, ['csv', 'json'])) {
|
||||
die('Paramètres invalides');
|
||||
}
|
||||
|
||||
try {
|
||||
$db = Database::getInstance()->getConnection();
|
||||
|
||||
// Évaluation
|
||||
$stmt = $db->prepare("SELECT * FROM evaluations WHERE id_evaluation = ?");
|
||||
$stmt->execute([$id_evaluation]);
|
||||
$evaluation = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$evaluation) {
|
||||
die('Évaluation non trouvée');
|
||||
}
|
||||
|
||||
// Questions
|
||||
$stmt = $db->prepare("SELECT * FROM questions WHERE id_evaluation = ? ORDER BY ordre ASC");
|
||||
$stmt->execute([$id_evaluation]);
|
||||
$questions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Tentatives (CORRECTION: date_fin au lieu de date_soumission)
|
||||
$stmt = $db->prepare("
|
||||
SELECT
|
||||
te.*,
|
||||
TIMESTAMPDIFF(MINUTE, te.date_debut, COALESCE(te.date_fin, NOW())) as duree_minutes_calc,
|
||||
u.login, u.nom, u.prenom,
|
||||
c.nom_classe
|
||||
FROM tentatives_eleves te
|
||||
JOIN utilisateurs u ON te.id_eleve = u.id_utilisateur
|
||||
LEFT JOIN classes c ON u.id_classe = c.id_classe
|
||||
WHERE te.id_evaluation = ?
|
||||
ORDER BY u.nom, u.prenom
|
||||
");
|
||||
$stmt->execute([$id_evaluation]);
|
||||
$tentatives = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($format === 'csv') {
|
||||
exportCSV($evaluation, $questions, $tentatives);
|
||||
} else {
|
||||
exportJSON($evaluation, $questions, $tentatives);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
die('Erreur: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Extrait réponse correcte depuis reponse_correcte_json
|
||||
* Format réel: {"reponse": "x = 4"}
|
||||
*/
|
||||
function extraireReponseCorrecte($question) {
|
||||
// 1. Essayer reponse_correcte_json d'abord (pour type number, text, etc.)
|
||||
$correcte_data = json_decode($question['reponse_correcte_json'] ?? '{}', true);
|
||||
|
||||
if (isset($correcte_data['reponse'])) {
|
||||
$rep = $correcte_data['reponse'];
|
||||
if (is_array($rep)) {
|
||||
return implode(' | ', $rep);
|
||||
}
|
||||
return $rep;
|
||||
}
|
||||
|
||||
// 2. Fallback: chercher dans options_json (pour checkbox, qcm, select)
|
||||
$options = json_decode($question['options_json'] ?? '{}', true);
|
||||
|
||||
if (isset($options['reponses']) && is_array($options['reponses'])) {
|
||||
$correctes = [];
|
||||
foreach ($options['reponses'] as $rep) {
|
||||
if (isset($rep['est_correcte']) && $rep['est_correcte'] === true) {
|
||||
$correctes[] = $rep['texte'] ?? $rep['id'];
|
||||
}
|
||||
}
|
||||
if (!empty($correctes)) {
|
||||
return implode(' + ', $correctes);
|
||||
}
|
||||
}
|
||||
|
||||
// 2b. Format avec 'options' (select)
|
||||
if (isset($options['options']) && is_array($options['options'])) {
|
||||
foreach ($options['options'] as $opt) {
|
||||
if (isset($opt['est_correcte']) && $opt['est_correcte'] === true) {
|
||||
return $opt['texte'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Fallback ultime: options_json peut être un simple array ["opt1", "opt2"]
|
||||
if (isset($options['correct_answer'])) {
|
||||
return $options['correct_answer'];
|
||||
}
|
||||
|
||||
return 'N/A';
|
||||
}
|
||||
|
||||
function exportCSV($evaluation, $questions, $tentatives) {
|
||||
$filename = sprintf(
|
||||
'eval_%d_%s_%s.csv',
|
||||
$evaluation['id_evaluation'],
|
||||
preg_replace('/[^a-z0-9]/i', '_', substr($evaluation['titre'], 0, 30)),
|
||||
date('Ymd_His')
|
||||
);
|
||||
|
||||
header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
|
||||
$output = fopen('php://output', 'w');
|
||||
fprintf($output, chr(0xEF).chr(0xBB).chr(0xBF));
|
||||
|
||||
// En-tête
|
||||
$headers = ['ID', 'Élève', 'Classe', 'Login', 'Statut', 'Début', 'Fin', 'Durée(min)', 'Note', 'Note sur', '%'];
|
||||
|
||||
foreach ($questions as $q) {
|
||||
$headers[] = 'Q' . $q['ordre'];
|
||||
}
|
||||
foreach ($questions as $q) {
|
||||
$headers[] = 'Q' . $q['ordre'] . '_Correcte';
|
||||
}
|
||||
|
||||
fputcsv($output, $headers, ';');
|
||||
|
||||
// Données
|
||||
foreach ($tentatives as $t) {
|
||||
$reponses = json_decode($t['reponses_json'] ?? '{}', true) ?: [];
|
||||
|
||||
$row = [
|
||||
$t['id_tentative'],
|
||||
$t['prenom'] . ' ' . $t['nom'],
|
||||
$t['nom_classe'] ?: 'Libre',
|
||||
$t['login'],
|
||||
$t['statut'],
|
||||
$t['date_debut'],
|
||||
$t['date_fin'] ?: '-',
|
||||
$t['temps_passe'] ?? $t['duree_minutes_calc'],
|
||||
$t['note'] !== null ? number_format($t['note'], 2, ',', '') : 'N/A',
|
||||
$t['note_sur'] ?? $evaluation['note_totale'],
|
||||
$t['pourcentage'] !== null ? number_format($t['pourcentage'], 1, ',', '') . '%' : 'N/A'
|
||||
];
|
||||
|
||||
// Réponses élève
|
||||
foreach ($questions as $q) {
|
||||
$rep = $reponses[$q['id_question']] ?? '';
|
||||
if (is_array($rep)) {
|
||||
$rep = implode(' + ', $rep);
|
||||
} elseif (is_object($rep)) {
|
||||
$rep = json_encode($rep, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$row[] = $rep;
|
||||
}
|
||||
|
||||
// Réponses correctes
|
||||
foreach ($questions as $q) {
|
||||
$row[] = extraireReponseCorrecte($q);
|
||||
}
|
||||
|
||||
fputcsv($output, $row, ';');
|
||||
}
|
||||
|
||||
fclose($output);
|
||||
exit;
|
||||
}
|
||||
|
||||
function exportJSON($evaluation, $questions, $tentatives) {
|
||||
$filename = sprintf(
|
||||
'eval_%d_%s_%s.json',
|
||||
$evaluation['id_evaluation'],
|
||||
preg_replace('/[^a-z0-9]/i', '_', substr($evaluation['titre'], 0, 30)),
|
||||
date('Ymd_His')
|
||||
);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
|
||||
$export = [
|
||||
'metadata' => [
|
||||
'date_export' => date('Y-m-d H:i:s'),
|
||||
'exporteur' => $_SESSION['login'] ?? 'Enseignant'
|
||||
],
|
||||
'evaluation' => [
|
||||
'id' => (int)$evaluation['id_evaluation'],
|
||||
'titre' => $evaluation['titre'],
|
||||
'description' => $evaluation['description'] ?? '',
|
||||
'type' => $evaluation['type'],
|
||||
'duree_minutes' => (int)$evaluation['duree_minutes'],
|
||||
'note_totale' => (float)$evaluation['note_totale'],
|
||||
'nb_questions' => count($questions),
|
||||
'tentatives_max' => (int)$evaluation['tentatives_max']
|
||||
],
|
||||
'questions' => [],
|
||||
'tentatives' => []
|
||||
];
|
||||
|
||||
foreach ($questions as $q) {
|
||||
$export['questions'][] = [
|
||||
'id' => (int)$q['id_question'],
|
||||
'ordre' => (int)$q['ordre'],
|
||||
'type' => $q['type_question'],
|
||||
'enonce' => $q['enonce'],
|
||||
'options' => json_decode($q['options_json'] ?? '[]', true),
|
||||
'reponse_correcte' => extraireReponseCorrecte($q),
|
||||
'points' => (float)$q['points'],
|
||||
'explication' => $q['explication'] ?? null
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($tentatives as $t) {
|
||||
$reponses = json_decode($t['reponses_json'] ?? '{}', true) ?: [];
|
||||
$details = [];
|
||||
|
||||
foreach ($questions as $q) {
|
||||
$details[] = [
|
||||
'question_id' => (int)$q['id_question'],
|
||||
'ordre' => (int)$q['ordre'],
|
||||
'reponse_eleve' => $reponses[$q['id_question']] ?? null,
|
||||
'reponse_correcte' => extraireReponseCorrecte($q)
|
||||
];
|
||||
}
|
||||
|
||||
$export['tentatives'][] = [
|
||||
'id' => (int)$t['id_tentative'],
|
||||
'eleve' => [
|
||||
'id' => (int)$t['id_eleve'],
|
||||
'nom' => $t['nom'],
|
||||
'prenom' => $t['prenom'],
|
||||
'login' => $t['login'],
|
||||
'classe' => $t['nom_classe'] ?? 'Libre'
|
||||
],
|
||||
'numero_tentative' => (int)$t['numero_tentative'],
|
||||
'statut' => $t['statut'],
|
||||
'note' => $t['note'] !== null ? (float)$t['note'] : null,
|
||||
'note_sur' => $t['note_sur'] !== null ? (float)$t['note_sur'] : (float)$evaluation['note_totale'],
|
||||
'pourcentage' => $t['pourcentage'] !== null ? (float)$t['pourcentage'] : null,
|
||||
'dates' => [
|
||||
'debut' => $t['date_debut'],
|
||||
'fin' => $t['date_fin']
|
||||
],
|
||||
'temps_passe_minutes' => $t['temps_passe'] ?? (int)$t['duree_minutes_calc'],
|
||||
'reponses_detaillees' => $details
|
||||
];
|
||||
}
|
||||
|
||||
echo json_encode($export, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
411
enseignant/export_passwords.php
Normal file
411
enseignant/export_passwords.php
Normal file
@ -0,0 +1,411 @@
|
||||
<?php
|
||||
/**
|
||||
* Export Mots de Passe - Enseignant
|
||||
* Génération et téléchargement des listes par classe
|
||||
*/
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
require_once APP_ROOT . '/config/config.php';
|
||||
require_once APP_ROOT . '/config/database.php';
|
||||
|
||||
session_start();
|
||||
|
||||
// Vérifier authentification enseignant
|
||||
if (!isLoggedIn() || !isEnseignant()) {
|
||||
redirect('index.php');
|
||||
}
|
||||
|
||||
// $auth = new Auth(); // MIGRÉ vers SessionManager
|
||||
$user = currentUser();
|
||||
$db = Database::getInstance();
|
||||
$exporter = new PasswordExport();
|
||||
|
||||
// Actions
|
||||
$action = $_GET['action'] ?? '';
|
||||
$message = '';
|
||||
$error = '';
|
||||
|
||||
if ($action === 'export_classe' && isset($_GET['id_classe'])) {
|
||||
$result = $exporter->exportClassePasswords((int)$_GET['id_classe']);
|
||||
if ($result['success']) {
|
||||
$message = 'Export réussi : ' . $result['filename'];
|
||||
} else {
|
||||
$error = $result['message'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($action === 'export_all') {
|
||||
$results = $exporter->exportAllClasses();
|
||||
$success_count = count(array_filter($results, fn($r) => $r['success']));
|
||||
$message = "Export terminé : $success_count classe(s) exportée(s)";
|
||||
}
|
||||
|
||||
if ($action === 'download' && isset($_GET['file'])) {
|
||||
$exporter->downloadFile($_GET['file']);
|
||||
}
|
||||
|
||||
if ($action === 'delete' && isset($_GET['file'])) {
|
||||
if ($exporter->deleteFile($_GET['file'])) {
|
||||
$message = 'Fichier supprimé';
|
||||
} else {
|
||||
$error = 'Erreur suppression';
|
||||
}
|
||||
}
|
||||
|
||||
// Récupérer classes
|
||||
$classes = $db->fetchAll("
|
||||
SELECT
|
||||
c.id_classe,
|
||||
c.nom_classe,
|
||||
c.niveau,
|
||||
c.type_classe,
|
||||
COUNT(u.id_utilisateur) as nb_eleves
|
||||
FROM classes c
|
||||
LEFT JOIN utilisateurs u ON c.id_classe = u.id_classe AND u.actif = TRUE
|
||||
WHERE c.actif = TRUE
|
||||
GROUP BY c.id_classe
|
||||
ORDER BY c.nom_classe
|
||||
");
|
||||
|
||||
// Fichiers exportés
|
||||
$files = $exporter->listExportedFiles();
|
||||
|
||||
// Déconnexion
|
||||
if (isset($_GET['logout'])) {
|
||||
$auth->logout();
|
||||
redirect('index.php');
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Export Mots de Passe - Enseignant</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
:root {
|
||||
--primary: #667eea;
|
||||
--secondary: #764ba2;
|
||||
--success: #10b981;
|
||||
--danger: #ef4444;
|
||||
--warning: #f59e0b;
|
||||
--gray-100: #f3f4f6;
|
||||
--gray-200: #e5e7eb;
|
||||
--gray-800: #1f2937;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: var(--gray-100);
|
||||
color: var(--gray-800);
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, var(--primary), var(--secondary));
|
||||
color: white;
|
||||
padding: 20px 0;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.header .container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 0 30px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 1.8em;
|
||||
}
|
||||
|
||||
.header .nav {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.header a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
background: rgba(255,255,255,0.2);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.header a:hover {
|
||||
background: rgba(255,255,255,0.3);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
max-width: 1400px;
|
||||
margin: 40px auto;
|
||||
padding: 0 30px;
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: 15px 20px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.alert-success {
|
||||
background: #d1fae5;
|
||||
color: #065f46;
|
||||
border-left: 4px solid var(--success);
|
||||
}
|
||||
|
||||
.alert-error {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
border-left: 4px solid var(--danger);
|
||||
}
|
||||
|
||||
.alert-warning {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
border-left: 4px solid var(--warning);
|
||||
}
|
||||
|
||||
.section {
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.section h2 {
|
||||
margin-bottom: 20px;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: var(--success);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: var(--danger);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-warning {
|
||||
background: var(--warning);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
th {
|
||||
background: var(--gray-100);
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
border-bottom: 2px solid var(--gray-200);
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 15px;
|
||||
border-bottom: 1px solid var(--gray-200);
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background: var(--gray-100);
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 5px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 0.85em;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge-regular { background: #dbeafe; color: #1e40af; }
|
||||
.badge-soutien { background: #fef3c7; color: #92400e; }
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="container">
|
||||
<h1>🔐 Export Mots de Passe</h1>
|
||||
<div class="nav">
|
||||
<a href="dashboard.php">← Retour Dashboard</a>
|
||||
<a href="?logout=1">Déconnexion</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="main-content">
|
||||
<?php if ($message): ?>
|
||||
<div class="alert alert-success"><?= h($message) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-error"><?= h($error) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="alert alert-warning">
|
||||
⚠️ <strong>Sécurité :</strong> Les fichiers contiennent les mots de passe en clair.
|
||||
Ils sont stockés hors du dossier web dans <code>/var/backups/mathematiques/classes_passwords/</code>
|
||||
avec permissions 600 (lecture seule propriétaire).
|
||||
</div>
|
||||
|
||||
<!-- Export par classe -->
|
||||
<section class="section">
|
||||
<h2>📚 Export par Classe</h2>
|
||||
|
||||
<p style="margin-bottom: 20px;">
|
||||
Générez un fichier JSON contenant tous les logins et mots de passe pour chaque classe.
|
||||
</p>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<a href="?action=export_all" class="btn btn-success"
|
||||
onclick="return confirm('Exporter toutes les classes ?')">
|
||||
📤 Exporter Toutes les Classes
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Classe</th>
|
||||
<th>Niveau</th>
|
||||
<th>Type</th>
|
||||
<th>Nb Élèves</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($classes as $classe): ?>
|
||||
<tr>
|
||||
<td><strong><?= h($classe['nom_classe']) ?></strong></td>
|
||||
<td><?= h($classe['niveau']) ?></td>
|
||||
<td>
|
||||
<span class="badge badge-<?= $classe['type_classe'] ?>">
|
||||
<?= $classe['type_classe'] === 'reguliere' ? 'Régulière' : 'Soutien' ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><?= $classe['nb_eleves'] ?></td>
|
||||
<td class="actions">
|
||||
<a href="?action=export_classe&id_classe=<?= $classe['id_classe'] ?>"
|
||||
class="btn btn-primary">
|
||||
Exporter
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- Fichiers exportés -->
|
||||
<section class="section">
|
||||
<h2>📁 Fichiers Exportés</h2>
|
||||
|
||||
<?php if (empty($files)): ?>
|
||||
<p style="color: #6b7280;">Aucun fichier exporté pour le moment.</p>
|
||||
<?php else: ?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fichier</th>
|
||||
<th>Taille</th>
|
||||
<th>Date Modification</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($files as $file): ?>
|
||||
<tr>
|
||||
<td><code><?= h($file['filename']) ?></code></td>
|
||||
<td><?= number_format($file['size'] / 1024, 2) ?> KB</td>
|
||||
<td><?= date('d/m/Y H:i', $file['date_modification']) ?></td>
|
||||
<td class="actions">
|
||||
<a href="?action=download&file=<?= urlencode($file['filename']) ?>"
|
||||
class="btn btn-success">
|
||||
⬇️ Télécharger
|
||||
</a>
|
||||
<a href="?action=delete&file=<?= urlencode($file['filename']) ?>"
|
||||
class="btn btn-danger"
|
||||
onclick="return confirm('Supprimer ce fichier ?')">
|
||||
🗑️ Supprimer
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
<!-- Informations -->
|
||||
<section class="section">
|
||||
<h2>ℹ️ Informations</h2>
|
||||
|
||||
<h3 style="margin-top: 20px;">Format du fichier JSON :</h3>
|
||||
<pre style="background: var(--gray-100); padding: 15px; border-radius: 8px; overflow-x: auto;">
|
||||
{
|
||||
"classe": "2nde_A",
|
||||
"niveau": "2nde",
|
||||
"annee_scolaire": "2024-2025",
|
||||
"type": "reguliere",
|
||||
"date_export": "2025-10-23 10:30:00",
|
||||
"nombre_eleves": 25,
|
||||
"eleves": [
|
||||
{
|
||||
"login": "j.dupont",
|
||||
"nom": "DUPONT",
|
||||
"prenom": "Jean",
|
||||
"date_naissance": "15/03/2009",
|
||||
"mot_de_passe": "1503"
|
||||
}
|
||||
]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3 style="margin-top: 20px;">Règles de génération :</h3>
|
||||
<ul style="margin-left: 20px; line-height: 1.8;">
|
||||
<li><strong>Login :</strong> p.nom (première lettre prénom + point + nom, minuscules)</li>
|
||||
<li><strong>Doublons :</strong> ajout chiffre (j.dupont2, j.dupont3...)</li>
|
||||
<li><strong>Mot de passe élève :</strong> JJMM (jour+mois naissance en 4 chiffres)</li>
|
||||
<li><strong>Mot de passe enseignant :</strong> Personnalisé (n.boyer → math2025!)</li>
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
0
enseignant/exports/.gitkeep
Normal file
0
enseignant/exports/.gitkeep
Normal file
103
enseignant/get_eleves_classe.php
Normal file
103
enseignant/get_eleves_classe.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
// === PROTECTION JSON - NE PAS SUPPRIMER ===
|
||||
error_reporting(0);
|
||||
ini_set('display_errors', 0);
|
||||
ob_start();
|
||||
// === FIN PROTECTION ===
|
||||
|
||||
|
||||
/**
|
||||
* API élèves - VERSION ULTRA ROBUSTE
|
||||
* Capture TOUTES les erreurs avant d'envoyer le JSON
|
||||
*/
|
||||
|
||||
// Démarrer le buffer AVANT tout
|
||||
ob_start();
|
||||
|
||||
// Désactiver l'affichage des erreurs
|
||||
ini_set('display_errors', 0);
|
||||
error_reporting(0);
|
||||
|
||||
// Fonction pour nettoyer et envoyer JSON
|
||||
function sendJSON($data) {
|
||||
// Vider et ignorer tout ce qui a été bufferisé (erreurs, warnings, etc.)
|
||||
ob_end_clean();
|
||||
|
||||
// Envoyer les headers
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
|
||||
// Envoyer le JSON
|
||||
echo json_encode($data);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// Includes
|
||||
require_once '../config/config.php';
|
||||
require_once '../config/database.php';
|
||||
require_once '../config/session.php';
|
||||
|
||||
// Vérifier authentification
|
||||
if (!SessionManager::isLoggedIn()) {
|
||||
sendJSON([
|
||||
'success' => false,
|
||||
'message' => 'Non connecté'
|
||||
]);
|
||||
}
|
||||
|
||||
$user = SessionManager::getUser();
|
||||
if ($user['id_type'] != 1) {
|
||||
sendJSON([
|
||||
'success' => false,
|
||||
'message' => 'Accès réservé aux enseignants'
|
||||
]);
|
||||
}
|
||||
|
||||
// Connexion BDD
|
||||
$db = Database::getInstance()->getConnection();
|
||||
|
||||
// Paramètre
|
||||
if (!isset($_GET['id_classe'])) {
|
||||
sendJSON([
|
||||
'success' => false,
|
||||
'message' => 'Paramètre id_classe manquant'
|
||||
]);
|
||||
}
|
||||
|
||||
$id_classe = (int)$_GET['id_classe'];
|
||||
|
||||
// Requête
|
||||
$stmt = $db->prepare("
|
||||
SELECT
|
||||
id_utilisateur,
|
||||
login,
|
||||
nom,
|
||||
prenom,
|
||||
actif,
|
||||
date_inscription
|
||||
FROM utilisateurs
|
||||
WHERE id_classe = ? AND id_type IN (2, 3)
|
||||
ORDER BY nom, prenom
|
||||
");
|
||||
$stmt->execute([$id_classe]);
|
||||
$eleves = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Succès
|
||||
sendJSON([
|
||||
'success' => true,
|
||||
'eleves' => $eleves,
|
||||
'total' => count($eleves),
|
||||
'mot_de_passe_defaut' => 'eleve2025',
|
||||
'info' => 'Mot de passe par défaut lors de l\'import'
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
sendJSON([
|
||||
'success' => false,
|
||||
'message' => 'Erreur: ' . $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine()
|
||||
]);
|
||||
}
|
||||
?>
|
||||
523
enseignant/monitoring.php
Normal file
523
enseignant/monitoring.php
Normal file
@ -0,0 +1,523 @@
|
||||
<?php
|
||||
/**
|
||||
* MATRICE MONITORING TEMPS RÉEL - ENSEIGNANT
|
||||
* Supervision élèves pendant passage évaluation
|
||||
*/
|
||||
|
||||
require_once '../config/config.php';
|
||||
require_once '../config/database.php';
|
||||
require_once '../config/session.php';
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
SessionManager::startSession();
|
||||
}
|
||||
|
||||
// Vérification enseignant
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['type_libelle'] !== 'enseignant') {
|
||||
header('Location: ../auth/login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$id_evaluation = $_GET['id_evaluation'] ?? null;
|
||||
|
||||
if (!$id_evaluation) {
|
||||
die('❌ ID évaluation manquant');
|
||||
}
|
||||
|
||||
try {
|
||||
$db = Database::getInstance()->getConnection();
|
||||
|
||||
// Récupérer évaluation
|
||||
$stmt = $db->prepare("SELECT * FROM evaluations WHERE id_evaluation = ?");
|
||||
$stmt->execute([$id_evaluation]);
|
||||
$evaluation = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$evaluation) {
|
||||
die('❌ Évaluation non trouvée');
|
||||
}
|
||||
|
||||
// Récupérer questions
|
||||
$stmt = $db->prepare("SELECT id_question, ordre, enonce FROM questions WHERE id_evaluation = ? ORDER BY ordre ASC");
|
||||
$stmt->execute([$id_evaluation]);
|
||||
$questions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$nb_questions = count($questions);
|
||||
|
||||
} catch (Exception $e) {
|
||||
die('Erreur: ' . $e->getMessage());
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Monitoring - <?= htmlspecialchars($evaluation['titre']) ?></title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: white;
|
||||
padding: 20px 30px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
color: #333;
|
||||
font-size: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.refresh-indicator {
|
||||
padding: 8px 16px;
|
||||
background: #f0f0f0;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.refresh-indicator.active {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.stats-bar {
|
||||
background: white;
|
||||
padding: 15px 30px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
margin-bottom: 20px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.monitoring-table {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
thead {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
thead th {
|
||||
padding: 15px 10px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
thead th.question-col {
|
||||
text-align: center;
|
||||
min-width: 40px;
|
||||
}
|
||||
|
||||
tbody tr {
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
tbody tr:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
tbody td {
|
||||
padding: 12px 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.status-indicator {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.status-en-ligne { background: #28a745; }
|
||||
.status-en-cours { background: #ffc107; }
|
||||
.status-inactif { background: #fd7e14; }
|
||||
.status-hors-ligne { background: #dc3545; }
|
||||
.status-termine { background: #6c757d; }
|
||||
|
||||
.question-cell {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.question-cell:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
.progress-bar-container {
|
||||
background: #e9ecef;
|
||||
border-radius: 10px;
|
||||
height: 20px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
|
||||
transition: width 0.3s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.progress-text {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.eleve-name {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.eleve-classe {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.time-info {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.legende {
|
||||
background: white;
|
||||
padding: 15px 30px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
gap: 30px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.legende-title {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.legende-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn-retour {
|
||||
background: #6c757d;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.btn-retour:hover {
|
||||
background: #5a6268;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.spinner {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
.no-data {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #666;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<h1>
|
||||
📊 Monitoring Temps Réel
|
||||
<span style="font-size: 18px; font-weight: normal; color: #666;">
|
||||
- <?= htmlspecialchars($evaluation['titre']) ?>
|
||||
</span>
|
||||
</h1>
|
||||
<div style="display: flex; gap: 15px; align-items: center;">
|
||||
<div class="refresh-indicator" id="refreshIndicator">
|
||||
<span id="refreshIcon">🔄</span>
|
||||
<span id="refreshText">Chargement...</span>
|
||||
</div>
|
||||
<a href="dashboard.php" class="btn-retour">← Retour</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Statistiques -->
|
||||
<div class="stats-bar" id="statsBar">
|
||||
<div class="stat-item">
|
||||
<div class="stat-value" id="statTotal">-</div>
|
||||
<div class="stat-label">Total élèves</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-value" style="color: #28a745;" id="statActifs">-</div>
|
||||
<div class="stat-label">🟢 En ligne</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-value" style="color: #ffc107;" id="statEnCours">-</div>
|
||||
<div class="stat-label">🟡 En cours</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-value" style="color: #dc3545;" id="statInactifs">-</div>
|
||||
<div class="stat-label">🔴 Inactifs</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-value" style="color: #6c757d;" id="statTermines">-</div>
|
||||
<div class="stat-label">⚫ Terminés</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tableau monitoring -->
|
||||
<div class="monitoring-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40px;">Statut</th>
|
||||
<th style="width: 200px;">Élève</th>
|
||||
<th style="width: 200px;">Progression</th>
|
||||
<th style="width: 120px;">Temps écoulé</th>
|
||||
<th style="width: 120px;">Dernière activité</th>
|
||||
<?php foreach ($questions as $q): ?>
|
||||
<th class="question-col" title="<?= htmlspecialchars($q['enonce']) ?>">
|
||||
Q<?= $q['ordre'] ?>
|
||||
</th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="monitoringBody">
|
||||
<tr>
|
||||
<td colspan="<?= 5 + $nb_questions ?>" class="no-data">
|
||||
🔄 Chargement des données...
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Légende -->
|
||||
<div class="legende">
|
||||
<div class="legende-title">Légende :</div>
|
||||
<div class="legende-item">
|
||||
<span class="status-indicator status-en-ligne"></span>
|
||||
<span>En ligne (<1 min)</span>
|
||||
</div>
|
||||
<div class="legende-item">
|
||||
<span class="status-indicator status-en-cours"></span>
|
||||
<span>En cours (<3 min)</span>
|
||||
</div>
|
||||
<div class="legende-item">
|
||||
<span class="status-indicator status-inactif"></span>
|
||||
<span>Inactif (3-5 min)</span>
|
||||
</div>
|
||||
<div class="legende-item">
|
||||
<span class="status-indicator status-hors-ligne"></span>
|
||||
<span>Hors ligne (>5 min)</span>
|
||||
</div>
|
||||
<div class="legende-item">
|
||||
<span class="status-indicator status-termine"></span>
|
||||
<span>Terminé</span>
|
||||
</div>
|
||||
<div class="legende-item" style="margin-left: 30px;">
|
||||
<span>⬜ Vide</span>
|
||||
<span style="margin-left: 15px;">✅ Répondu</span>
|
||||
<span style="margin-left: 15px;">✔️ Correct</span>
|
||||
<span style="margin-left: 15px;">❌ Incorrect</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const ID_EVALUATION = <?= $id_evaluation ?>;
|
||||
const NB_QUESTIONS = <?= $nb_questions ?>;
|
||||
let refreshInterval;
|
||||
|
||||
// Charger données initiales
|
||||
loadMonitoringData();
|
||||
|
||||
// Auto-refresh toutes les 10 secondes
|
||||
refreshInterval = setInterval(loadMonitoringData, 10000);
|
||||
|
||||
function loadMonitoringData() {
|
||||
const refreshIcon = document.getElementById('refreshIcon');
|
||||
const refreshText = document.getElementById('refreshText');
|
||||
const refreshIndicator = document.getElementById('refreshIndicator');
|
||||
|
||||
// Animation chargement
|
||||
refreshIcon.classList.add('spinner');
|
||||
refreshText.textContent = 'Actualisation...';
|
||||
refreshIndicator.classList.add('active');
|
||||
|
||||
fetch(`monitoring_ajax.php?id_evaluation=${ID_EVALUATION}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
updateStats(data.stats);
|
||||
updateTable(data.tentatives);
|
||||
|
||||
// Animation succès
|
||||
refreshIcon.textContent = '✅';
|
||||
refreshText.textContent = 'Mis à jour ' + new Date().toLocaleTimeString('fr-FR');
|
||||
|
||||
setTimeout(() => {
|
||||
refreshIcon.textContent = '🔄';
|
||||
refreshIndicator.classList.remove('active');
|
||||
}, 2000);
|
||||
} else {
|
||||
throw new Error(data.error || 'Erreur inconnue');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Erreur:', error);
|
||||
refreshIcon.textContent = '❌';
|
||||
refreshText.textContent = 'Erreur de chargement';
|
||||
refreshIndicator.style.background = '#f8d7da';
|
||||
refreshIndicator.style.color = '#721c24';
|
||||
})
|
||||
.finally(() => {
|
||||
refreshIcon.classList.remove('spinner');
|
||||
});
|
||||
}
|
||||
|
||||
function updateStats(stats) {
|
||||
document.getElementById('statTotal').textContent = stats.total;
|
||||
document.getElementById('statActifs').textContent = stats.en_ligne;
|
||||
document.getElementById('statEnCours').textContent = stats.en_cours;
|
||||
document.getElementById('statInactifs').textContent = stats.inactif + stats.hors_ligne;
|
||||
document.getElementById('statTermines').textContent = stats.termine;
|
||||
}
|
||||
|
||||
function updateTable(tentatives) {
|
||||
const tbody = document.getElementById('monitoringBody');
|
||||
|
||||
if (tentatives.length === 0) {
|
||||
tbody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="${5 + NB_QUESTIONS}" class="no-data">
|
||||
📭 Aucun élève n'a encore commencé cette évaluation
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
tbody.innerHTML = tentatives.map(t => `
|
||||
<tr>
|
||||
<td>
|
||||
<span class="status-indicator status-${t.statut_connexion}"></span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="eleve-name">${escapeHtml(t.nom)} ${escapeHtml(t.prenom)}</div>
|
||||
<span class="eleve-classe">${escapeHtml(t.classe || 'Libre')}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="progress-bar-container">
|
||||
<div class="progress-bar" style="width: ${t.pourcentage_progression}%">
|
||||
${t.pourcentage_progression}%
|
||||
</div>
|
||||
</div>
|
||||
<div class="progress-text">${t.nb_reponses}/${NB_QUESTIONS} questions</div>
|
||||
</td>
|
||||
<td class="time-info">
|
||||
⏱️ ${t.temps_ecoule}
|
||||
</td>
|
||||
<td class="time-info">
|
||||
${t.derniere_activite}
|
||||
</td>
|
||||
${t.reponses_details.map(r => `
|
||||
<td class="question-cell" title="${r.tooltip}">
|
||||
${r.icone}
|
||||
</td>
|
||||
`).join('')}
|
||||
</tr>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
// Nettoyer interval au déchargement
|
||||
window.addEventListener('beforeunload', () => {
|
||||
if (refreshInterval) {
|
||||
clearInterval(refreshInterval);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
279
enseignant/monitoring_ajax.php
Normal file
279
enseignant/monitoring_ajax.php
Normal file
@ -0,0 +1,279 @@
|
||||
<?php
|
||||
/**
|
||||
* API MONITORING TEMPS RÉEL - VERSION FINALE CORRIGÉE V3
|
||||
* Fix: Alignement logique vérification avec soumettre_evaluation.php
|
||||
*
|
||||
* Changements:
|
||||
* 1. Ligne 39: Ajout type_question dans SELECT (fix précédent) ✅
|
||||
* 2. Ligne 183-271: Fonction verifierReponseCorrecte() alignée sur correction réelle ✅
|
||||
* 3. Ligne 11-20: Authentification corrigée (session directe) ✅
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
require_once __DIR__ . '/../config/session.php';
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
SessionManager::startSession();
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Vérifier authentification enseignant
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['type_libelle'] !== 'enseignant') {
|
||||
echo json_encode(['success' => false, 'error' => 'Accès refusé']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id_evaluation = isset($_GET['id_evaluation']) ? (int)$_GET['id_evaluation'] : 0;
|
||||
|
||||
if ($id_evaluation <= 0) {
|
||||
echo json_encode(['success' => false, 'error' => 'ID évaluation invalide']);
|
||||
exit;
|
||||
}
|
||||
try {
|
||||
$db = Database::getInstance()->getConnection();
|
||||
|
||||
// Récupérer questions (AVEC type_question - FIX 1)
|
||||
$stmt = $db->prepare("
|
||||
SELECT id_question, ordre, type_question, enonce, reponse_correcte_json, options_json
|
||||
FROM questions
|
||||
WHERE id_evaluation = ?
|
||||
ORDER BY ordre ASC
|
||||
");
|
||||
$stmt->execute([$id_evaluation]);
|
||||
$questions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$nb_questions = count($questions);
|
||||
|
||||
// Récupérer tentatives avec statut connexion
|
||||
$stmt = $db->prepare("
|
||||
SELECT
|
||||
te.id_tentative,
|
||||
te.id_eleve,
|
||||
te.statut,
|
||||
te.reponses_json,
|
||||
te.date_debut,
|
||||
te.date_fin,
|
||||
te.derniere_sauvegarde,
|
||||
te.note,
|
||||
u.nom,
|
||||
u.prenom,
|
||||
u.login,
|
||||
c.nom_classe,
|
||||
TIMESTAMPDIFF(SECOND, te.date_debut, NOW()) as secondes_ecoulees,
|
||||
TIMESTAMPDIFF(SECOND,
|
||||
COALESCE(te.derniere_sauvegarde, te.date_debut),
|
||||
NOW()
|
||||
) as secondes_inactif,
|
||||
CASE
|
||||
WHEN te.statut = 'terminee' THEN 'termine'
|
||||
WHEN TIMESTAMPDIFF(SECOND, COALESCE(te.derniere_sauvegarde, te.date_debut), NOW()) > 300 THEN 'hors_ligne'
|
||||
WHEN TIMESTAMPDIFF(SECOND, COALESCE(te.derniere_sauvegarde, te.date_debut), NOW()) > 180 THEN 'inactif'
|
||||
WHEN TIMESTAMPDIFF(SECOND, COALESCE(te.derniere_sauvegarde, te.date_debut), NOW()) > 60 THEN 'en_cours'
|
||||
ELSE 'en_ligne'
|
||||
END as statut_connexion
|
||||
FROM tentatives_eleves te
|
||||
JOIN utilisateurs u ON te.id_eleve = u.id_utilisateur
|
||||
LEFT JOIN classes c ON u.id_classe = c.id_classe
|
||||
WHERE te.id_evaluation = ?
|
||||
ORDER BY
|
||||
FIELD(statut_connexion, 'en_ligne', 'en_cours', 'inactif', 'hors_ligne', 'termine'),
|
||||
te.derniere_sauvegarde DESC,
|
||||
u.nom, u.prenom
|
||||
");
|
||||
$stmt->execute([$id_evaluation]);
|
||||
$tentatives = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Calculer statistiques
|
||||
$stats = [
|
||||
'total' => count($tentatives),
|
||||
'en_ligne' => 0,
|
||||
'en_cours' => 0,
|
||||
'inactif' => 0,
|
||||
'hors_ligne' => 0,
|
||||
'termine' => 0
|
||||
];
|
||||
|
||||
foreach ($tentatives as $t) {
|
||||
$stats[$t['statut_connexion']]++;
|
||||
}
|
||||
|
||||
// Formater données pour frontend
|
||||
$tentatives_formatted = array_map(function($t) use ($questions, $nb_questions) {
|
||||
$reponses = json_decode($t['reponses_json'] ?? '{}', true) ?: [];
|
||||
$nb_reponses = count(array_filter($reponses, function($r) {
|
||||
return $r !== null && $r !== '';
|
||||
}));
|
||||
|
||||
$pourcentage = $nb_questions > 0 ? round(($nb_reponses / $nb_questions) * 100) : 0;
|
||||
|
||||
// Calculer temps écoulé
|
||||
$heures = floor($t['secondes_ecoulees'] / 3600);
|
||||
$minutes = floor(($t['secondes_ecoulees'] % 3600) / 60);
|
||||
$temps_ecoule = sprintf("%d:%02d", $heures, $minutes);
|
||||
|
||||
// Dernière activité
|
||||
$derniere_activite = '';
|
||||
if ($t['statut_connexion'] === 'termine') {
|
||||
$derniere_activite = '✅ Terminé';
|
||||
} else if ($t['secondes_inactif'] < 60) {
|
||||
$derniere_activite = 'À l\'instant';
|
||||
} else if ($t['secondes_inactif'] < 3600) {
|
||||
$min_inactif = floor($t['secondes_inactif'] / 60);
|
||||
$derniere_activite = "Il y a {$min_inactif} min";
|
||||
} else {
|
||||
$h_inactif = floor($t['secondes_inactif'] / 3600);
|
||||
$derniere_activite = "Il y a {$h_inactif}h";
|
||||
}
|
||||
|
||||
// Détails réponses pour chaque question
|
||||
$reponses_details = [];
|
||||
foreach ($questions as $q) {
|
||||
$reponse_eleve = $reponses[$q['id_question']] ?? null;
|
||||
|
||||
if ($reponse_eleve === null || $reponse_eleve === '') {
|
||||
$reponses_details[] = [
|
||||
'icone' => '⬜',
|
||||
'tooltip' => 'Pas encore répondu'
|
||||
];
|
||||
} else {
|
||||
// Vérifier si réponse correcte (FIX 2 - utiliser nouvelle fonction alignée)
|
||||
$est_correcte = verifierReponseCorrecte($q, $reponse_eleve);
|
||||
$reponses_details[] = [
|
||||
'icone' => $est_correcte ? '✅' : '❌',
|
||||
'tooltip' => $est_correcte ? 'Réponse correcte' : 'Réponse incorrecte'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id_tentative' => $t['id_tentative'],
|
||||
'nom' => $t['nom'],
|
||||
'prenom' => $t['prenom'],
|
||||
'classe' => $t['nom_classe'] ?? 'Sans classe',
|
||||
'statut_connexion' => $t['statut_connexion'],
|
||||
'nb_reponses' => $nb_reponses,
|
||||
'pourcentage_progression' => $pourcentage,
|
||||
'temps_ecoule' => $temps_ecoule,
|
||||
'derniere_activite' => $derniere_activite,
|
||||
'reponses_details' => $reponses_details
|
||||
];
|
||||
}, $tentatives);
|
||||
|
||||
// Réponse JSON
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'stats' => $stats,
|
||||
'tentatives' => $tentatives_formatted,
|
||||
'timestamp' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIX 2: Fonction vérification ALIGNÉE sur soumettre_evaluation.php (ligne 100-188)
|
||||
*
|
||||
* Changements principaux:
|
||||
* - SELECT: Utilise reponse_correcte_json['id'] au lieu de options['est_correcte']
|
||||
* - Accepte ID ou texte comme correction réelle
|
||||
* - QCM: Utilise 'reponses' au lieu de 'options'
|
||||
* - CHECKBOX: Compare textes au lieu de IDs
|
||||
*/
|
||||
function verifierReponseCorrecte($question, $reponse_eleve) {
|
||||
if (empty($reponse_eleve) && $reponse_eleve !== '0' && $reponse_eleve !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = $question['type_question'];
|
||||
$options = json_decode($question['options_json'] ?? '{}', true);
|
||||
$reponse_correcte_data = json_decode($question['reponse_correcte_json'] ?? '{}', true);
|
||||
|
||||
// Type NUMBER
|
||||
if ($type === 'number') {
|
||||
$reponse_correcte = $reponse_correcte_data['reponse'] ?? null;
|
||||
if ($reponse_correcte === null) {
|
||||
return false;
|
||||
}
|
||||
return abs((float)$reponse_eleve - (float)$reponse_correcte) < 0.01;
|
||||
}
|
||||
|
||||
// Type TEXT
|
||||
if ($type === 'text') {
|
||||
$reponse_correcte = $reponse_correcte_data['reponse'] ?? null;
|
||||
if ($reponse_correcte === null) {
|
||||
return false;
|
||||
}
|
||||
return strtolower(trim($reponse_eleve)) === strtolower(trim($reponse_correcte));
|
||||
}
|
||||
|
||||
// Type SELECT (FIX MAJEUR)
|
||||
if ($type === 'select') {
|
||||
// Réponse correcte dans reponse_correcte_json: {"id": "opt2"}
|
||||
$id_reponse_correcte = $reponse_correcte_data['id'] ?? null;
|
||||
|
||||
if (!$id_reponse_correcte || !isset($options['options'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trouver le texte correspondant à l'ID correct
|
||||
$texte_correct = null;
|
||||
foreach ($options['options'] as $opt) {
|
||||
if (($opt['id'] ?? '') === $id_reponse_correcte) {
|
||||
$texte_correct = $opt['texte'] ?? null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Vérifier si réponse élève correspond (ID OU texte - comme correction réelle)
|
||||
return ($reponse_eleve === $id_reponse_correcte || $reponse_eleve === $texte_correct);
|
||||
}
|
||||
|
||||
// Type QCM (utilise 'reponses' pas 'options')
|
||||
if ($type === 'qcm') {
|
||||
if (!isset($options['reponses'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trouver la réponse correcte dans le tableau reponses
|
||||
$reponse_correcte = null;
|
||||
foreach ($options['reponses'] as $rep) {
|
||||
if (isset($rep['est_correcte']) && $rep['est_correcte'] === true) {
|
||||
$reponse_correcte = $rep['texte'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $reponse_eleve === $reponse_correcte;
|
||||
}
|
||||
|
||||
// Type CHECKBOX (compare textes comme correction réelle)
|
||||
if ($type === 'checkbox') {
|
||||
if (!isset($options['reponses'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trouver toutes les réponses correctes (TEXTES)
|
||||
$reponses_correctes = [];
|
||||
foreach ($options['reponses'] as $rep) {
|
||||
if (isset($rep['est_correcte']) && $rep['est_correcte'] === true) {
|
||||
$reponses_correctes[] = $rep['texte'];
|
||||
}
|
||||
}
|
||||
|
||||
// Normaliser réponses élève
|
||||
$reponses_eleve_array = is_array($reponse_eleve) ? $reponse_eleve : [$reponse_eleve];
|
||||
|
||||
// Comparer tableaux triés
|
||||
sort($reponses_correctes);
|
||||
sort($reponses_eleve_array);
|
||||
|
||||
return $reponses_correctes === $reponses_eleve_array;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
?>
|
||||
42
enseignant/resultats_ajax.php
Normal file
42
enseignant/resultats_ajax.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0);
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
require_once __DIR__ . '/../config/session.php';
|
||||
if (session_status() === PHP_SESSION_NONE) SessionManager::startSession();
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['type_libelle'] !== 'enseignant') die(json_encode(['success' => false, 'error' => 'Accès refusé']));
|
||||
$id = isset($_GET['id_evaluation']) ? (int)$_GET['id_evaluation'] : 0;
|
||||
if ($id <= 0) die(json_encode(['success' => false, 'error' => 'ID invalide']));
|
||||
try {
|
||||
$db = Database::getInstance()->getConnection();
|
||||
$stmt = $db->prepare("SELECT titre, duree_minutes, note_totale FROM evaluations WHERE id_evaluation = ?");
|
||||
$stmt->execute([$id]);
|
||||
$eval = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (!$eval) die(json_encode(['success' => false, 'error' => 'Évaluation introuvable']));
|
||||
$stmt = $db->prepare("SELECT id_question, ordre FROM questions WHERE id_evaluation = ? ORDER BY ordre");
|
||||
$stmt->execute([$id]);
|
||||
$questions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt = $db->prepare("SELECT te.note, te.note_sur, te.pourcentage, te.temps_passe, te.statut, te.date_fin, u.nom, u.prenom, c.nom_classe FROM (SELECT id_eleve, MAX(id_tentative) as max_id FROM tentatives_eleves WHERE id_evaluation = ? GROUP BY id_eleve) d JOIN tentatives_eleves te ON te.id_tentative = d.max_id JOIN utilisateurs u ON te.id_eleve = u.id_utilisateur LEFT JOIN classes c ON u.id_classe = c.id_classe ORDER BY te.note DESC");
|
||||
$stmt->execute([$id]);
|
||||
$tents = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$notes = []; $temps_total = 0; $nb_ok = 0; $nb_cours = 0;
|
||||
foreach ($tents as $t) {
|
||||
if ($t['statut'] === 'terminee') { $notes[] = (float)$t['note']; $temps_total += (int)$t['temps_passe']; $nb_ok++; } else { $nb_cours++; }
|
||||
}
|
||||
$mediane = 0;
|
||||
if (!empty($notes)) { sort($notes); $count = count($notes); $mediane = ($count % 2 === 0) ? ($notes[$count/2 - 1] + $notes[$count/2]) / 2 : $notes[floor($count/2)]; }
|
||||
$ecart_type = 0;
|
||||
if (count($notes) > 1) { $moyenne = array_sum($notes) / count($notes); $variance = 0; foreach ($notes as $note) { $variance += pow($note - $moyenne, 2); } $ecart_type = sqrt($variance / count($notes)); }
|
||||
$temps_moyen = '00:00:00';
|
||||
if ($nb_ok > 0) { $sec_moy = $temps_total / $nb_ok; $h = floor($sec_moy / 3600); $m = floor(($sec_moy % 3600) / 60); $s = $sec_moy % 60; $temps_moyen = sprintf("%02d:%02d:%02d", $h, $m, $s); }
|
||||
$nb_reussis = 0; foreach ($notes as $n) { if ($n >= 10) $nb_reussis++; }
|
||||
$taux_reussite = $nb_ok > 0 ? ($nb_reussis / $nb_ok) * 100 : 0;
|
||||
$stats = ['total_eleves' => count($tents), 'termines' => $nb_ok, 'en_cours' => $nb_cours, 'taux_participation' => count($tents) > 0 ? ($nb_ok / count($tents)) * 100 : 0, 'moyenne' => $nb_ok > 0 ? array_sum($notes) / $nb_ok : 0, 'mediane' => $mediane, 'min' => $nb_ok > 0 ? min($notes) : 0, 'max' => $nb_ok > 0 ? max($notes) : 0, 'ecart_type' => $ecart_type, 'taux_reussite' => $taux_reussite, 'temps_moyen' => $temps_moyen];
|
||||
$list = []; $rang = 1;
|
||||
foreach ($tents as $t) { $sec = (int)$t['temps_passe']; $list[] = ['rang' => $t['statut'] === 'terminee' ? $rang : '-', 'nom' => $t['nom'], 'prenom' => $t['prenom'], 'classe' => $t['nom_classe'] ?? 'Sans classe', 'note' => (float)$t['note'], 'note_sur' => (float)$t['note_sur'], 'pourcentage' => (float)$t['pourcentage'], 'temps' => sprintf("%02d:%02d:%02d", floor($sec/3600), floor(($sec%3600)/60), $sec%60), 'statut' => $t['statut'], 'date_fin' => $t['date_fin'] ? date('d/m/Y H:i', strtotime($t['date_fin'])) : '-']; if ($t['statut'] === 'terminee') $rang++; }
|
||||
$classes = []; foreach ($tents as $t) { if ($t['statut'] !== 'terminee') continue; $c = $t['nom_classe'] ?? 'Sans classe'; if (!isset($classes[$c])) $classes[$c] = ['notes' => [], 'nom' => $c]; $classes[$c]['notes'][] = (float)$t['note']; }
|
||||
$stats_classes = []; foreach ($classes as $c) { if (empty($c['notes'])) continue; $stats_classes[] = ['nom' => $c['nom'], 'nb_eleves' => count($c['notes']), 'moyenne' => array_sum($c['notes']) / count($c['notes'])]; }
|
||||
usort($stats_classes, function($a, $b) { return $b['moyenne'] <=> $a['moyenne']; });
|
||||
echo json_encode(['success' => true, 'evaluation' => ['titre' => $eval['titre'], 'duree_minutes' => (int)$eval['duree_minutes'], 'note_totale' => (float)$eval['note_totale'], 'nb_questions' => count($questions)], 'stats' => $stats, 'stats_classes' => $stats_classes, 'stats_questions' => [], 'tentatives' => $list, 'graphiques' => ['histogramme_classes' => ['labels' => [], 'datasets' => []], 'progression_eleves' => ['labels' => [], 'datasets' => []]]], JSON_UNESCAPED_UNICODE);
|
||||
} catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage(), 'line' => $e->getLine()]); }
|
||||
874
enseignant/resultats_evaluation.php
Normal file
874
enseignant/resultats_evaluation.php
Normal file
@ -0,0 +1,874 @@
|
||||
<?php
|
||||
/**
|
||||
* INTERFACE RÉSULTATS ÉVALUATION
|
||||
* Affichage complet : stats + graphiques + tableau notes
|
||||
*
|
||||
* Graphiques:
|
||||
* - Histogramme distribution notes par classe
|
||||
* - Courbe progression par élève (Top 5 + moyenne)
|
||||
*/
|
||||
|
||||
require_once '../config/database.php';
|
||||
require_once '../config/session.php';
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
SessionManager::startSession();
|
||||
}
|
||||
|
||||
// Vérifier authentification enseignant
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['type_libelle'] !== 'enseignant') {
|
||||
header('Location: ../login.php?error=access_denied');
|
||||
exit;
|
||||
}
|
||||
|
||||
$id_evaluation = isset($_GET['id_evaluation']) ? (int)$_GET['id_evaluation'] : 0;
|
||||
|
||||
if ($id_evaluation <= 0) {
|
||||
die('ID évaluation invalide');
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Résultats Évaluation</title>
|
||||
|
||||
<!-- Chart.js -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
||||
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
background: #f8fafc;
|
||||
color: #1e293b;
|
||||
padding: 20px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* === HEADER === */
|
||||
.header {
|
||||
background: white;
|
||||
padding: 20px 30px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 24px;
|
||||
color: #1e293b;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #3b82f6;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #2563eb;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #e2e8f0;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #cbd5e1;
|
||||
}
|
||||
|
||||
/* === LOADING === */
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
display: inline-block;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 4px solid #e2e8f0;
|
||||
border-top-color: #3b82f6;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* === STATISTIQUES === */
|
||||
.stats-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 14px;
|
||||
color: #64748b;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.stat-card.success .stat-value {
|
||||
color: #22c55e;
|
||||
}
|
||||
|
||||
.stat-card.warning .stat-value {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.stat-card.danger .stat-value {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
/* === GRAPHIQUES === */
|
||||
.charts-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.chart-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.chart-canvas {
|
||||
max-height: 400px;
|
||||
}
|
||||
|
||||
/* === TABLEAU === */
|
||||
.table-section {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.table-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.table-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.table-filters {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.filter-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.filter-label {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
select, input[type="text"] {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: #1e293b;
|
||||
background: white;
|
||||
}
|
||||
|
||||
select:focus, input[type="text"]:focus {
|
||||
outline: none;
|
||||
border-color: #3b82f6;
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
th {
|
||||
background: #f8fafc;
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
border-bottom: 2px solid #e2e8f0;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
th:hover {
|
||||
background: #f1f5f9;
|
||||
}
|
||||
|
||||
th.sortable::after {
|
||||
content: ' ↕';
|
||||
color: #cbd5e1;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
th.sort-asc::after {
|
||||
content: ' ↑';
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
th.sort-desc::after {
|
||||
content: ' ↓';
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.rang {
|
||||
font-weight: 700;
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
.note {
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.note.excellent {
|
||||
color: #22c55e;
|
||||
}
|
||||
|
||||
.note.good {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
.note.average {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.note.bad {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 4px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge.termine {
|
||||
background: #dcfce7;
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
.badge.en-cours {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
.table-footer {
|
||||
margin-top: 15px;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
text-align: center;
|
||||
color: #64748b;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* === RESPONSIVE === */
|
||||
@media (max-width: 768px) {
|
||||
.header {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.table-filters {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
table {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
/* === EMPTY STATE === */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.empty-state-icon {
|
||||
font-size: 64px;
|
||||
margin-bottom: 15px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.empty-state-text {
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<h1>
|
||||
<span>📊</span>
|
||||
<span id="eval-title">Résultats Évaluation</span>
|
||||
</h1>
|
||||
<div class="header-actions">
|
||||
<a href="dashboard.php" class="btn btn-secondary">
|
||||
← Retour Dashboard
|
||||
</a>
|
||||
<a href="export.php?id_evaluation=<?= $id_evaluation ?>&format=csv" class="btn btn-primary" id="btn-export">
|
||||
📥 Export CSV
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Loading -->
|
||||
<div id="loading" class="loading">
|
||||
<div class="loading-spinner"></div>
|
||||
<p style="margin-top: 15px;">Chargement des résultats...</p>
|
||||
</div>
|
||||
|
||||
<!-- Content (hidden initially) -->
|
||||
<div id="content" style="display: none;">
|
||||
<!-- Statistiques -->
|
||||
<div class="stats-section">
|
||||
<div class="stats-grid" id="stats-grid">
|
||||
<!-- Remplies dynamiquement -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Graphiques -->
|
||||
<div class="charts-section">
|
||||
<!-- Histogramme par classe -->
|
||||
<div class="chart-container">
|
||||
<div class="chart-title">
|
||||
<span>📊</span>
|
||||
<span>Distribution des Notes par Classe</span>
|
||||
</div>
|
||||
<canvas id="chart-histogramme" class="chart-canvas"></canvas>
|
||||
</div>
|
||||
|
||||
<!-- Courbe progression -->
|
||||
<div class="chart-container">
|
||||
<div class="chart-title">
|
||||
<span>📈</span>
|
||||
<span>Progression par Élève (Top 5 + Moyenne)</span>
|
||||
</div>
|
||||
<canvas id="chart-progression" class="chart-canvas"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tableau -->
|
||||
<div class="table-section">
|
||||
<div class="table-header">
|
||||
<div class="table-title">📋 Tableau Détaillé</div>
|
||||
<div class="table-filters">
|
||||
<div class="filter-group">
|
||||
<label class="filter-label">Classe</label>
|
||||
<select id="filter-classe">
|
||||
<option value="">Toutes les classes</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label class="filter-label">Statut</label>
|
||||
<select id="filter-statut">
|
||||
<option value="">Tous</option>
|
||||
<option value="terminee">Terminé</option>
|
||||
<option value="en_cours">En cours</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label class="filter-label">Recherche</label>
|
||||
<input type="text" id="search-eleve" placeholder="Nom ou prénom...">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="table-resultats">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sortable" data-sort="rang">Rang</th>
|
||||
<th class="sortable" data-sort="nom">Nom</th>
|
||||
<th class="sortable" data-sort="prenom">Prénom</th>
|
||||
<th class="sortable" data-sort="classe">Classe</th>
|
||||
<th class="sortable" data-sort="note">Note</th>
|
||||
<th class="sortable" data-sort="pourcentage">%</th>
|
||||
<th class="sortable" data-sort="temps">Temps</th>
|
||||
<th class="sortable" data-sort="statut">Statut</th>
|
||||
<th class="sortable" data-sort="date_fin">Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-body">
|
||||
<!-- Rempli dynamiquement -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="table-footer" id="table-footer">
|
||||
<!-- Total affiché -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty state (si aucun résultat) -->
|
||||
<div id="empty-state" style="display: none;" class="empty-state">
|
||||
<div class="empty-state-icon">📭</div>
|
||||
<div class="empty-state-text">Aucun résultat disponible</div>
|
||||
<p style="margin-top: 10px; font-size: 14px;">Les élèves n'ont pas encore commencé cette évaluation.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// ========================================================================
|
||||
// VARIABLES GLOBALES
|
||||
// ========================================================================
|
||||
|
||||
let dataGlobal = null;
|
||||
let tentativesFiltrees = [];
|
||||
let sortColumn = 'rang';
|
||||
let sortDirection = 'asc';
|
||||
let chartHistogramme = null;
|
||||
let chartProgression = null;
|
||||
|
||||
const idEvaluation = <?= $id_evaluation ?>;
|
||||
|
||||
// ========================================================================
|
||||
// CHARGEMENT DONNÉES
|
||||
// ========================================================================
|
||||
|
||||
async function loadData() {
|
||||
try {
|
||||
const response = await fetch(`resultats_ajax.php?id_evaluation=${idEvaluation}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.success) {
|
||||
alert('Erreur: ' + data.error);
|
||||
return;
|
||||
}
|
||||
|
||||
dataGlobal = data;
|
||||
|
||||
// Masquer loading
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
|
||||
// Si aucune tentative
|
||||
if (data.tentatives.length === 0) {
|
||||
document.getElementById('empty-state').style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
// Afficher contenu
|
||||
document.getElementById('content').style.display = 'block';
|
||||
|
||||
// Mettre à jour titre
|
||||
document.getElementById('eval-title').textContent =
|
||||
'Résultats : ' + data.evaluation.titre;
|
||||
|
||||
// Remplir interface
|
||||
renderStats(data.stats, data.stats_classes, data.stats_questions);
|
||||
renderCharts(data.graphiques);
|
||||
populateFilters(data.tentatives);
|
||||
tentativesFiltrees = [...data.tentatives];
|
||||
renderTable();
|
||||
|
||||
} catch (error) {
|
||||
console.error('Erreur chargement:', error);
|
||||
alert('Erreur lors du chargement des données');
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// RENDU STATISTIQUES
|
||||
// ========================================================================
|
||||
|
||||
function renderStats(stats, statsClasses, statsQuestions) {
|
||||
const grid = document.getElementById('stats-grid');
|
||||
|
||||
const cards = [
|
||||
{
|
||||
label: 'Élèves',
|
||||
value: stats.total_eleves,
|
||||
class: ''
|
||||
},
|
||||
{
|
||||
label: 'Terminés',
|
||||
value: stats.termines,
|
||||
class: 'success'
|
||||
},
|
||||
{
|
||||
label: 'En cours',
|
||||
value: stats.en_cours,
|
||||
class: 'warning'
|
||||
},
|
||||
{
|
||||
label: 'Moyenne',
|
||||
value: stats.moyenne.toFixed(2) + '/20',
|
||||
class: stats.moyenne >= 12 ? 'success' : (stats.moyenne >= 10 ? 'warning' : 'danger')
|
||||
},
|
||||
{
|
||||
label: 'Médiane',
|
||||
value: stats.mediane.toFixed(2),
|
||||
class: ''
|
||||
},
|
||||
{
|
||||
label: 'Min / Max',
|
||||
value: stats.min.toFixed(1) + ' / ' + stats.max.toFixed(1),
|
||||
class: ''
|
||||
},
|
||||
{
|
||||
label: 'Écart-type',
|
||||
value: stats.ecart_type.toFixed(2),
|
||||
class: ''
|
||||
},
|
||||
{
|
||||
label: 'Taux réussite',
|
||||
value: stats.taux_reussite.toFixed(1) + '%',
|
||||
class: stats.taux_reussite >= 70 ? 'success' : (stats.taux_reussite >= 50 ? 'warning' : 'danger')
|
||||
},
|
||||
{
|
||||
label: 'Temps moyen',
|
||||
value: stats.temps_moyen,
|
||||
class: ''
|
||||
},
|
||||
{
|
||||
label: 'Meilleure classe',
|
||||
value: statsClasses.length > 0 ? statsClasses[0].nom : '-',
|
||||
class: 'success'
|
||||
}
|
||||
];
|
||||
|
||||
grid.innerHTML = cards.map(card => `
|
||||
<div class="stat-card ${card.class}">
|
||||
<div class="stat-value">${card.value}</div>
|
||||
<div class="stat-label">${card.label}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// RENDU GRAPHIQUES
|
||||
// ========================================================================
|
||||
|
||||
function renderCharts(graphiques) {
|
||||
// Détruire charts existants
|
||||
if (chartHistogramme) chartHistogramme.destroy();
|
||||
if (chartProgression) chartProgression.destroy();
|
||||
|
||||
// Histogramme par classe
|
||||
const ctxHisto = document.getElementById('chart-histogramme').getContext('2d');
|
||||
chartHistogramme = new Chart(ctxHisto, {
|
||||
type: 'bar',
|
||||
data: graphiques.histogramme_classes,
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
position: 'top'
|
||||
},
|
||||
title: {
|
||||
display: false
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
stepSize: 1
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Nombre d\'élèves'
|
||||
}
|
||||
},
|
||||
x: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Tranches de notes'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Courbe progression
|
||||
const ctxProg = document.getElementById('chart-progression').getContext('2d');
|
||||
chartProgression = new Chart(ctxProg, {
|
||||
type: 'line',
|
||||
data: graphiques.progression_eleves,
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
position: 'top'
|
||||
},
|
||||
title: {
|
||||
display: false
|
||||
},
|
||||
tooltip: {
|
||||
mode: 'index',
|
||||
intersect: false
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Points cumulés'
|
||||
}
|
||||
},
|
||||
x: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Questions'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// FILTRES ET TRI
|
||||
// ========================================================================
|
||||
|
||||
function populateFilters(tentatives) {
|
||||
// Remplir filtre classes
|
||||
const classes = [...new Set(tentatives.map(t => t.classe))].sort();
|
||||
const selectClasse = document.getElementById('filter-classe');
|
||||
|
||||
classes.forEach(classe => {
|
||||
const option = document.createElement('option');
|
||||
option.value = classe;
|
||||
option.textContent = classe;
|
||||
selectClasse.appendChild(option);
|
||||
});
|
||||
|
||||
// Événements filtres
|
||||
selectClasse.addEventListener('change', applyFilters);
|
||||
document.getElementById('filter-statut').addEventListener('change', applyFilters);
|
||||
document.getElementById('search-eleve').addEventListener('input', applyFilters);
|
||||
|
||||
// Événements tri
|
||||
document.querySelectorAll('th.sortable').forEach(th => {
|
||||
th.addEventListener('click', () => {
|
||||
const column = th.dataset.sort;
|
||||
if (sortColumn === column) {
|
||||
sortDirection = sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
sortColumn = column;
|
||||
sortDirection = 'asc';
|
||||
}
|
||||
renderTable();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function applyFilters() {
|
||||
const filtreClasse = document.getElementById('filter-classe').value;
|
||||
const filtreStatut = document.getElementById('filter-statut').value;
|
||||
const search = document.getElementById('search-eleve').value.toLowerCase();
|
||||
|
||||
tentativesFiltrees = dataGlobal.tentatives.filter(t => {
|
||||
// Filtre classe
|
||||
if (filtreClasse && t.classe !== filtreClasse) return false;
|
||||
|
||||
// Filtre statut
|
||||
if (filtreStatut && t.statut !== filtreStatut) return false;
|
||||
|
||||
// Recherche
|
||||
if (search) {
|
||||
const nomComplet = (t.nom + ' ' + t.prenom).toLowerCase();
|
||||
if (!nomComplet.includes(search)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
renderTable();
|
||||
}
|
||||
|
||||
function renderTable() {
|
||||
// Tri
|
||||
tentativesFiltrees.sort((a, b) => {
|
||||
let valA = a[sortColumn];
|
||||
let valB = b[sortColumn];
|
||||
|
||||
// Conversion numérique si nécessaire
|
||||
if (sortColumn === 'note' || sortColumn === 'pourcentage' || sortColumn === 'rang') {
|
||||
valA = parseFloat(valA) || 0;
|
||||
valB = parseFloat(valB) || 0;
|
||||
}
|
||||
|
||||
if (sortDirection === 'asc') {
|
||||
return valA > valB ? 1 : -1;
|
||||
} else {
|
||||
return valA < valB ? 1 : -1;
|
||||
}
|
||||
});
|
||||
|
||||
// Mise à jour classes th
|
||||
document.querySelectorAll('th.sortable').forEach(th => {
|
||||
th.classList.remove('sort-asc', 'sort-desc');
|
||||
if (th.dataset.sort === sortColumn) {
|
||||
th.classList.add('sort-' + sortDirection);
|
||||
}
|
||||
});
|
||||
|
||||
// Rendu lignes
|
||||
const tbody = document.getElementById('table-body');
|
||||
|
||||
tbody.innerHTML = tentativesFiltrees.map(t => {
|
||||
// Classe note selon valeur
|
||||
let noteClass = '';
|
||||
if (t.note >= 18) noteClass = 'excellent';
|
||||
else if (t.note >= 15) noteClass = 'good';
|
||||
else if (t.note >= 10) noteClass = 'average';
|
||||
else noteClass = 'bad';
|
||||
|
||||
// Badge statut
|
||||
const badgeClass = t.statut === 'terminee' ? 'termine' : 'en-cours';
|
||||
const badgeText = t.statut === 'terminee' ? 'Terminé' : 'En cours';
|
||||
|
||||
return `
|
||||
<tr>
|
||||
<td class="rang">${t.rang !== '-' ? t.rang : '-'}</td>
|
||||
<td>${t.nom}</td>
|
||||
<td>${t.prenom}</td>
|
||||
<td>${t.classe}</td>
|
||||
<td class="note ${noteClass}">${t.note}/${t.note_sur}</td>
|
||||
<td>${t.pourcentage}%</td>
|
||||
<td>${t.temps}</td>
|
||||
<td><span class="badge ${badgeClass}">${badgeText}</span></td>
|
||||
<td>${t.date_fin}</td>
|
||||
</tr>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
// Footer
|
||||
document.getElementById('table-footer').textContent =
|
||||
`Total : ${tentativesFiltrees.length} élève(s) affiché(s)`;
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// INITIALISATION
|
||||
// ========================================================================
|
||||
|
||||
window.addEventListener('DOMContentLoaded', loadData);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
41
enseignant/statistiques/index.php
Normal file
41
enseignant/statistiques/index.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../config/database.php';
|
||||
require_once __DIR__ . '/../../config/session.php';
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['id_type'] != 1) {
|
||||
header('Location: ../../login.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$user = SessionManager::getUser();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Statistiques détaillées</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f7fa; padding: 20px; }
|
||||
.container { max-width: 1200px; margin: 0 auto; background: white; border-radius: 12px; padding: 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
||||
h1 { color: #1976d2; margin-bottom: 30px; }
|
||||
.placeholder { text-align: center; padding: 60px 20px; color: #666; }
|
||||
.placeholder .icon { font-size: 80px; margin-bottom: 20px; opacity: 0.5; }
|
||||
.btn { display: inline-block; padding: 12px 24px; background: #1976d2; color: white; text-decoration: none; border-radius: 6px; margin-top: 20px; }
|
||||
.btn:hover { background: #1565c0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>📊 Statistiques détaillées</h1>
|
||||
|
||||
<div class="placeholder">
|
||||
<div class="icon">📈</div>
|
||||
<h2>Fonctionnalité en développement</h2>
|
||||
<p>Cette page affichera prochainement les statistiques détaillées de vos évaluations.</p>
|
||||
<a href="../dashboard.php" class="btn">← Retour au tableau de bord</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user