Index: mod/lesson/edit.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/lesson/edit.php,v retrieving revision 1.28 diff -u -B -r1.28 edit.php --- mod/lesson/edit.php 16 Jan 2010 15:40:01 -0000 1.28 +++ mod/lesson/edit.php 28 Jun 2010 08:32:49 -0000 @@ -69,4 +69,4 @@ } } -echo $lessonoutput->footer(); \ No newline at end of file +echo $lessonoutput->footer(); Index: mod/lesson/editpage.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/lesson/editpage.php,v retrieving revision 1.6 diff -u -B -r1.6 editpage.php --- mod/lesson/editpage.php 16 Jan 2010 15:40:02 -0000 1.6 +++ mod/lesson/editpage.php 28 Jun 2010 08:32:49 -0000 @@ -63,6 +63,7 @@ $properties = $editpage->properties(); $properties->pageid = $editpage->id; $properties->id = $cm->id; + $properties->contentsformat = FORMAT_HTML; $mform->set_data($properties, $context, $editpage->id); $PAGE->navbar->add(get_string('edit'), new moodle_url('/mod/lesson/edit.php', array('id'=>$id))); $PAGE->navbar->add(get_string('editingquestionpage', 'lesson', get_string($mform->qtypestring, 'lesson'))); @@ -101,4 +102,4 @@ $lessonoutput = $PAGE->get_renderer('mod_lesson'); echo $lessonoutput->header($lesson, $cm); $mform->display(); -echo $lessonoutput->footer(); \ No newline at end of file +echo $lessonoutput->footer(); Index: mod/lesson/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/lesson/lib.php,v retrieving revision 1.92 diff -u -B -r1.92 lib.php --- mod/lesson/lib.php 22 May 2010 13:54:42 -0000 1.92 +++ mod/lesson/lib.php 28 Jun 2010 08:32:50 -0000 @@ -2007,7 +2007,8 @@ $this->answers = array(); $answers = $DB->get_records('lesson_answers', array('pageid'=>$this->properties->id, 'lessonid'=>$this->lesson->id), 'id'); if (!$answers) { - print_error('cannotfindanswer', 'lesson'); + //print_error('cannotfindanswer', 'lesson'); + return array(); } foreach ($answers as $answer) { $this->answers[count($this->answers)] = new lesson_page_answer($answer); @@ -2233,14 +2234,17 @@ * @param object $properties * @return bool */ - public function update($properties,$context, $maxbytes) { - global $DB; + public function update($properties, $context = null, $maxbytes = -1) { + global $DB, $PAGE; $answers = $this->get_answers(); $properties->id = $this->properties->id; $properties->lessonid = $this->lesson->id; if (empty($properties->qoption)) { $properties->qoption = '0'; } + if (empty($context)) { + $context = $PAGE->context; + } $properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$maxbytes), $context, 'lesson_page_contents', $properties->id); $DB->update_record("lesson_pages", $properties); Index: mod/lesson/view.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/lesson/view.php,v retrieving revision 1.172 diff -u -B -r1.172 view.php --- mod/lesson/view.php 3 May 2010 17:35:21 -0000 1.172 +++ mod/lesson/view.php 28 Jun 2010 08:32:50 -0000 @@ -354,14 +354,13 @@ } $lessoncontent = $lessonoutput->display_page($lesson, $page, $attempt); } else { - - $nextpage = $lesson->get_next_page($page->nextpageid); - $data = new stdClass; $data->id = $PAGE->cm->id; - $data->newpageid = $nextpage->id; + if ($nextpage = $lesson->get_next_page($page->nextpageid)) { + $data->newpageid = $nextpage->id; + } - $mform = lesson_page_without_answers(); + $mform = new lesson_page_without_answers(); $mform->set_data($data); ob_start(); $mform->display(); Index: mod/lesson/pagetypes/branchtable.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/lesson/pagetypes/branchtable.php,v retrieving revision 1.7 diff -u -B -r1.7 branchtable.php --- mod/lesson/pagetypes/branchtable.php 17 Feb 2010 19:33:25 -0000 1.7 +++ mod/lesson/pagetypes/branchtable.php 28 Jun 2010 08:32:50 -0000 @@ -270,6 +270,7 @@ $mform->addElement('text', 'title', get_string("pagetitle", "lesson"), array('size'=>70)); $mform->setType('title', PARAM_TEXT); + $mform->addRule('title', null, 'required', null, 'server'); $this->editoroptions = array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes); $mform->addElement('editor', 'contents_editor', get_string("pagecontents", "lesson"), null, $this->editoroptions); @@ -285,6 +286,10 @@ $mform->addElement('header', 'headeranswer'.$i, get_string('branch', 'lesson').' '.($i+1)); $mform->addElement('textarea', 'answer['.$i.']', get_string("description", "lesson"), array('rows'=>10, 'cols'=>70, 'width'=>630, 'height'=>300)); $mform->setType('answer['.$i.']', PARAM_CLEANHTML); + if ($i == 0) { + // we should have at least one branch + $mform->addRule('answer['.$i.']', null, 'required', null, 'server'); + } $mform->addElement('select', 'jumpto['.$i.']', get_string("jump", "lesson"), $jumptooptions); if ($i === 0) { @@ -294,4 +299,4 @@ } } } -} \ No newline at end of file +}