-
Bug
-
Resolution: Fixed
-
Major
-
4.1.6, 4.1.7, 4.2.3, 4.3.1
Context
Moodle 4.1.6+
Mysql 5.7
In a lesson activity, add a page with a matching question type.
There is no possibility to go on selecting the correct answers.
I think it is a collateral effect of applying MDL-78481, about filters.
Problem
I have identified missing code that adds this HTML to the answer from the user div class="text_to_html">expected answer</div>, instead of simply expected answer (for the sake of an example).
Expected
The user, when selecting correct answers, can go on with the lesson activity.
Proposed patch
There is similar fragment working later on on the same file mod/lesson/pagetypes/matching.php, where the method set ups the properties for the format_text() function, like format_text(trim($answer->response), $answer->answerformat, $formattextdefoptions);. Instead, prior to this case, the user answer is processed without them, producing the unexpected incorrect behaviour of the patch.
The final code results on this:
|
$formattextdefoptions = new stdClass();
$formattextdefoptions->noclean = true;
$formattextdefoptions->para = false;
$responses = array();
foreach ($answers as $answer) {
// get all the response
if ($answer->response != null)
}
code}
and the diff is:
--- a/mod/lesson/pagetypes/matching.php
|
+++ b/mod/lesson/pagetypes/matching.php
|
@@ -79,11 +79,15 @@ class lesson_page_type_matching extends lesson_page {
|
$answers[$getanswer->id] = $getanswer;
|
}
|
|
+ $formattextdefoptions = new stdClass();
|
+ $formattextdefoptions->noclean = true;
|
+ $formattextdefoptions->para = false;
|
+
|
$responses = array();
|
foreach ($answers as $answer) {
|
// get all the response
|
if ($answer->response != null) {
|
- $responses[] = format_text(trim($answer->response));
|
+ $responses[] = format_text(trim($answer->response), $answer->answerformat, $formattextdefoptions);
|
}
|
}
|
|
|
With this patch, the matching question page on the lesson activity works properly.