Permalink
Browse files

Merge branch 'MDL-25874' of git://git.luns.net.uk/moodle

  • Loading branch information...
2 parents e8d6d24 + fe4457a commit 1ca95a13f3ea4ea1cfcc73caf5202ff3b05b8a2c Sam Hemelryk committed Feb 7, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 mod/lesson/editpage.php
View
@@ -56,8 +56,30 @@
$jumpto = lesson_page::get_jumptooptions($pageid, $lesson);
$manager = lesson_page_type_manager::get($lesson);
$editoroptions = array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes);
+
+// If the previous page was the Question type selection form, this form
+// will have a different name (e.g. _qf__lesson_add_page_form_selection
+// versus _qf__lesson_add_page_form_multichoice). This causes confusion
+// in moodleform::_process_submission because the array key check doesn't
+// tie up with the current form name, which in turn means the "submitted"
+// check ends up evaluating as false, thus it's not possible to check whether
+// the Question type selection was cancelled. For this reason, a dummy form
+// is created here solely to check whether the selection was cancelled.
+if ($qtype) {
+ $mformdummy = $manager->get_page_form(0, array('editoroptions'=>$editoroptions, 'jumpto'=>$jumpto, 'lesson'=>$lesson, 'edit'=>$edit, 'maxbytes'=>$PAGE->course->maxbytes));
+ if ($mformdummy->is_cancelled()) {
+ redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$id");
+ exit;
+ }
+}
+
$mform = $manager->get_page_form($qtype, array('editoroptions'=>$editoroptions, 'jumpto'=>$jumpto, 'lesson'=>$lesson, 'edit'=>$edit, 'maxbytes'=>$PAGE->course->maxbytes));
+if ($mform->is_cancelled()) {
+ redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$id");
+ exit;
+}
+
if ($edit) {
$data = $editpage->properties();
$data->pageid = $editpage->id;

0 comments on commit 1ca95a1

Please sign in to comment.