Ejemplo n.º 1
0
 public function getByExamSubjectId($exam_subject_id)
 {
     $qry = "SELECT * FROM " . $this->strTableName . " WHERE `exam_subject_id`='" . $exam_subject_id . "';";
     $objStmt = $this->objPDO->prepare($qry);
     $objStmt->execute();
     $result = array();
     require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/splitup_marks_class.php';
     global $objPDO;
     $split = new SplitupMarks($objPDO);
     while ($res = $objStmt->fetch(PDO::FETCH_ASSOC)) {
         $split_marks = $split->getByExamMarksId($res['id']);
         $result[$res['student_id']] = array('id' => $res['id'], 'total_marks' => $res['marks'], 'grade' => $res['grade'], 'split' => $split_marks);
     }
     return $result;
 }
Ejemplo n.º 2
0
 protected function savemarks()
 {
     $required = array("exam_subject_id" => "Examination", "student" => "Student Id", "total_marks" => "Total Marks");
     global $user;
     global $objPDO;
     $student = new Student($objPDO, $user->getuserId());
     if ($user->checkAdmin() == true || $student->checkTeacher()) {
         if (isset($_POST)) {
             foreach ($required as $key => $value) {
                 if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
                     echo $value . ' is Required<br/>';
                     return;
                 }
             }
             $flag = true;
             foreach ($_POST['student'] as $key => $value) {
                 if (!isset($_POST['total_marks'][$key]) || !is_numeric($_POST['total_marks'][$key])) {
                     $flag = false;
                 }
             }
             if ($flag == false) {
                 echo 'Enter All Students Marks (you may use -1 for not attended)';
                 return;
             }
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/marks_splitup_class.php';
             $split_ups = new MarksSplitup($objPDO);
             $split = $split_ups->getByExamSubjectId($_POST['exam_subject_id']);
             $split_marks = array();
             foreach ($split as $key => $value) {
                 if (!isset($_POST[$value['id']])) {
                     echo 'Marks Split Up Required (If Not Needed Change Marks Split Up Settings)';
                     return;
                 } else {
                     foreach ($_POST[$value['id']] as $k => $v) {
                         if ($v == "" || !is_numeric($v)) {
                             echo 'Marks Split Up Required (If Not Needed Change Marks Split Up Settings)';
                             return;
                         } else {
                             $split_marks[$k][$value['id']] = $v;
                         }
                     }
                 }
             }
             echo 'Saving...';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/exam_marks_class.php';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/splitup_marks_class.php';
             $total_marks = $_POST['total_marks'];
             $student = $_POST['student'];
             foreach ($student as $key => $value) {
                 $exam = new ExamMarks($objPDO);
                 $exam->setExamSubjectId($_POST['exam_subject_id']);
                 $exam->setStudentId($value);
                 $exam->setByExamStudentID($_POST['exam_subject_id'], $value);
                 $exam->setMarks($total_marks[$key]);
                 $exam->autoGrade();
                 $exam->save();
                 $exam_marks_id = $exam->getID();
                 if ($split_marks) {
                     foreach ($split_marks[$key] as $k => $v) {
                         $split = new SplitupMarks($objPDO);
                         $split->setExamMarksId($exam_marks_id);
                         $split->setSplitUpId($k);
                         $split->setMarks($v);
                         $split->save();
                     }
                 }
             }
             echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/examination"/>';
         }
     } else {
         header('Location:http://localhost/cloud');
     }
 }