. /** * Handles lesson actions * * ACTIONS handled are: * confirmdelete * delete * move * moveit * @package mod * @subpackage lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ require_once("../../config.php"); require_once($CFG->dirroot.'/mod/lesson/locallib.php'); $id = required_param('id', PARAM_INT); // Course Module ID $action = required_param('action', PARAM_ALPHA); // Action $pageid = required_param('pageid', PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);; $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); $url = new moodle_url('/mod/lesson/lesson.php', array('id'=>$id,'action'=>$action)); $PAGE->set_url($url); $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/lesson:edit', $context); require_sesskey(); $lessonoutput = $PAGE->get_renderer('mod_lesson'); /// Process the action switch ($action) { case 'confirmdelete': $PAGE->navbar->add(get_string($action, 'lesson')); $thispage = $lesson->load_page($pageid); echo $lessonoutput->header($lesson, $cm); echo $OUTPUT->heading(get_string("deletingpage", "lesson", format_string($thispage->title))); // print the jumps to this page $params = array("lessonid" => $lesson->id, "pageid" => $pageid); if ($answers = $DB->get_records_select("lesson_answers", "lessonid = :lessonid AND jumpto = :pageid + 1", $params)) { echo $OUTPUT->heading(get_string("thefollowingpagesjumptothispage", "lesson")); echo "
\n";
foreach ($answers as $answer) {
if (!$title = $DB->get_field("lesson_pages", "title", array("id" => $answer->pageid))) {
print_error('cannotfindpagetitle', 'lesson');
}
echo $title."
\n";
}
}
echo $OUTPUT->confirm(get_string("confirmdeletionofthispage","lesson"),"lesson.php?action=delete&id=$cm->id&pageid=$pageid","view.php?id=$cm->id");
break;
case 'move':
$PAGE->navbar->add(get_string($action, 'lesson'));
$title = $DB->get_field("lesson_pages", "title", array("id" => $pageid));
echo $lessonoutput->header($lesson, $cm);
echo $OUTPUT->heading(get_string("moving", "lesson", format_string($title)));
$params = array ("lessonid" => $lesson->id, "prevpageid" => 0);
if (!$page = $DB->get_record_select("lesson_pages", "lessonid = :lessonid AND prevpageid = :prevpageid", $params)) {
print_error('cannotfindfirstpage', 'lesson');
}
echo "
id&sesskey=".sesskey()."&action=moveit&pageid=$pageid&after=0\">". get_string("movepagehere", "lesson")." |
$title |
id&sesskey=".sesskey()."&action=moveit&pageid=$pageid&after={$page->id}\">". get_string("movepagehere", "lesson")." |