[Changed] 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.
This commit is contained in:
michaelpenne 2006-01-13 18:41:37 +00:00
parent 42f9b64b80
commit aeb8148a57
3 changed files with 26 additions and 6 deletions

View File

@ -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");
}
@ -53,11 +55,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) {

View File

@ -7,12 +7,25 @@
}
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)) {
@ -140,7 +153,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 File

@ -90,6 +90,7 @@
'<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="redirect" value="navigation" />'.
'<input type="hidden" name="pageid" value="'. $currentpageid .'" />'.
'<input type="submit" value="'. get_string('editpagecontent', 'lesson') .'" /></form>';
}
@ -879,7 +880,7 @@
$fullbuttonhtml .= "</div>\n";
if ($lesson->slideshow) {
echo '<div class="branchslidetop">' . $fullbuttonhtml . '</div>';
//echo '<div class="branchslidetop">' . $fullbuttonhtml . '</div>';
$options = new stdClass;
$options->noclean = true;
echo '<div class="contents">'.format_text($page->contents, FORMAT_MOODLE, $options).'</div>';;