This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. */ // 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 "

ERROR: Fach $fach bei $matrikelnummer existiert nicht

"; 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 "

ERROR: Note $note ungueltig fuer $matrikelnummer,$fach,$teilpruefung

"; } } } } foreach ($notenupdate[$fach] as $teilpruefung => $neuenote) { $students[$matrikelnummer]["noten"][$fach][$teilpruefung] = $neuenote; db_student_update_note($matrikelnummer,$fach,$teilpruefung,$neuenote); } } } ?>