public function TrueFalseResponse::getFeedbackValues in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_truefalse/src/Plugin/quiz/QuizQuestion/TrueFalseResponse.php \Drupal\quiz_truefalse\Plugin\quiz\QuizQuestion\TrueFalseResponse::getFeedbackValues()
- 6.x question_types/quiz_truefalse/src/Plugin/quiz/QuizQuestion/TrueFalseResponse.php \Drupal\quiz_truefalse\Plugin\quiz\QuizQuestion\TrueFalseResponse::getFeedbackValues()
Implementation of getFeedbackValues().
Overrides QuizResultAnswerEntityTrait::getFeedbackValues
See also
QuizQuestionResponse::getFeedbackValues()
File
- question_types/
quiz_truefalse/ src/ Plugin/ quiz/ QuizQuestion/ TrueFalseResponse.php, line 44
Class
- TrueFalseResponse
- Extension of QuizQuestionResponse.
Namespace
Drupal\quiz_truefalse\Plugin\quiz\QuizQuestionCode
public function getFeedbackValues() {
$answer = $this
->getResponse();
if (is_numeric($answer)) {
$answer = intval($answer);
}
$correct_answer = intval($this
->getQuizQuestion()
->getCorrectAnswer());
$data = array();
$data[] = array(
'choice' => t('True'),
'attempt' => $answer === 1 ? QuizUtil::icon('selected') : '',
'correct' => $answer === 1 ? QuizUtil::icon($correct_answer ? 'correct' : 'incorrect') : '',
'score' => intval($correct_answer === 1 && $answer === 1),
'answer_feedback' => '',
'solution' => $correct_answer === 1 ? QuizUtil::icon('should') : '',
);
$data[] = array(
'choice' => t('False'),
'attempt' => $answer === 0 ? QuizUtil::icon('selected') : '',
'correct' => $answer === 0 ? QuizUtil::icon(!$correct_answer ? 'correct' : 'incorrect') : '',
'score' => intval($correct_answer === 0 && $answer === 0),
'answer_feedback' => '',
'solution' => $correct_answer === 0 ? QuizUtil::icon('should') : '',
);
return $data;
}