MDL-53966 lesson: Allow maximum number of attempts to be unlimited
[moodle.git] / mod / lesson / pagetypes / multichoice.php
CommitLineData
0a4abb73
SH
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * Multichoice
20 *
9b24f68b 21 * @package mod_lesson
cc3dbaaa
PS
22 * @copyright 2009 Sam Hemelryk
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
0a4abb73
SH
24 **/
25
1e7f8ea2
PS
26defined('MOODLE_INTERNAL') || die();
27
0a4abb73
SH
28/** Multichoice question type */
29define("LESSON_PAGE_MULTICHOICE", "3");
30
31class lesson_page_type_multichoice extends lesson_page {
32
33 protected $type = lesson_page::TYPE_QUESTION;
34 protected $typeidstring = 'multichoice';
35 protected $typeid = LESSON_PAGE_MULTICHOICE;
36 protected $string = null;
37
38 public function get_typeid() {
39 return $this->typeid;
40 }
41 public function get_typestring() {
42 if ($this->string===null) {
43 $this->string = get_string($this->typeidstring, 'lesson');
44 }
45 return $this->string;
46 }
47 public function get_idstring() {
48 return $this->typeidstring;
49 }
50
a07dedff
PS
51 /**
52 * Gets an array of the jumps used by the answers of this page
53 *
54 * @return array
55 */
56 public function get_jumps() {
57 global $DB;
58 $jumps = array();
a07dedff
PS
59 if ($answers = $this->get_answers()) {
60 foreach ($answers as $answer) {
61 if ($answer->answer === '') {
62 // show only jumps for real branches (==have description)
63 continue;
64 }
65 $jumps[] = $this->get_jump_name($answer->jumpto);
66 }
9170dea7
SH
67 } else {
68 // We get here is the lesson was created on a Moodle 1.9 site and
69 // the lesson contains question pages without any answers.
70 $jumps[] = $this->get_jump_name($this->properties->nextpageid);
a07dedff
PS
71 }
72 return $jumps;
73 }
74
cc217823
PS
75 public function get_used_answers() {
76 $answers = $this->get_answers();
77 foreach ($answers as $key=>$answer) {
6eb2138a 78 if ($answer->answer === '') {
cc217823 79 unset($answers[$key]);
0abc18cf
JMV
80 } else {
81 $answers[$key] = parent::rewrite_answers_urls($answer);
cc217823
PS
82 }
83 }
84 return $answers;
85 }
86
0a4abb73
SH
87 public function display($renderer, $attempt) {
88 global $CFG, $PAGE;
cc217823 89 $answers = $this->get_used_answers();
0a4abb73
SH
90 shuffle($answers);
91 $action = $CFG->wwwroot.'/mod/lesson/continue.php';
ac3d7791 92 $params = array('answers'=>$answers, 'lessonid'=>$this->lesson->id, 'contents'=>$this->get_contents(), 'attempt'=>$attempt);
0a4abb73
SH
93 if ($this->properties->qoption) {
94 $mform = new lesson_display_answer_form_multichoice_multianswer($action, $params);
95 } else {
96 $mform = new lesson_display_answer_form_multichoice_singleanswer($action, $params);
97 }
98 $data = new stdClass;
99 $data->id = $PAGE->cm->id;
100 $data->pageid = $this->properties->id;
101 $mform->set_data($data);
8101328a
SB
102
103 // Trigger an event question viewed.
104 $eventparams = array(
105 'context' => context_module::instance($PAGE->cm->id),
106 'objectid' => $this->properties->id,
107 'other' => array(
108 'pagetype' => $this->get_typestring()
109 )
110 );
111
112 $event = \mod_lesson\event\question_viewed::create($eventparams);
113 $event->trigger();
0a4abb73
SH
114 return $mform->display();
115 }
116
117 public function check_answer() {
df0442c6 118 global $DB, $CFG, $PAGE;
0a4abb73
SH
119 $result = parent::check_answer();
120
39790bd8 121 $formattextdefoptions = new stdClass();
6eb2138a
PS
122 $formattextdefoptions->noclean = true;
123 $formattextdefoptions->para = false;
124
cc217823 125 $answers = $this->get_used_answers();
0a4abb73
SH
126 shuffle($answers);
127 $action = $CFG->wwwroot.'/mod/lesson/continue.php';
128 $params = array('answers'=>$answers, 'lessonid'=>$this->lesson->id, 'contents'=>$this->get_contents());
129 if ($this->properties->qoption) {
130 $mform = new lesson_display_answer_form_multichoice_multianswer($action, $params);
131 } else {
132 $mform = new lesson_display_answer_form_multichoice_singleanswer($action, $params);
133 }
134 $data = $mform->get_data();
135 require_sesskey();
136
137 if (!$data) {
8d674838
JL
138 $result->inmediatejump = true;
139 $result->newpageid = $this->properties->id;
140 return $result;
0a4abb73 141 }
2f67a9b3 142
0a4abb73 143 if ($this->properties->qoption) {
e231a3ff 144 // Multianswer allowed, user's answer is an array
0a4abb73
SH
145
146 if (empty($data->answer) || !is_array($data->answer)) {
147 $result->noanswer = true;
148 return $result;
149 }
150
6eb2138a
PS
151 $studentanswers = array();
152 foreach ($data->answer as $key=>$value) {
153 $studentanswers[] = (int)$key;
0a4abb73 154 }
2f67a9b3 155
0a4abb73
SH
156 // get what the user answered
157 $result->userresponse = implode(",", $studentanswers);
158
159 // get the answers in a set order, the id order
cc217823 160 $answers = $this->get_used_answers();
0a4abb73
SH
161 $ncorrect = 0;
162 $nhits = 0;
e053583f 163 $responses = array();
0a4abb73
SH
164 $correctanswerid = 0;
165 $wronganswerid = 0;
166 // store student's answers for displaying on feedback page
6eb2138a 167 $result->studentanswer = '';
c914c92d 168 $result->studentanswerformat = FORMAT_HTML;
0a4abb73 169 foreach ($answers as $answer) {
6eb2138a 170 foreach ($studentanswers as $answerid) {
0a4abb73 171 if ($answerid == $answer->id) {
7b319d20
MG
172 $studentanswerarray[] = format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
173 $responses[$answerid] = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
0a4abb73
SH
174 }
175 }
176 }
0e613a1f 177 $result->studentanswer = implode(self::MULTIANSWER_DELIMITER, $studentanswerarray);
64a3ce8c
PS
178 $correctpageid = null;
179 $wrongpageid = null;
0a4abb73 180
d5eefdb6
JL
181 // Iterate over all the possible answers.
182 foreach ($answers as $answer) {
183 if ($this->lesson->custom) {
184 $iscorrectanswer = $answer->score > 0;
185 } else {
186 $iscorrectanswer = $this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto);
187 }
188
189 // Iterate over all the student answers to check if he selected the current possible answer.
190 foreach ($studentanswers as $answerid) {
191 if ($answerid == $answer->id) {
192 if ($iscorrectanswer) {
193 $nhits++;
194 } else {
195 // Always jump to the page related to the student's first wrong answer.
196 if (!isset($wrongpageid)) {
197 // Leave in its "raw" state - will be converted into a proper page id later.
198 $wrongpageid = $answer->jumpto;
199 }
200 // Save the answer id for scoring.
201 if ($wronganswerid == 0) {
202 $wronganswerid = $answer->id;
0a4abb73 203 }
0a4abb73 204 }
0a4abb73
SH
205 }
206 }
d5eefdb6
JL
207
208 if ($iscorrectanswer) {
209 $ncorrect++;
210
211 // Save the first jumpto page id, may be needed!
212 if (!isset($correctpageid)) {
213 // Leave in its "raw" state - will be converted into a proper page id later.
214 $correctpageid = $answer->jumpto;
215 }
216 // Save the answer id for scoring.
217 if ($correctanswerid == 0) {
218 $correctanswerid = $answer->id;
0a4abb73
SH
219 }
220 }
221 }
d5eefdb6 222
0a4abb73
SH
223 if ((count($studentanswers) == $ncorrect) and ($nhits == $ncorrect)) {
224 $result->correctanswer = true;
0e613a1f 225 $result->response = implode(self::MULTIANSWER_DELIMITER, $responses);
0a4abb73
SH
226 $result->newpageid = $correctpageid;
227 $result->answerid = $correctanswerid;
228 } else {
0e613a1f 229 $result->response = implode(self::MULTIANSWER_DELIMITER, $responses);
0a4abb73
SH
230 $result->newpageid = $wrongpageid;
231 $result->answerid = $wronganswerid;
232 }
233 } else {
234 // only one answer allowed
dd30ae41 235 if (!isset($data->answerid) || (empty($data->answerid) && !is_int($data->answerid))) {
0a4abb73
SH
236 $result->noanswer = true;
237 return $result;
238 }
239 $result->answerid = $data->answerid;
240 if (!$answer = $DB->get_record("lesson_answers", array("id" => $result->answerid))) {
241 print_error("Continue: answer record not found");
242 }
0abc18cf 243 $answer = parent::rewrite_answers_urls($answer);
0a4abb73
SH
244 if ($this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto)) {
245 $result->correctanswer = true;
246 }
247 if ($this->lesson->custom) {
248 if ($answer->score > 0) {
249 $result->correctanswer = true;
250 } else {
251 $result->correctanswer = false;
252 }
253 }
254 $result->newpageid = $answer->jumpto;
01c37ef1 255 $result->response = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
ece2c44f 256 $result->userresponse = format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
5e110d86 257 $result->studentanswer = $result->userresponse;
0a4abb73
SH
258 }
259 return $result;
260 }
261
262 public function option_description_string() {
263 if ($this->properties->qoption) {
264 return " - ".get_string("multianswer", "lesson");
265 }
266 return parent::option_description_string();
267 }
268
269 public function display_answers(html_table $table) {
cc217823 270 $answers = $this->get_used_answers();
0a4abb73
SH
271 $options = new stdClass;
272 $options->noclean = true;
273 $options->para = false;
274 $i = 1;
275 foreach ($answers as $answer) {
0abc18cf 276 $answer = parent::rewrite_answers_urls($answer);
0a4abb73
SH
277 $cells = array();
278 if ($this->lesson->custom && $answer->score > 0) {
279 // if the score is > 0, then it is correct
195480e9 280 $cells[] = '<label class="correct">' . get_string('answer', 'lesson') . " {$i}</label>: \n";
0a4abb73 281 } else if ($this->lesson->custom) {
195480e9 282 $cells[] = '<label>' . get_string('answer', 'lesson') . " {$i}</label>: \n";
0a4abb73
SH
283 } else if ($this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto)) {
284 // underline correct answers
195480e9 285 $cells[] = '<span class="correct">' . get_string('answer', 'lesson') . " {$i}</span>: \n";
0a4abb73 286 } else {
195480e9 287 $cells[] = '<label class="correct">' . get_string('answer', 'lesson') . " {$i}</label>: \n";
0a4abb73 288 }
01c37ef1 289 $cells[] = format_text($answer->answer, $answer->answerformat, $options);
8cea545e 290 $table->data[] = new html_table_row($cells);
0a4abb73
SH
291
292 $cells = array();
195480e9 293 $cells[] = '<label>' . get_string('response', 'lesson') . " {$i} </label>:\n";
01c37ef1 294 $cells[] = format_text($answer->response, $answer->responseformat, $options);
8cea545e 295 $table->data[] = new html_table_row($cells);
2f67a9b3 296
0a4abb73 297 $cells = array();
195480e9 298 $cells[] = '<label>' . get_string('score', 'lesson') . '</label>:';
0a4abb73 299 $cells[] = $answer->score;
8cea545e 300 $table->data[] = new html_table_row($cells);
0a4abb73
SH
301
302 $cells = array();
195480e9 303 $cells[] = '<label>' . get_string('jump', 'lesson') . '</label>:';
0a4abb73 304 $cells[] = $this->get_jump_name($answer->jumpto);
8cea545e 305 $table->data[] = new html_table_row($cells);
0a4abb73
SH
306 if ($i === 1){
307 $table->data[count($table->data)-1]->cells[0]->style = 'width:20%;';
308 }
309 $i++;
310 }
311 return $table;
312 }
313 public function stats(array &$pagestats, $tries) {
252e85be 314 $temp = $this->lesson->get_last_attempt($tries);
0a4abb73
SH
315 if ($this->properties->qoption) {
316 $userresponse = explode(",", $temp->useranswer);
317 foreach ($userresponse as $response) {
318 if (isset($pagestats[$temp->pageid][$response])) {
319 $pagestats[$temp->pageid][$response]++;
320 } else {
321 $pagestats[$temp->pageid][$response] = 1;
322 }
323 }
324 } else {
325 if (isset($pagestats[$temp->pageid][$temp->answerid])) {
326 $pagestats[$temp->pageid][$temp->answerid]++;
327 } else {
328 $pagestats[$temp->pageid][$temp->answerid] = 1;
329 }
330 }
331 if (isset($pagestats[$temp->pageid]["total"])) {
332 $pagestats[$temp->pageid]["total"]++;
333 } else {
334 $pagestats[$temp->pageid]["total"] = 1;
335 }
336 return true;
337 }
338
339 public function report_answers($answerpage, $answerdata, $useranswer, $pagestats, &$i, &$n) {
cc217823 340 $answers = $this->get_used_answers();
0a4abb73
SH
341 $formattextdefoptions = new stdClass;
342 $formattextdefoptions->para = false; //I'll use it widely in this page
59f1c9f5 343 $formattextdefoptions->context = $answerpage->context;
367a75fa 344
0a4abb73
SH
345 foreach ($answers as $answer) {
346 if ($this->properties->qoption) {
ecea65ca 347 if ($useranswer == null) {
0a4abb73
SH
348 $userresponse = array();
349 } else {
350 $userresponse = explode(",", $useranswer->useranswer);
351 }
352 if (in_array($answer->id, $userresponse)) {
353 // make checked
354 $data = "<input readonly=\"readonly\" disabled=\"disabled\" name=\"answer[$i]\" checked=\"checked\" type=\"checkbox\" value=\"1\" />";
355 if (!isset($answerdata->response)) {
ecea65ca 356 if ($answer->response == null) {
0a4abb73
SH
357 if ($useranswer->correct) {
358 $answerdata->response = get_string("thatsthecorrectanswer", "lesson");
359 } else {
360 $answerdata->response = get_string("thatsthewronganswer", "lesson");
361 }
362 } else {
363 $answerdata->response = $answer->response;
364 }
365 }
366 if (!isset($answerdata->score)) {
367 if ($this->lesson->custom) {
368 $answerdata->score = get_string("pointsearned", "lesson").": ".$answer->score;
369 } elseif ($useranswer->correct) {
370 $answerdata->score = get_string("receivedcredit", "lesson");
371 } else {
372 $answerdata->score = get_string("didnotreceivecredit", "lesson");
373 }
374 }
375 } else {
376 // unchecked
377 $data = "<input type=\"checkbox\" readonly=\"readonly\" name=\"answer[$i]\" value=\"0\" disabled=\"disabled\" />";
378 }
379 if (($answer->score > 0 && $this->lesson->custom) || ($this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto) && !$this->lesson->custom)) {
01c37ef1 380 $data = "<div class=highlight>".$data.' '.format_text($answer->answer,$answer->answerformat,$formattextdefoptions)."</div>";
0a4abb73 381 } else {
01c37ef1 382 $data .= format_text($answer->answer,$answer->answerformat,$formattextdefoptions);
0a4abb73
SH
383 }
384 } else {
ecea65ca 385 if ($useranswer != null and $answer->id == $useranswer->answerid) {
0a4abb73
SH
386 // make checked
387 $data = "<input readonly=\"readonly\" disabled=\"disabled\" name=\"answer[$i]\" checked=\"checked\" type=\"checkbox\" value=\"1\" />";
ecea65ca 388 if ($answer->response == null) {
0a4abb73
SH
389 if ($useranswer->correct) {
390 $answerdata->response = get_string("thatsthecorrectanswer", "lesson");
391 } else {
392 $answerdata->response = get_string("thatsthewronganswer", "lesson");
393 }
394 } else {
395 $answerdata->response = $answer->response;
396 }
397 if ($this->lesson->custom) {
398 $answerdata->score = get_string("pointsearned", "lesson").": ".$answer->score;
399 } elseif ($useranswer->correct) {
400 $answerdata->score = get_string("receivedcredit", "lesson");
401 } else {
402 $answerdata->score = get_string("didnotreceivecredit", "lesson");
403 }
404 } else {
405 // unchecked
406 $data = "<input type=\"checkbox\" readonly=\"readonly\" name=\"answer[$i]\" value=\"0\" disabled=\"disabled\" />";
407 }
408 if (($answer->score > 0 && $this->lesson->custom) || ($this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto) && !$this->lesson->custom)) {
409 $data = "<div class=\"highlight\">".$data.' '.format_text($answer->answer,FORMAT_MOODLE,$formattextdefoptions)."</div>";
410 } else {
01c37ef1 411 $data .= format_text($answer->answer,$answer->answerformat,$formattextdefoptions);
0a4abb73
SH
412 }
413 }
414 if (isset($pagestats[$this->properties->id][$answer->id])) {
415 $percent = $pagestats[$this->properties->id][$answer->id] / $pagestats[$this->properties->id]["total"] * 100;
416 $percent = round($percent, 2);
417 $percent .= "% ".get_string("checkedthisone", "lesson");
418 } else {
419 $percent = get_string("noonecheckedthis", "lesson");
420 }
421
422 $answerdata->answers[] = array($data, $percent);
423 $answerpage->answerdata = $answerdata;
424 }
425 return $answerpage;
426 }
427}
428
429
430class lesson_add_page_form_multichoice extends lesson_add_page_form_base {
431
432 public $qtype = 'multichoice';
433 public $qtypestring = 'multichoice';
ceeab150
RT
434 protected $answerformat = LESSON_ANSWER_HTML;
435 protected $responseformat = LESSON_ANSWER_HTML;
0a4abb73
SH
436
437 public function custom_definition() {
438
439 $this->_form->addElement('checkbox', 'qoption', get_string('options', 'lesson'), get_string('multianswer', 'lesson'));
fbda6256 440 $this->_form->setDefault('qoption', 0);
4c80a990 441 $this->_form->addHelpButton('qoption', 'multianswer', 'lesson');
0a4abb73
SH
442
443 for ($i = 0; $i < $this->_customdata['lesson']->maxanswers; $i++) {
444 $this->_form->addElement('header', 'answertitle'.$i, get_string('answer').' '.($i+1));
ceeab150 445 $this->add_answer($i, null, ($i<2), $this->get_answer_format());
0a4abb73 446 $this->add_response($i);
ecea65ca 447 $this->add_jumpto($i, null, ($i == 0 ? LESSON_NEXTPAGE : LESSON_THISPAGE));
0a4abb73
SH
448 $this->add_score($i, null, ($i===0)?1:0);
449 }
450 }
451}
452
453class lesson_display_answer_form_multichoice_singleanswer extends moodleform {
454
455 public function definition() {
456 global $USER, $OUTPUT;
457 $mform = $this->_form;
458 $answers = $this->_customdata['answers'];
459 $lessonid = $this->_customdata['lessonid'];
460 $contents = $this->_customdata['contents'];
ac3d7791
AB
461 if (array_key_exists('attempt', $this->_customdata)) {
462 $attempt = $this->_customdata['attempt'];
1112c9ed
AB
463 } else {
464 $attempt = new stdClass();
465 $attempt->answerid = null;
ac3d7791 466 }
ffdf7f8a 467
5b0af6e4
JMV
468 // Disable shortforms.
469 $mform->setDisableShortforms();
470
ffdf7f8a
DM
471 $mform->addElement('header', 'pageheader');
472
473 $mform->addElement('html', $OUTPUT->container($contents, 'contents'));
0a4abb73 474
abd5c24e
RW
475 $hasattempt = false;
476 $disabled = '';
477 if (isset($USER->modattempts[$lessonid]) && !empty($USER->modattempts[$lessonid])) {
478 $hasattempt = true;
479 $disabled = array('disabled' => 'disabled');
480 }
481
0a4abb73
SH
482 $options = new stdClass;
483 $options->para = false;
484 $options->noclean = true;
485
486 $mform->addElement('hidden', 'id');
487 $mform->setType('id', PARAM_INT);
488
489 $mform->addElement('hidden', 'pageid');
490 $mform->setType('pageid', PARAM_INT);
491
492 $i = 0;
493 foreach ($answers as $answer) {
494 $mform->addElement('html', '<div class="answeroption">');
c3af87ac 495 $answer->answer = preg_replace('#>$#', '> ', $answer->answer);
abd5c24e 496 $mform->addElement('radio','answerid',null,format_text($answer->answer, $answer->answerformat, $options),$answer->id, $disabled);
0a4abb73 497 $mform->setType('answer'.$i, PARAM_INT);
abd5c24e 498 if ($hasattempt && $answer->id == $USER->modattempts[$lessonid]->answerid) {
57a4bd03 499 $mform->setDefault('answerid', $USER->modattempts[$lessonid]->answerid);
0a4abb73
SH
500 }
501 $mform->addElement('html', '</div>');
502 $i++;
503 }
504
abd5c24e
RW
505 if ($hasattempt) {
506 $this->add_action_buttons(null, get_string("nextpage", "lesson"));
507 } else {
508 $this->add_action_buttons(null, get_string("submit", "lesson"));
509 }
0a4abb73
SH
510 }
511
512}
513
514class lesson_display_answer_form_multichoice_multianswer extends moodleform {
515
516 public function definition() {
517 global $USER, $OUTPUT;
518 $mform = $this->_form;
519 $answers = $this->_customdata['answers'];
6eb2138a 520
0a4abb73
SH
521 $lessonid = $this->_customdata['lessonid'];
522 $contents = $this->_customdata['contents'];
523
5b0af6e4
JMV
524 // Disable shortforms.
525 $mform->setDisableShortforms();
526
ffdf7f8a
DM
527 $mform->addElement('header', 'pageheader');
528
529 $mform->addElement('html', $OUTPUT->container($contents, 'contents'));
0a4abb73 530
54fd7cd9
RW
531 $hasattempt = false;
532 $disabled = '';
533 $useranswers = array();
534 if (isset($USER->modattempts[$lessonid]) && !empty($USER->modattempts[$lessonid])) {
535 $hasattempt = true;
536 $disabled = array('disabled' => 'disabled');
537 $useranswers = explode(',', $USER->modattempts[$lessonid]->useranswer);
538 }
539
0a4abb73
SH
540 $options = new stdClass;
541 $options->para = false;
542 $options->noclean = true;
543
544 $mform->addElement('hidden', 'id');
545 $mform->setType('id', PARAM_INT);
546
547 $mform->addElement('hidden', 'pageid');
548 $mform->setType('pageid', PARAM_INT);
549
0a4abb73
SH
550 foreach ($answers as $answer) {
551 $mform->addElement('html', '<div class="answeroption">');
54fd7cd9
RW
552 $answerid = 'answer['.$answer->id.']';
553 if ($hasattempt && in_array($answer->id, $useranswers)) {
554 $answerid = 'answer_'.$answer->id;
555 $mform->addElement('hidden', 'answer['.$answer->id.']', $answer->answer);
f2a41c51 556 $mform->setType('answer['.$answer->id.']', PARAM_NOTAGS);
54fd7cd9 557 $mform->setDefault($answerid, true);
6eb2138a 558 $mform->setDefault('answer['.$answer->id.']', true);
0a4abb73 559 }
54fd7cd9 560 // NOTE: our silly checkbox supports only value '1' - we can not use it like the radiobox above!!!!!!
c3af87ac 561 $answer->answer = preg_replace('#>$#', '> ', $answer->answer);
54fd7cd9
RW
562 $mform->addElement('checkbox', $answerid, null, format_text($answer->answer, $answer->answerformat, $options), $disabled);
563 $mform->setType($answerid, PARAM_INT);
564
0a4abb73 565 $mform->addElement('html', '</div>');
0a4abb73
SH
566 }
567
54fd7cd9
RW
568 if ($hasattempt) {
569 $this->add_action_buttons(null, get_string("nextpage", "lesson"));
570 } else {
571 $this->add_action_buttons(null, get_string("submit", "lesson"));
572 }
0a4abb73
SH
573 }
574
4c80a990 575}