class ScaleResponse in Quiz 7.5
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.6 question_types/scale/scale.classes.inc \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
Extension of QuizQuestionResponse.
Hierarchy
- class \QuizQuestionResponse
- class \ScaleResponse
Expanded class hierarchy of ScaleResponse
1 string reference to 'ScaleResponse'
- scale_quiz_question_info in question_types/
scale/ scale.module - Implements hook_quiz_question_info().
File
- question_types/
scale/ scale.classes.inc, line 566 - Scale classes.
View source
class ScaleResponse extends QuizQuestionResponse {
/**
* ID of the answer.
*/
protected $answer_id = 0;
/**
* Constructor.
*
* @param int $result_id
* The result ID for the user's result set. There is one result ID per time
* the user takes a quiz.
* @param stdClass $question_node
* The question node.
* @param mixed $answer
* The answer (dependent on question type).
*/
public function __construct($result_id, stdClass $question_node, $answer = NULL) {
parent::__construct($result_id, $question_node, $answer);
if (isset($answer)) {
$this->answer_id = intval($answer);
}
else {
$this->answer_id = db_query('SELECT answer_id FROM {quiz_scale_user_answers} WHERE result_answer_id = :raid', array(
':raid' => $this->result_answer_id,
))
->fetchField();
}
$answer = db_query('SELECT answer FROM {quiz_scale_answer} WHERE id = :id', array(
':id' => $this->answer_id,
))
->fetchField();
$this->answer = check_plain($answer);
}
/**
* Implementation of save().
*
* @see QuizQuestionResponse::save()
*/
public function save() {
db_merge('quiz_scale_user_answers')
->key(array(
'result_answer_id' => $this->result_answer_id,
))
->fields(array(
'answer_id' => $this->answer_id,
'result_answer_id' => $this->result_answer_id,
))
->execute();
}
/**
* Implementation of delete().
*
* @see QuizQuestionResponse::delete()
*/
public function delete() {
db_delete('quiz_scale_user_answers')
->condition('result_answer_id', $this->result_answer_id)
->execute();
}
/**
* Implementation of score().
*
* @see QuizQuestionResponse::score()
*/
public function score() {
return (bool) $this
->getResponse();
}
/**
* Implementation of getResponse().
*
* @see QuizQuestionResponse::getResponse()
*/
public function getResponse() {
return $this->answer_id;
}
/**
* Implementation of getFeedbackValues().
*
* @see QuizQuestionResponse::getFeedbackValues()
*/
public function getFeedbackValues() {
$data = array();
$data[] = array(
'choice' => $this->answer,
);
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
QuizQuestionResponse:: |
protected | property | ||
QuizQuestionResponse:: |
protected | property | ||
QuizQuestionResponse:: |
protected | property | ||
QuizQuestionResponse:: |
public | property | ||
QuizQuestionResponse:: |
public | property | ||
QuizQuestionResponse:: |
public | property | ||
QuizQuestionResponse:: |
public | property | ||
QuizQuestionResponse:: |
protected | property | ||
QuizQuestionResponse:: |
protected | property | 9 | |
QuizQuestionResponse:: |
public | function | Can the quiz taker view the requested review? | |
QuizQuestionResponse:: |
protected | function | Utility function that returns the format of the node body. | |
QuizQuestionResponse:: |
public | function | Get the max score of this question response. | 1 |
QuizQuestionResponse:: |
public | function | Get the question of this question response. | |
QuizQuestionResponse:: |
public | function | Get data suitable for reporting a user's score on the question. | 1 |
QuizQuestionResponse:: |
public | function | Creates the report form for the admin pages, and for when a user gets feedback after answering questions. | 2 |
QuizQuestionResponse:: |
public | function | Get the feedback form for the reportForm. | 2 |
QuizQuestionResponse:: |
public | function | Implementation of getReportFormScore(). | |
QuizQuestionResponse:: |
public | function | Get the submit function for the reportForm. | 2 |
QuizQuestionResponse:: |
public | function | Get the validate function for the reportForm. | |
QuizQuestionResponse:: |
public | function | Get the score of this question response. | |
QuizQuestionResponse:: |
public | function | Get the weighted score ratio. | |
QuizQuestionResponse:: |
public | function | Check to see if the answer is marked as correct. | 2 |
QuizQuestionResponse:: |
public | function | Indicate whether the response has been evaluated (scored) yet. | |
QuizQuestionResponse:: |
public | function | Used to refresh this instances question node in case drupal has changed it. | |
QuizQuestionResponse:: |
public | function | Set the target result answer ID for this Question response. | |
QuizQuestionResponse:: |
public | function | Represent the response as a stdClass object. | |
QuizQuestionResponse:: |
public static | function | Get answers for a question in a result. | 3 |
ScaleResponse:: |
protected | property | ID of the answer. | |
ScaleResponse:: |
public | function |
Implementation of delete(). Overrides QuizQuestionResponse:: |
|
ScaleResponse:: |
public | function |
Implementation of getFeedbackValues(). Overrides QuizQuestionResponse:: |
|
ScaleResponse:: |
public | function |
Implementation of getResponse(). Overrides QuizQuestionResponse:: |
|
ScaleResponse:: |
public | function |
Implementation of save(). Overrides QuizQuestionResponse:: |
|
ScaleResponse:: |
public | function |
Implementation of score(). Overrides QuizQuestionResponse:: |
|
ScaleResponse:: |
public | function |
Constructor. Overrides QuizQuestionResponse:: |