You are here

function quiz_question_evaluate_question in Quiz 6.6

Same name and namespace in other branches
  1. 8.4 question_types/quiz_question/quiz_question.module \quiz_question_evaluate_question()
  2. 6.3 question_types/quiz_question/quiz_question.module \quiz_question_evaluate_question()
  3. 6.4 question_types/quiz_question/quiz_question.module \quiz_question_evaluate_question()
  4. 6.5 question_types/quiz_question/quiz_question.module \quiz_question_evaluate_question()
  5. 7 question_types/quiz_question/quiz_question.module \quiz_question_evaluate_question()
  6. 7.4 question_types/quiz_question/quiz_question.module \quiz_question_evaluate_question()

Implementation of Quiz's hook_evaluate_question().

Return value

Object with nid, vid, rid, score, is_correct flags set.

File

question_types/quiz_question/quiz_question.module, line 308
Quiz Question module. This module provides the basic facilities for adding quiz question types to a quiz. While you can create standard Quiz question types simply by implementing the appropriate hooks, this module provides a framework that makes…

Code

function quiz_question_evaluate_question($question, $rid, $answer = NULL) {

  //print_r($_POST['tries']);exit;
  if (empty($answer)) {
    $answer = $_POST['tries'];

    //$answer = is_array($_POST['tries']) ? $_POST['tries'] : array($_POST['tries']);
  }
  unset($_POST['tries']);
  $response = _quiz_question_response_get_instance($rid, $question, $answer);

  // If a rid is set, we are taking a quiz.
  if ($rid && isset($answer)) {

    // We don't know whether or not the user has gone back a question. However,
    // we do know that deleting a question for this result set should be safe in
    // the case where the user has not gone back (since there will be no entries
    // to delete). So we always run the delete.
    $response
      ->delete();
    $response
      ->save();
  }

  // Convert the response to a bare object.
  return $response
    ->toBareObject();
}