From 1112c9ed4e26c7b7229577811a9a5244696c0298 Mon Sep 17 00:00:00 2001 From: Aparup Banerjee Date: Fri, 6 Aug 2010 08:16:08 +0000 Subject: [PATCH] lesson MDL-23525 more bugs fixed to pagetypes. --- mod/lesson/pagetypes/multichoice.php | 5 ++++- mod/lesson/pagetypes/truefalse.php | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mod/lesson/pagetypes/multichoice.php b/mod/lesson/pagetypes/multichoice.php index b71bf89085e..0b9de02826b 100644 --- a/mod/lesson/pagetypes/multichoice.php +++ b/mod/lesson/pagetypes/multichoice.php @@ -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', '
'); $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', '
'); diff --git a/mod/lesson/pagetypes/truefalse.php b/mod/lesson/pagetypes/truefalse.php index c68eb4863c6..11e81cce8ac 100644 --- a/mod/lesson/pagetypes/truefalse.php +++ b/mod/lesson/pagetypes/truefalse.php @@ -53,7 +53,7 @@ class lesson_page_type_truefalse extends lesson_page { $answers = $this->get_answers(); shuffle($answers); - $params = array('answers'=>$answers, 'lessonid'=>$this->lesson->id, 'contents'=>$this->get_contents()); + $params = array('answers'=>$answers, 'lessonid'=>$this->lesson->id, 'contents'=>$this->get_contents(), 'attempt'=>$attempt); $mform = new lesson_display_answer_form_truefalse($CFG->wwwroot.'/mod/lesson/continue.php', $params); $data = new stdClass; $data->id = $PAGE->cm->id; @@ -177,7 +177,7 @@ class lesson_page_type_truefalse extends lesson_page { public function report_answers($answerpage, $answerdata, $useranswer, $pagestats, &$i, &$n) { $answers = $this->get_answers(); - $formattextdefoptions = new obejct(); //I'll use it widely in this page + $formattextdefoptions = new object(); //I'll use it widely in this page $formattextdefoptions->para = false; $formattextdefoptions->noclean = true; foreach ($answers as $answer) { @@ -292,6 +292,12 @@ class lesson_display_answer_form_truefalse extends moodleform { $answers = $this->_customdata['answers']; $lessonid = $this->_customdata['lessonid']; $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'));