function CourseObjectQuizFulfillment::grade in Course 7.2
Marks a user's fulfillment record for this object complete if the user passed the quiz.
File
- modules/
course_quiz/ CourseObjectQuizFulfillment.php, line 33
Class
- CourseObjectQuizFulfillment
- Course fulfillment class for quizzes.
Code
function grade($rid) {
$result = quiz_result_load($rid);
// Store the result ID.
$result_ids = (array) $this
->getOption('quiz_result_ids');
$result_ids[] = $rid;
$this
->setOption('instance', $rid);
$this
->setOption('quiz_result_ids', $result_ids);
if ($result && $result->score >= $this
->getCourseObject()
->getOption('passing_grade')) {
$this
->setGrade($result->score)
->setComplete()
->save();
}
else {
$this
->setGrade($result->score)
->save();
}
}