You are here

function quiz_question_skip_question in Quiz 8.4

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

Implements hook_skip_question().

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.

Code

function quiz_question_skip_question($question, $result_id) {
  unset($_POST['tries']);

  // Unset any answer that might have been set.
  // Delete any old answers for this question (for backwards nav).
  _quiz_question_response_get_instance($result_id, $question)
    ->delete();

  // This is the standard response:
  $response = new stdClass();
  $response->nid = $question
    ->id();
  $response->vid = $question
    ->getRevisionId();
  $response->rid = $result_id;
  $response->is_skipped = TRUE;
  if (isset($_POST['is_doubtful'])) {
    $response->is_doubtful = $_POST['is_doubtful'];
  }
  else {
    $response->is_doubtful = db_query('SELECT is_doubtful FROM {quiz_node_results_answers} WHERE result_id = :result_id AND question_nid = :question_nid AND question_vid = :question_vid', array(
      ':result_id' => $result_id,
      ':question_nid' => $question
        ->id(),
      ':question_vid' => $question
        ->getRevisionId(),
    ))
      ->fetchField();
  }
  return $response;
}