public function LongAnswerResponse::getFeedbackValues in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_long_answer/src/Plugin/quiz/QuizQuestion/LongAnswerResponse.php \Drupal\quiz_long_answer\Plugin\quiz\QuizQuestion\LongAnswerResponse::getFeedbackValues()
- 6.x question_types/quiz_long_answer/src/Plugin/quiz/QuizQuestion/LongAnswerResponse.php \Drupal\quiz_long_answer\Plugin\quiz\QuizQuestion\LongAnswerResponse::getFeedbackValues()
Get the response part of the report form.
Return value
array Array of response data, with each item being an answer to a response. For an example, see MultichoiceResponse::getFeedbackValues(). The sub items are keyed by the feedback type. Providing a NULL option means that feedback will not be shown. See an example at LongAnswerResponse::getFeedbackValues().
Overrides QuizResultAnswerEntityTrait::getFeedbackValues
File
- question_types/
quiz_long_answer/ src/ Plugin/ quiz/ QuizQuestion/ LongAnswerResponse.php, line 31
Class
- LongAnswerResponse
- Extension of QuizQuestionResponse.
Namespace
Drupal\quiz_long_answer\Plugin\quiz\QuizQuestionCode
public function getFeedbackValues() {
$data = array();
$score = $this
->getPoints();
$max = $this
->getMaxScore(FALSE);
if ($this->evaluated) {
// Question has been graded.
if ($score == 0) {
$icon = QuizUtil::icon('incorrect');
}
if ($score > 0) {
$icon = QuizUtil::icon('almost');
}
if ($score == $max) {
$icon = QuizUtil::icon('correct');
}
}
else {
$icon = QuizUtil::icon('unknown');
}
$rubric = !$this
->getQuizQuestion()
->get('long_answer_rubric')
->isEmpty() ? $this
->getQuizQuestion()
->get('long_answer_rubric')
->get(0)
->getValue() : NULL;
$answer_feedback = $this
->get('answer_feedback')
->get(0)
->getValue();
$user_answer = $this
->get('long_answer')
->get(0)
->getValue();
$data[] = array(
// Hide this column. Does not make sense for long answer as there are no
// choices.
'choice' => NULL,
'attempt' => is_array($user_answer) ? check_markup($user_answer['value'], $user_answer['format']) : $user_answer,
'correct' => $icon,
'score' => !$this
->isEvaluated() ? t('This answer has not yet been scored.') : $score,
'answer_feedback' => $answer_feedback ? check_markup($answer_feedback['value'], $answer_feedback['format']) : '',
'solution' => $rubric ? check_markup($rubric['value'], $rubric['format']) : '',
);
return $data;
}