abstract class AbstractQuizQuestionResponse in Quiz 6.3
Same name and namespace in other branches
- 6.6 question_types/quiz_question/quiz_question.core.inc \AbstractQuizQuestionResponse
- 6.5 question_types/quiz_question/quiz_question.core.inc \AbstractQuizQuestionResponse
A base implementation of QuizQuestionResponse.
Hierarchy
- class \AbstractQuizQuestionResponse implements QuizQuestionResponse
Expanded class hierarchy of AbstractQuizQuestionResponse
File
- question_types/
quiz_question/ quiz_question.core.inc, line 212 - Classes used in the Quiz Question module.
View source
abstract class AbstractQuizQuestionResponse implements QuizQuestionResponse {
// These are only public until we can
// adjust all of Quiz. DO NOT EXPECT THESE
// TO BE ACCESSIBLE!
public $score = 0;
public $rid = 0;
public $is_correct = FALSE;
protected $evaluated = TRUE;
protected $question = NULL;
protected $answer = NULL;
/*
public function __construct($rid, $question, $answer) {
$this->rid = $rid;
$this->question = $question;
$this->answer = $answer;
}
*/
public function isEvaluated() {
return $this->evaluated;
}
/**
* Check to see if the answer is marked as correct.
*
* This default version returns TRUE iff the score is equal to the maximum possible score.
*/
function isCorrect() {
$possible = _quiz_question_get_instance($this->question)
->getMaximumScore();
$actual = $this->score;
return $possible == $actual;
}
function getScore() {
return $this->score;
}
function toBareObject() {
$obj = new stdClass();
$obj->score = $this->score;
// This can be 0 for unscored.
$obj->nid = $this->question->nid;
$obj->vid = $this->question->vid;
$obj->rid = $this->rid;
$obj->is_correct = $this
->isCorrect();
$obj->is_evaluated = $this
->isEvaluated();
$obj->is_skipped = FALSE;
return $obj;
}
public function getReport() {
// Basically, we encode internal information in a
// legacy array format for Quiz.
$report = array(
'answer_id' => 0,
// <-- Stupid vestige of multichoice.
'answer' => $this->answer,
'is_evaluated' => $this
->isEvaluated(),
'is_correct' => $this
->isCorrect(),
'score' => $this->score,
'question_vid' => $this->question->vid,
'question_nid' => $this->question->nid,
'result_id' => $this->rid,
);
return $report;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractQuizQuestionResponse:: |
protected | property | ||
AbstractQuizQuestionResponse:: |
protected | property | ||
AbstractQuizQuestionResponse:: |
public | property | ||
AbstractQuizQuestionResponse:: |
protected | property | ||
AbstractQuizQuestionResponse:: |
public | property | ||
AbstractQuizQuestionResponse:: |
public | property | ||
AbstractQuizQuestionResponse:: |
public | function |
Get data suitable for reporting a user's score on the question.
This expects an object with the following attributes: Overrides QuizQuestionResponse:: |
|
AbstractQuizQuestionResponse:: |
function |
Get the integer score. Overrides QuizQuestionResponse:: |
||
AbstractQuizQuestionResponse:: |
function |
Check to see if the answer is marked as correct. Overrides QuizQuestionResponse:: |
3 | |
AbstractQuizQuestionResponse:: |
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. Overrides QuizQuestionResponse:: |
|
AbstractQuizQuestionResponse:: |
function |
Repesent the response as a stdClass object. Overrides QuizQuestionResponse:: |
||
QuizQuestionResponse:: |
public | function | Delete the response. | 5 |
QuizQuestionResponse:: |
public | function | Return an HTML marked-up report for displaying the results of this question. | 5 |
QuizQuestionResponse:: |
public | function | Get the user's response. | 5 |
QuizQuestionResponse:: |
public | function | Save the current response. | 5 |
QuizQuestionResponse:: |
public | function | Calculate the score for the response. This MUST set the $score instance variable. | 5 |
QuizQuestionResponse:: |
public | function | Create a new user response. | 5 |