-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajouter_note.php
More file actions
103 lines (92 loc) · 3.99 KB
/
ajouter_note.php
File metadata and controls
103 lines (92 loc) · 3.99 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
<?php
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);
if (!isset($_GET['id'])) {
header("Location: index.php");
exit();
}
$etudiant_id = $_GET['id'];
$etudiant_info = $etudiant->getById($etudiant_id);
if (!$etudiant_info) {
header("Location: index.php");
exit();
}
// Récupérer la liste des matières
$matieres = $matiere->read();
$liste_matieres = [];
while ($row = $matieres->fetch(PDO::FETCH_ASSOC)) {
$liste_matieres[] = $row;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$note->etudiant_id = $etudiant_id;
$note->matiere = $_POST['matiere'];
$note->note = $_POST['note'];
$note->type_note = $_POST['type_note'];
$note->date_examen = $_POST['date_examen'];
if ($note->create()) {
header("Location: voir_notes.php?id=" . $etudiant_id);
exit();
}
}
// Définir la date du jour comme valeur par défaut
$date_aujourdhui = date('Y-m-d');
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Ajouter une Note - <?php echo htmlspecialchars($etudiant_info['prenom'] . ' ' . $etudiant_info['nom']); ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-4">
<h1>Ajouter une Note</h1>
<h2 class="h4 mb-4">Pour <?php echo htmlspecialchars($etudiant_info['prenom'] . ' ' . $etudiant_info['nom']); ?> (<?php echo htmlspecialchars($etudiant_info['classe']); ?>)</h2>
<form method="POST" class="card">
<div class="card-body">
<div class="mb-3">
<label for="matiere" class="form-label">Matière</label>
<select class="form-select" id="matiere" name="matiere" required>
<option value="">Sélectionnez une matière</option>
<?php foreach ($liste_matieres as $mat): ?>
<option value="<?php echo htmlspecialchars($mat['nom']); ?>">
<?php echo htmlspecialchars($mat['nom']); ?>
(<?php echo $mat['credit']; ?> crédit<?php echo $mat['credit'] > 1 ? 's' : ''; ?>)
</option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label for="type_note" class="form-label">Type de note</label>
<select class="form-select" id="type_note" name="type_note" required>
<option value="">Sélectionnez le type de note</option>
<option value="cc">Contrôle Continu (CC) - 30%</option>
<option value="sn">Session Normale (SN) - 70%</option>
</select>
</div>
<div class="mb-3">
<label for="note" class="form-label">Note</label>
<input type="number" step="0.25" min="0" max="20" class="form-control" id="note" name="note" required>
</div>
<div class="mb-3">
<label for="date_examen" class="form-label">Date de l'examen</label>
<input type="date" class="form-control" id="date_examen" name="date_examen"
value="<?php echo $date_aujourdhui; ?>" required>
</div>
<div class="mt-4">
<button type="submit" class="btn btn-primary">Ajouter la note</button>
<a href="voir_notes.php?id=<?php echo $etudiant_id; ?>" class="btn btn-secondary">Retour aux notes</a>
</div>
</div>
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>