class ScaleResponse in Quiz 6.6
Same name and namespace in other branches
- 8.6 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleResponse.php \ScaleResponse
- 8.5 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleResponse.php \ScaleResponse
- 6.4 question_types/scale/scale.classes.inc \ScaleResponse
- 7.6 question_types/scale/scale.classes.inc \ScaleResponse
- 7 question_types/scale/scale.classes.inc \ScaleResponse
- 7.4 question_types/scale/scale.classes.inc \ScaleResponse
- 7.5 question_types/scale/scale.classes.inc \ScaleResponse
The short answer question response class.
Hierarchy
- class \AbstractQuizQuestionResponse
- class \ScaleResponse
Expanded class hierarchy of ScaleResponse
1 string reference to 'ScaleResponse'
- scale_quiz_question_info in question_types/
scale/ scale.module - Implementation of hook_quiz_question_info().
File
- question_types/
scale/ scale.classes.inc, line 484 - The main classes for the scale question type.
View source
class ScaleResponse extends AbstractQuizQuestionResponse {
/**
* ID of the answer.
*/
protected $answer_id = 0;
/**
* Constructor
*
* @param $rid - response_id
* @param $question - as an object
* @param $answer - answer_id
*/
public function __construct($rid, $question, $answer = NULL) {
$this->rid = $rid;
$this->question = $question;
if (isset($answer)) {
$this->answer_id = $answer;
}
else {
$sql = 'SELECT answer_id
FROM {quiz_scale_user_answers}
WHERE result_id = %d AND question_nid = %d AND question_vid = %d';
$res = db_query($sql, $rid, $this->question->nid, $this->question->vid);
$res_o = db_fetch_object($res);
$this->answer_id = $res_o->answer_id;
}
$sql = 'SELECT answer
FROM {quiz_scale_answer}
WHERE id = %d';
$res = db_query($sql, $this->answer_id);
$res_o = db_fetch_object($res);
$this->answer = check_plain($res_o->answer);
}
/**
* Implementation of save
*/
public function save() {
$sql = "INSERT INTO {quiz_scale_user_answers}\n (answer_id, result_id, question_vid, question_nid)\n VALUES (%d, %d, %d, %d)";
db_query($sql, $this->answer_id, $this->rid, $this->question->vid, $this->question->nid);
}
/**
* Implementation of delete
*/
public function delete() {
$sql = 'DELETE FROM {quiz_scale_user_answers}
WHERE result_id = %d AND question_nid = %d AND question_vid = %d';
db_query($sql, $this->rid, $this->question->nid, $this->question->vid);
}
/**
* Implementation of score
*
* @return 0 - this question type is never scored.
*/
public function score() {
return 0;
}
/**
* Implementation of isCorrect
*
* @return 0 - this question type is never scored
* (non-PHPdoc)
* @see sites/all/modules/quiz-HEAD/question_types/quiz_question/AbstractQuizQuestionResponse#isCorrect()
*/
public function isCorrect() {
return TRUE;
}
/**
* Implementation of getResponse
*
* @return answer
*/
public function getResponse() {
return $this->answer;
}
/**
* Implementation of format report.
*
* @param $showpoints
* @param $showfeedback
* @return report as html
*/
public function formatReport($showpoints = TRUE, $showfeedback = TRUE) {
$slug = '<div class="quiz_summary_question"><span class="quiz_question_bullet">Q:</span> ' . check_markup($this->question->body, $this->question->format, FALSE) . '</div>';
$result = '<div class="quiz_answer_feedback">';
$result .= t('You answered:');
$result .= '<BR/>';
$result .= check_plain($this->answer);
$result .= '</div>';
return $slug . $result;
}
}