You are here

interface QuizQuestionResponse in Quiz 6.3

Same name and namespace in other branches
  1. 6.6 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse
  2. 6.5 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse

Each question type must store its own response data and be able to calculate a score for that data.

Hierarchy

Expanded class hierarchy of QuizQuestionResponse

All classes that implement QuizQuestionResponse

File

question_types/quiz_question/quiz_question.core.inc, line 126
Classes used in the Quiz Question module.

View source
interface QuizQuestionResponse {

  /**
   * Create a new user response.
   *
   * @param $rid
   *  The result ID for the user's result set. There is one result ID per time
   *  the user takes a quiz.
   * @param $question
   *  The question node.
   * @param $answer
   *  The answer (dependent on question type).
   */
  public function __construct($rid, $question, $answer = NULL);

  /**
   * Save the current response.
   */
  public function save();

  /**
   * Delete the response.
   */
  public function delete();

  /**
   * Calculate the score for the response.
   * This MUST set the $score instance variable.
   */
  public function score();

  /**
   * Determine whether the score is a passing score.
   */
  public function isCorrect();

  /**
   * Indicate whether the response has been evaluated (scored) yet.
   * Questions that require human scoring (e.g. essays) may need to manually
   * toggle this.
   */
  public function isEvaluated();

  /**
   * Get the user's response.
   */
  public function getResponse();

  /**
   * Get data suitable for reporting a user's score on the question.
   * This expects an object with the following attributes:
   *
   *  answer_id; // The answer ID
   *  answer; // The full text of the answer
   *  is_evaluated; // 0 if the question has not been evaluated, 1 if it has
   *  score; // The score the evaluator gave the user; this should be 0 if is_evaluated is 0.
   *  question_vid
   *  question_nid
   *  result_id
   */
  public function getReport();

  /**
   * Return an HTML marked-up report for displaying the results of this question.
   *
   * @return
   *  An HTML string.
   */
  public function formatReport($showPoints = TRUE, $showFeedback = TRUE);

  /**
   * Get the integer score.
   */
  public function getScore();

  /**
   * Repesent the response as a stdClass object.
   *
   * Convert data to an object that has the following properties:
   * - $score
   * - $rid
   * - $nid
   * - $vid
   * - $is_correct
   */
  public function toBareObject();

}

Members

Namesort descending Modifiers Type Description Overrides
QuizQuestionResponse::delete public function Delete the response. 5
QuizQuestionResponse::formatReport public function Return an HTML marked-up report for displaying the results of this question. 5
QuizQuestionResponse::getReport public function Get data suitable for reporting a user's score on the question. This expects an object with the following attributes: 1
QuizQuestionResponse::getResponse public function Get the user's response. 5
QuizQuestionResponse::getScore public function Get the integer score. 1
QuizQuestionResponse::isCorrect public function Determine whether the score is a passing score. 1
QuizQuestionResponse::isEvaluated public function Indicate whether the response has been evaluated (scored) yet. Questions that require human scoring (e.g. essays) may need to manually toggle this. 1
QuizQuestionResponse::save public function Save the current response. 5
QuizQuestionResponse::score public function Calculate the score for the response. This MUST set the $score instance variable. 5
QuizQuestionResponse::toBareObject public function Repesent the response as a stdClass object. 1
QuizQuestionResponse::__construct public function Create a new user response. 5