|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 require_once('../../config.php'); 00028 require_once($CFG->dirroot.'/mod/lesson/locallib.php'); 00029 00030 $id = required_param('id', PARAM_INT); 00031 00032 $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);; 00033 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 00034 $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); 00035 00036 require_login($course, false, $cm); 00037 00038 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 00039 require_capability('mod/lesson:manage', $context); 00040 00041 $mode = optional_param('mode', get_user_preferences('lesson_view', 'collapsed'), PARAM_ALPHA); 00042 $PAGE->set_url('/mod/lesson/edit.php', array('id'=>$cm->id,'mode'=>$mode)); 00043 00044 if ($mode != get_user_preferences('lesson_view', 'collapsed') && $mode !== 'single') { 00045 set_user_preference('lesson_view', $mode); 00046 } 00047 00048 $lessonoutput = $PAGE->get_renderer('mod_lesson'); 00049 $PAGE->navbar->add(get_string('edit')); 00050 echo $lessonoutput->header($lesson, $cm, $mode); 00051 00052 if (!$lesson->has_pages()) { 00053 // There are no pages; give teacher some options 00054 require_capability('mod/lesson:edit', $context); 00055 echo $lessonoutput->add_first_page_links($lesson); 00056 } else { 00057 switch ($mode) { 00058 case 'collapsed': 00059 echo $lessonoutput->display_edit_collapsed($lesson, $lesson->firstpageid); 00060 break; 00061 case 'single': 00062 $pageid = required_param('pageid', PARAM_INT); 00063 $PAGE->url->param('pageid', $pageid); 00064 $singlepage = $lesson->load_page($pageid); 00065 echo $lessonoutput->display_edit_full($lesson, $singlepage->id, $singlepage->prevpageid, true); 00066 break; 00067 case 'full': 00068 echo $lessonoutput->display_edit_full($lesson, $lesson->firstpageid, 0); 00069 break; 00070 } 00071 } 00072 00073 echo $lessonoutput->footer();