You are here

function course_quiz_quiz_finished in Course 7

Same name and namespace in other branches
  1. 6 modules/course_quiz/course_quiz.module \course_quiz_quiz_finished()
  2. 7.2 modules/course_quiz/course_quiz.module \course_quiz_quiz_finished()

Implements hook_quiz_finished().

Update the fulfillment record when a user finishes a quiz.

1 call to course_quiz_quiz_finished()
course_quiz_quiz_scored in modules/course_quiz/course_quiz.module
Implements hook_quiz_scored().

File

modules/course_quiz/course_quiz.module, line 24

Code

function course_quiz_quiz_finished($quiz, $score, $session_data) {
  $uid = db_query('SELECT uid FROM {quiz_node_results} WHERE result_id = :result_id', array(
    ':result_id' => $session_data['result_id'],
  ))
    ->fetchField();
  if ($uid) {
    $account = user_load($uid);
    if ($courseObject = course_get_course_object('course_quiz', 'quiz', $quiz->nid, $account)) {

      /* @var $courseObject CourseObjectQuiz */
      $courseObject
        ->grade($account, $session_data['result_id']);
    }
  }
}