You are here

public function CourseGradeTestCase::testCourseFinalGrade in Course 6

Same name and namespace in other branches
  1. 7.2 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 22

Class

CourseGradeTestCase
Tests for Course enrollment

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 = $courseObjects[0];

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

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

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