From f540540b9e09a09f901bc42c0756fc58462461cb Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 3 Nov 2021 11:30:01 +0800 Subject: [PATCH] MDL-72672 lesson: add label for multichoice checkboxes --- mod/lesson/pagetypes/multichoice.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mod/lesson/pagetypes/multichoice.php b/mod/lesson/pagetypes/multichoice.php index 232add56eae..1ca091211f0 100644 --- a/mod/lesson/pagetypes/multichoice.php +++ b/mod/lesson/pagetypes/multichoice.php @@ -351,7 +351,7 @@ class lesson_page_type_multichoice extends lesson_page { } if (in_array($answer->id, $userresponse)) { // make checked - $data = ""; + $checkboxelement = ""; if (!isset($answerdata->response)) { if ($answer->response == null) { if ($useranswer->correct) { @@ -374,17 +374,19 @@ class lesson_page_type_multichoice extends lesson_page { } } else { // unchecked - $data = ""; + $checkboxelement = ""; } if (($answer->score > 0 && $this->lesson->custom) || ($this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto) && !$this->lesson->custom)) { - $data = "
".$data.' '.format_text($answer->answer,$answer->answerformat,$formattextdefoptions)."
"; + $answertext = $checkboxelement . format_text($answer->answer, $answer->answerformat, $formattextdefoptions); + $data = "
"; } else { - $data .= format_text($answer->answer,$answer->answerformat,$formattextdefoptions); + $answertext = $checkboxelement . format_text($answer->answer, $answer->answerformat, $formattextdefoptions); + $data = ""; } } else { if ($useranswer != null and $answer->id == $useranswer->answerid) { // make checked - $data = ""; + $checkboxelement = ""; if ($answer->response == null) { if ($useranswer->correct) { $answerdata->response = get_string("thatsthecorrectanswer", "lesson"); @@ -403,12 +405,14 @@ class lesson_page_type_multichoice extends lesson_page { } } else { // unchecked - $data = ""; + $checkboxelement = ""; } if (($answer->score > 0 && $this->lesson->custom) || ($this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto) && !$this->lesson->custom)) { - $data = "
".$data.' '.format_text($answer->answer,FORMAT_MOODLE,$formattextdefoptions)."
"; + $answertext = $checkboxelement . format_text($answer->answer, FORMAT_MOODLE, $formattextdefoptions); + $data = "
"; } else { - $data .= format_text($answer->answer,$answer->answerformat,$formattextdefoptions); + $answertext = $checkboxelement . format_text($answer->answer, $answer->answerformat, $formattextdefoptions); + $data = ""; } } if (isset($pagestats[$this->properties->id][$answer->id])) {