blob: c952618691b6453c86754077582a40103d2892ea (
plain)
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
|
<?php
// Check the entries in the form and compare them with the
// data in the database. If there are updates, then change
// the data in the database and append the json file with
// the changes.
if (empty($_POST["note"])) {
return;
}
$notenneu = $_POST["note"];
foreach ($notenneu as $matrikelnummer => $pruefungen) {
foreach ($pruefungen as $fach => $semesterliste) {
$notenupdate[$fach] = [];
if (!array_key_exists($fach,$students[$matrikelnummer]["noten"])) {
var_dump($students[$matrikelnummer]);
echo "<p>ERROR: Fach $fach bei $matrikelnummer existiert nicht</p>";
break;
}
foreach ($semesterliste as $semestername => $teilpruefungen) {
// "amt" is a checkbox input where the name exists only when checked
// So the $teilpruefung loop will only iterate if it is checked.
if (!empty($students[$matrikelnummer]["noten"][$fach]["amt"])
and empty($teilpruefungen["amt"])) {
$notenupdate[$fach]["amt"]="";
}
foreach ($teilpruefungen as $teilpruefung => $note) {
if (!empty($note)
and (in_array($note,$notendelete)
or empty($students[$matrikelnummer]["noten"][$fach][$teilpruefung])
or $students[$matrikelnummer]["noten"][$fach][$teilpruefung] !== $note)) {
if ($teilpruefung === "klausur" and in_array($note,$notenklausur)
or $teilpruefung === "labor" and in_array($note,$notenlabor)
or $teilpruefung === "amt" and in_array($note,$notenamt)
or in_array($note,$notendelete)) {
$note = in_array($note,$notendelete) ? "" : $note;
$notenupdate[$fach][$teilpruefung]=$note;
} else {
var_dump($students[$matrikelnummer]);
echo "<p>ERROR: Note $note ungueltig fuer $matrikelnummer,$fach,$teilpruefung </p>";
}
}
}
}
foreach ($notenupdate[$fach] as $teilpruefung => $neuenote) {
$students[$matrikelnummer]["noten"][$fach][$teilpruefung] = $neuenote;
db_student_update_note($matrikelnummer,$fach,$teilpruefung,$neuenote);
}
}
}
?>
|