if (Grade::exists($id, $student_id)) { $newgrade = Grade::get_by_subj_stud($id, $student_id); $newgrade->delete(); } $newgrade = new Grade(); $newgrade->subject_id = $id; $newgrade->student_id = $student_id; $newgrade->grade = 0; $newgrade->create(); $pre_subject = Subject::get_by_id($id); if (!EvaluatedSubject::exists($id, $student_id)) { $grade = Grade::get_by_subj_stud($pre_subject->id, $student_id); $gradepre = Grade::get_by_subj_stud($pre_subject->prereq_subject_id, $student_id); if (has_prerequisite($pre_subject->prereq_subject_id, $student_subjects)) { if ($gradepre != null) { if (Grade::get_by_subj_stud($pre_subject->prereq_subject_id, $student_id)->grade <= 74) { $warnings .= "Cannot add " . $pre_subject->code . " because it's previous subject:" . Subject::get_by_id($pre_subject->prereq_subject_id)->code . " is failed\n\n"; } else { $eval_subject = new EvaluatedSubject(); $eval_subject->student_id = $student_id; $eval_subject->subject_id = $id; $eval_subject->create(); } } } else { $eval_subject = new EvaluatedSubject(); $eval_subject->student_id = $student_id; $eval_subject->subject_id = $id; $eval_subject->create(); } }
<?php require_once "../includes/initialize.php"; $student_id = $_GET['student_id']; $subject_ids2 = $_POST['subject_ids2']; $message = "success"; foreach ($subject_ids2 as $id) { $subject_id = EvaluatedSubject::get_by_id($id)->subject_id; $newgrade = Grade::get_by_subj_stud($subject_id, $student_id); if ($newgrade != null) { $newgrade->delete(); } $object = EvaluatedSubject::get_by_id($id); if ($object != null) { $object->delete(); } } echo $message;