Пример #1
0
 public function GradeTest()
 {
     include APPPATH . 'models\\Helper\\Grade.php';
     //Test 1
     $grade_1 = new Grade('A+');
     $expected_result = true;
     $this->unit->run($grade_1->passed('C+'), $expected_result, 'Grade A- passed course grade of C+.');
     //Test 2
     $grade_1 = new Grade('D+');
     $expected_result = false;
     $this->unit->run($grade_1->passed('C+'), $expected_result, 'Grade D- failed course grade of C+.');
     //Test 3
     $grade_1 = new Grade('');
     $expected_result = true;
     $this->unit->run($grade_1->passed('C+'), $expected_result, 'Empty Grade (Pending Grade), conditional pass.');
     //Test 3
     $grade_1 = new Grade('D-');
     $expected_result = true;
     $this->unit->run($grade_1->passed('D-'), $expected_result, 'Grade D- passed course grade of D-.');
     echo $this->unit->report();
 }
Пример #2
0
 /**
  * Checks if the current student has completed the course.
  *
  * @param $course_id
  * @return bool
  * @throws Exception
  */
 public function is_complete($course_id)
 {
     $passing_grade = $this->course->getPassingGrade($course_id);
     $grades = $this->db->query("\n\t\t\tSELECT\n\t\t\t  registered.grade\n\t\t\tFROM registered\n\t\t\t  INNER JOIN sections\n\t\t\t\tON registered.section_id = sections.id\n\t\t\t  INNER JOIN semesters\n\t\t\t\tON sections.semester_id = semesters.id\n\t\t\tWHERE sections.course_id = '{$course_id}' AND semesters.id < '{$this->semester_id}' AND registered.student_id = '{$this->student_id}'")->result();
     foreach ($grades as $grade) {
         if (!$grade->grade) {
             return TRUE;
         }
         $mark = new Grade($grade->grade);
         if ($mark->passed($passing_grade)) {
         }
         return TRUE;
     }
     return FALSE;
 }
Пример #3
0
 /**
  * Determines if a course is completed with passing grade or going to be completed.
  *
  * @param $course_id - the course id to compare with.
  * @param $allGrades - the lists of all grades with all courses.
  * @return bool - returns true if he has completed the course.
  * @throws Exception - Throws exception if invalid grade, shouldn't happen however.
  */
 private function isCompleted($course_id, $allGrades)
 {
     foreach ($allGrades as $value) {
         if ($value->course_id == $course_id) {
             //
             $grade = new Grade($value->grade);
             if ($grade->passed($value->passing_grade)) {
                 return true;
             }
         }
     }
     return false;
 }