lesson MDL-23525 more bugs fixed to pagetypes.
[moodle.git] / mod / lesson / pagetypes / multichoice.php
index b71bf89..0b9de02 100644 (file)
@@ -475,6 +475,9 @@ class lesson_display_answer_form_multichoice_singleanswer extends moodleform {
         $contents = $this->_customdata['contents'];
         if (array_key_exists('attempt', $this->_customdata)) {
             $attempt = $this->_customdata['attempt'];
+        } else {
+            $attempt = new stdClass();
+            $attempt->answerid = null;
         }
         $mform->addElement('header', 'pageheader', $OUTPUT->box($contents, 'contents'));
 
@@ -493,7 +496,7 @@ class lesson_display_answer_form_multichoice_singleanswer extends moodleform {
             $mform->addElement('html', '<div class="answeroption">');
             $mform->addElement('radio','answerid',null,format_text($answer->answer, $answer->answerformat, $options),$answer->id);
             $mform->setType('answer'.$i, PARAM_INT);
-            if (isset($USER->modattempts[$lessonid]) && array_key_exists('attempt', $this->_customdata) && $answer->id == $attempt->answerid) {
+            if (isset($USER->modattempts[$lessonid]) && $answer->id == $attempt->answerid) {
                 $mform->setDefault('answerid', true);
             }
             $mform->addElement('html', '</div>');