Skip to content

Commit

Permalink
feat: render correct answer from initial content in graphical answer
Browse files Browse the repository at this point in the history
  • Loading branch information
Pol Torrent i Soler committed Sep 14, 2023
1 parent 24719b7 commit 8c61451
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ public function correct_response(question_attempt $qa) {
if (!$answer) {
return '';
}

$slots = $qa->get_question()->wirisquestion->question->getSlots();
$initialcontent = isset($slots[0]) ? $slots[0]->getInitialContent() : null;

$wrap = com_wiris_system_CallWrapper::getInstance();
$wrap->start();
$filterableanswer = com_wiris_quizzes_impl_QuizzesImpl::getInstance()->answerToFilterableValue($answer['answer']);
$filterableanswer = com_wiris_quizzes_impl_QuizzesImpl::getInstance()->answerToFilterableValue($answer['answer'], $initialcontent);
$wrap->stop();
$text = get_string('correctansweris', 'qtype_shortanswer', $filterableanswer);
return $question->format_text($text, FORMAT_HTML, $qa, 'question', 'correctanswer', $question->id);
Expand Down

0 comments on commit 8c61451

Please sign in to comment.