You are here

function quiz_question_report_form in Quiz 6.4

Same name and namespace in other branches
  1. 8.4 question_types/quiz_question/quiz_question.module \quiz_question_report_form()
  2. 7.6 question_types/quiz_question/quiz_question.module \quiz_question_report_form()
  3. 7 question_types/quiz_question/quiz_question.module \quiz_question_report_form()
  4. 7.4 question_types/quiz_question/quiz_question.module \quiz_question_report_form()
  5. 7.5 question_types/quiz_question/quiz_question.module \quiz_question_report_form()

Returns a result report for a question response.

The retaurned value is a form array because in some contexts the scores in the form is editable

Parameters

$question: The question node

$showpoints:

$showfeedback:

$allow_scoring:

Return value

FAPI form array

File

question_types/quiz_question/quiz_question.module, line 834
Quiz Question module. This module provides the basic facilities for adding quiz question types to a quiz.

Code

function quiz_question_report_form($question, $showpoints, $showfeedback, $allow_scoring = FALSE) {
  $answer = $question->answers[0];
  $response_instance = _quiz_question_response_get_instance($answer['result_id'], $question, $answer);

  // If need to specify the score weight if it isn't already specified.
  if (!isset($response_instance->question->score_weight)) {
    $sql = 'SELECT qnr.max_score
            FROM {quiz_node_relationship} qnr
            WHERE qnr.child_vid = %d
            AND qnr.parent_vid = (
              SELECT vid
              FROM {quiz_node_results}
              WHERE result_id = %d
            )';
    $qnr_max_score = db_result(db_query($sql, $question->vid, $answer['result_id']));
    if ($qnr_max_score === FALSE) {
      $qnr_max_score = db_result(db_query('SELECT qt.max_score
         FROM {quiz_node_results} qnr
         JOIN {quiz_node_results_answers} qnra ON (qnr.result_id = qnra.result_id)
         JOIN {quiz_terms} qt ON (qt.vid = qnr.vid AND qt.tid = qnra.tid)
         WHERE qnr.result_id = %d AND qnra.question_nid = %d AND qnra.question_vid = %d', $answer['result_id'], $question->nid, $question->vid));
    }
    if ($qnr_max_score == 0) {
      $weight = 0;
    }
    else {
      $weight = $qnr_max_score / $response_instance->question->max_score;
    }
    $response_instance->question->score_weight = $weight;
  }
  return $response_instance
    ->getReportForm($showpoints, $showfeedback, $allow_scoring);
}