From fc18f5308a8d1f8a51703d7fdc7d2240b391c3ac Mon Sep 17 00:00:00 2001 From: Pol Torrent Date: Thu, 6 May 2021 17:19:17 +0200 Subject: [PATCH] Propagates answer field type in cloze questions --- question.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/question.php b/question.php index 3e4e38b..8ba5e95 100644 --- a/question.php +++ b/question.php @@ -133,6 +133,14 @@ private function set_shortanswer_matching_answers(array $response) { $qimpl->setAssertion("equivalent_symbolic", 0, 0); } + // Since we are generating all the slots artificially by cloning the first one, + // set its answer field type as the default for the question. + $slots = $qimpl->slots; + if ($slots != null && isset($slots[0])) { + $answerFieldType = $slots[0]->getAnswerFieldType(); + $qimpl->setAnswerFieldType($answerFieldType); + } + // Remove all non-syntactic assertions from question and save to $assertions array. for ($i = $qimpl->assertions->length - 1; $i >= 0; $i--) { $assertion = $qimpl->assertions[$i];