Permalink
Browse files

[Changed/BugFix] Now when a teacher edits a page with the "Edit page …

…contents" button and then saves or cancels, s/he gets redirected back to the lesson navigation. This will help to streamline the editing.

[Fixed] The cancel button on the edit page now works.

[Fixed] "Edit page contents" button works on the first page now.
  • Loading branch information...
1 parent 451e99a commit 9250c7f9177f0f7b927711b0092859c6d4f884e5 michaelpenne committed Jan 13, 2006
Showing with 32 additions and 6 deletions.
  1. +7 −4 mod/lesson/action/editpage.php
  2. +17 −1 mod/lesson/action/updatepage.php
  3. +8 −1 mod/lesson/view.php
@@ -8,6 +8,8 @@
// get the page
$pageid = required_param('pageid', PARAM_INT);
+ $redirect = optional_param('redirect', '', PARAM_ALPHA);
+
if (!$page = get_record("lesson_pages", "id", $pageid)) {
error("Edit page: page record not found");
}
@@ -55,11 +57,12 @@
// give teacher a proforma
?>
<form name="editpage" method="post" action="lesson.php">
- <input type="hidden" name="id" value="<?PHP echo $cm->id ?>">
+ <input type="hidden" name="id" value="<?php echo $cm->id ?>" />
<input type="hidden" name="action" value="updatepage">
- <input type="hidden" name="pageid" value="<?PHP echo $pageid ?>">
- <input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>">
- <input type="hidden" name="redisplay" value="0">
+ <input type="hidden" name="pageid" value="<?php echo $pageid ?>" />
+ <input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
+ <input type="hidden" name="redirect" value="<?php echo $redirect ?>" />
+ <input type="hidden" name="redisplay" value="0" />
<center>
<?php
switch ($page->qtype) {
@@ -8,11 +8,24 @@
confirm_sesskey();
+ $redirect = optional_param('redirect', '', PARAM_ALPHA);
+
$timenow = time();
$form = data_submitted();
$page = new stdClass;
$page->id = clean_param($form->pageid, PARAM_INT);
+
+ // check to see if the cancel button was pushed
+ if (optional_param('cancel', '', PARAM_ALPHA)) {
+ if ($redirect == 'navigation') {
+ // redirect to viewing the page
+ redirect("view.php?id=$cm->id&amp;action=navigation&amp;pageid=$page->id");
+ } else {
+ redirect("view.php?id=$cm->id");
+ }
+ }
+
$page->timemodified = $timenow;
$page->qtype = clean_param($form->qtype, PARAM_INT);
if (isset($form->qoption)) {
@@ -150,7 +163,10 @@
}
if ($form->redisplay) {
- redirect("lesson.php?id=$cm->id&amp;action=editpage&amp;pageid=$page->id");
+ redirect("lesson.php?id=$cm->id&amp;action=editpage&amp;pageid=$page->id&amp;redirect=$redirect");
+ } else if ($redirect == 'navigation') {
+ // takes us back to viewing the page
+ redirect("view.php?id=$cm->id&amp;action=navigation&amp;pageid=$page->id", get_string('updatedpage', 'lesson'));
} else {
redirect("view.php?id=$cm->id", get_string('updatedpage', 'lesson'));
}
View
@@ -80,11 +80,18 @@
'<input type="hidden" name="return" value="true" />'.
'<input type="submit" value="'. get_string('editlessonsettings', 'lesson') .'" /></form>';
if ($action == 'navigation' && $pageid != LESSON_EOL) {
+ $currentpageid = $pageid; // very important not to alter $pageid.
+ if (empty($currentpageid)) {
+ if (!$currentpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) {
+ error('Navigation: first page not found');
+ }
+ }
$button .= '</td><td>'.
'<form target="'. $CFG->framename .'" method="get" action="'. $CFG->wwwroot .'/mod/lesson/lesson.php">'.
'<input type="hidden" name="id" value="'. $cm->id .'" />'.
'<input type="hidden" name="action" value="editpage" />'.
- '<input type="hidden" name="pageid" value="'. $pageid .'" />'.
+ '<input type="hidden" name="redirect" value="navigation" />'.
+ '<input type="hidden" name="pageid" value="'. $currentpageid .'" />'.
'<input type="submit" value="'. get_string('editpagecontent', 'lesson') .'" /></form>';
}
$button .= '</td></tr></table>';

0 comments on commit 9250c7f

Please sign in to comment.