You are here

function quiz_end_scoring in Quiz 7.4

Same name and namespace in other branches
  1. 8.4 quiz.module \quiz_end_scoring()
  2. 6.4 quiz.module \quiz_end_scoring()
  3. 7.6 quiz.module \quiz_end_scoring()
  4. 7 quiz.module \quiz_end_scoring()
  5. 7.5 quiz.module \quiz_end_scoring()

Score a completed quiz.

Related topics

1 call to quiz_end_scoring()
quiz_take_quiz in ./quiz.module
Handles quiz taking.

File

./quiz.module, line 2510
Quiz Module

Code

function quiz_end_scoring($quiz, $rid) {
  global $user;
  $score = quiz_calculate_score($quiz, $rid);
  if (!isset($score['percentage_score'])) {
    $score['percentage_score'] = 0;
  }
  db_update('quiz_node_results')
    ->fields(array(
    'is_evaluated' => $score['is_evaluated'],
    'time_end' => REQUEST_TIME,
    'score' => $score['percentage_score'],
  ))
    ->condition('result_id', $rid)
    ->execute();
  if ($user->uid) {
    $score['passing'] = quiz_is_passed($user->uid, $quiz->nid, $quiz->vid);
  }
  else {
    $score['passing'] = $score['percentage_score'] >= $quiz->pass_rate;
  }
  return $score;
}