-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes_par_classe.php
More file actions
120 lines (112 loc) · 4.72 KB
/
notes_par_classe.php
File metadata and controls
120 lines (112 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
session_start();
require_once "config/database.php";
require_once "models/Note.php";
require_once "models/Etudiant.php";
require_once "models/Matiere.php";
$database = new Database();
$db = $database->getConnection();
$note = new Note($db);
$etudiant = new Etudiant($db);
$matiere = new Matiere($db);
$etab = $_SESSION['etab'] ?? '';
// Récupérer la liste des classes
$classes = $etudiant->getClasses();
// Récupérer la classe sélectionnée
$selected_class = isset($_GET['classe']) ? $_GET['classe'] : '';
// Récupérer la liste des matières
$matieres = $matiere->read();
$liste_matieres = [];
while ($row = $matieres->fetch(PDO::FETCH_ASSOC)) {
$liste_matieres[] = $row;
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Notes par Classe</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.credit-info {
font-size: 0.8em;
color: #666;
}
.table th {
white-space: nowrap;
}
</style>
</head>
<body>
<div class="container-fluid mt-4">
<h1>Notes par Classe</h1>
<form method="GET" class="mb-4">
<div class="row">
<div class="col-md-4">
<select name="classe" class="form-select" onchange="this.form.submit()">
<option value="">Sélectionnez une classe</option>
<?php foreach ($classes as $classe): ?>
<option value="<?php echo htmlspecialchars($classe); ?>"
<?php echo $selected_class === $classe ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($classe); ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
</form>
<?php if ($selected_class): ?>
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Étudiant</th>
<?php foreach ($liste_matieres as $mat): ?>
<th>
<?php echo htmlspecialchars($mat['nom']); ?>
<div class="credit-info">(<?php echo $mat['credit']; ?> crédit<?php echo $mat['credit'] > 1 ? 's' : ''; ?>)</div>
</th>
<?php endforeach; ?>
<th>Moyenne Générale</th>
</tr>
</thead>
<tbody>
<?php
$etudiants = $etudiant->readByClasse($selected_class, $etab);
while ($etud = $etudiants->fetch(PDO::FETCH_ASSOC)):
?>
<tr>
<td>
<a href="voir_notes.php?id=<?php echo htmlspecialchars($etud['id']); ?>" class="text-decoration-none">
<?php echo htmlspecialchars($etud['nom'] . ' ' . $etud['prenom']); ?>
</a>
</td>
<?php foreach ($liste_matieres as $mat):
$note_finale = $note->getNoteFinaleByEtudiantMatiere($etud['id'], $mat['nom']);
?>
<td class="text-center">
<?php
if ($note_finale !== null) {
echo number_format($note_finale, 2);
} else {
echo '-';
}
?>
</td>
<?php endforeach; ?>
<td class="text-center fw-bold">
<?php
$moyenne = $note->getMoyenneEtudiant($etud['id']);
echo $moyenne !== null ? number_format($moyenne, 2) : '-';
?>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>