$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();
        }
    }
}
if ($warnings != "") {
    echo $warnings;
} else {
    if (!EvaluatedStudent::exists($student_id)) {
        $evaluatedstudent = new EvaluatedStudent();
        $evaluatedstudent->student_id = $student_id;
        $evaluatedstudent->create();
    }
    echo "success";
}
<?php

require_once "../includes/initialize.php";
global $session;
if (!$session->is_logged_in()) {
    redirect_to("index.php");
}
if ($_POST['oper'] == 'add') {
    $eval_student = new EvaluatedStudent();
    $eval_student->code = $_POST['code'];
    $eval_student->description = $_POST['description'];
    $eval_student->year = $_POST['year'];
    $eval_student->semester = $_POST['semester'];
    $eval_student->create();
} else {
    if ($_POST['oper'] == 'edit') {
        $eval_student = EvaluatedStudent::get_by_id($_POST['id']);
        $eval_student->code = $_POST['code'];
        $eval_student->description = $_POST['description'];
        $eval_student->year = $_POST['year'];
        $eval_student->semester = $_POST['semester'];
        $eval_student->update();
    } else {
        if ($_POST['oper'] == 'del') {
            EvaluatedStudent::get_by_id($_POST['id'])->delete();
        }
    }
}