You are here

public function CourseGradeTestCase::testCourseFinalGrade in Course 7.2

Same name and namespace in other branches
  1. 6 tests/CourseGradeTestCase.test \CourseGradeTestCase::testCourseFinalGrade()
  2. 7 tests/CourseGradeTestCase.test \CourseGradeTestCase::testCourseFinalGrade()

Test that the final grade is calculated correctly.

File

tests/CourseGradeTestCase.test, line 20

Class

CourseGradeTestCase
Tests for Course grade.

Code

public function testCourseFinalGrade() {
  $courseNode = $this
    ->createCourseNode();

  // Create a graded course object.
  $co1 = $this
    ->createCourseObject($courseNode, TRUE);

  // Reload the course from DB.
  $course = course_get_course($courseNode);
  $courseObjects = $course
    ->getObjects();
  $co1 = reset($courseObjects);
  course_enroll($courseNode, $this->student_user);

  // Set grade result.
  $co1
    ->getFulfillment($this->student_user)
    ->setOption('grade_result', 80)
    ->save();

  // Track object not included in final grade.
  $co1
    ->setOption('grade_include', FALSE)
    ->save();
  $co1
    ->getCourse()
    ->getTracker($this->student_user)
    ->track();
  $this
    ->assertNotEqual($co1
    ->getCourse()
    ->getTracker($this->student_user)
    ->getOption('grade_result'), 80, 'Course grade was not given from course object');

  // Track object included in final grade.
  $co1
    ->setOption('grade_include', TRUE)
    ->save();
  $co1
    ->getCourse()
    ->getTracker($this->student_user)
    ->track();
  $this
    ->assertEqual($co1
    ->getCourse()
    ->getTracker($this->student_user)
    ->getOption('grade_result'), 80, 'Course grade was given from course object');
}