From c69499369ebd94e63a031cac057e14a9b3eb87f6 Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Wed, 16 Sep 2009 06:22:12 +0000 Subject: [PATCH] mod-lesson MDL-20259 Created callback methods to expand navigation and settings blocks Also fixed up minor bugs and added calls set_url --- lang/en_utf8/lesson.php | 5 +++ mod/lesson/edit.php | 11 ++++++ mod/lesson/essay.php | 9 ++++- mod/lesson/lesson.php | 7 +++- mod/lesson/lib.php | 77 ++++++++++++++++++++++++++++++++++++++++- mod/lesson/report.php | 11 ++++++ 6 files changed, 117 insertions(+), 3 deletions(-) diff --git a/lang/en_utf8/lesson.php b/lang/en_utf8/lesson.php index 0d84488a58..51bc5534c0 100644 --- a/lang/en_utf8/lesson.php +++ b/lang/en_utf8/lesson.php @@ -7,6 +7,7 @@ $string['actions'] = 'Actions'; $string['activitylink'] = 'Link to an activity'; $string['activitylinkname'] = 'Go to: $a'; $string['addabranchtable'] = 'Add a Branch Table'; +$string['addbranchtable'] = 'Add a Branch Table'; $string['addanendofbranch'] = 'Add an End of Branch'; $string['addaquestionpage'] = 'Add a Question Page'; $string['addaquestionpagehere'] = 'Add a question page here'; @@ -68,6 +69,7 @@ $string['completed'] = 'Completed'; $string['completederror'] = 'Complete the lesson'; $string['completethefollowingconditions'] = 'You must complete the following condition(s) in $a lesson before you can proceed.'; $string['conditionsfordependency'] = 'Condition(s) for the dependency'; +$string['confirmdelete']= 'Delete page'; $string['confirmdeletionofthispage'] = 'Confirm deletion of this page'; $string['congratulations'] = 'Congratulations - end of lesson reached'; $string['continue'] = 'Continue'; @@ -98,6 +100,7 @@ $string['displayreview'] = 'Display review button'; $string['displayscorewithessays'] = 'You earned $a->score out of $a->tempmaxgrade for the automatically graded questions.
Your $a->essayquestions essay question(s) will be graded and added
into your final score at a later date.

Your current grade without the essay question(s) is $a->score out of $a->grade'; $string['displayscorewithoutessays'] = 'Your score is $a->score (out of $a->grade).'; $string['edit'] = 'Edit'; +$string['editpage'] = 'Edit page contents'; $string['editlessonsettings'] = 'Edit lesson settings'; $string['editpagecontent'] = 'Edit page contents'; $string['email'] = 'Email'; @@ -149,6 +152,7 @@ $string['jumps'] = 'Jumps'; $string['jumpsto'] = 'Jumps to $a'; $string['leftduringtimed'] = 'You have left during a timed lesson.
Please click on Continue to restart the lesson.'; $string['leftduringtimednoretake'] = 'You have left during a timed lesson and you are
not allowed to retake or continue the lesson.'; +$string['lessonadministration'] = 'Lesson administration'; $string['lesson:edit'] = 'Edit a lesson activity'; $string['lesson:manage'] = 'Manage a lesson activity'; $string['lessonattempted'] = 'Lesson attempted'; @@ -187,6 +191,7 @@ $string['modattempts'] = 'Allow student review'; $string['modattemptsnoteacher'] = 'Student review only works for students.'; $string['modulename'] = 'Lesson'; $string['modulenameplural'] = 'Lessons'; +$string['move'] = 'Move page'; $string['movedpage'] = 'Moved page'; $string['movepagehere'] = 'Move page to here'; $string['moving'] = 'Moving page: $a'; diff --git a/mod/lesson/edit.php b/mod/lesson/edit.php index cdf71fdaac..413ea21ca4 100644 --- a/mod/lesson/edit.php +++ b/mod/lesson/edit.php @@ -35,6 +35,17 @@ } require_login($course->id, false, $cm); + + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/edit.php', array('id'=>$id,'mode'=>$mode)); + if ($display !== 0) { + $url->param('display', $display); + } + if ($pageid !== 0) { + $url->param('pageid', $pageid); + } + $PAGE->set_url($url); + $PAGE->navbar->add(get_string('edit')); + $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/lesson:manage', $context); diff --git a/mod/lesson/essay.php b/mod/lesson/essay.php index 765319f73e..c2e105d74a 100644 --- a/mod/lesson/essay.php +++ b/mod/lesson/essay.php @@ -18,7 +18,14 @@ list($cm, $course, $lesson) = lesson_get_basics($id); require_login($course->id, false, $cm); - + + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/essay.php', array('id'=>$id)); + if ($mode !== 'display') { + $url->param('mode', $mode); + } + $PAGE->set_url($url); + $PAGE->navbar->add(get_string('manualgrading','lesson')); + $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/lesson:edit', $context); diff --git a/mod/lesson/lesson.php b/mod/lesson/lesson.php index f20d661d9c..8713bdaa55 100644 --- a/mod/lesson/lesson.php +++ b/mod/lesson/lesson.php @@ -29,7 +29,12 @@ list($cm, $course, $lesson) = lesson_get_basics($id); - require_login($course->id); + require_login($course->id, false, $cm); + + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/edit.php', array('id'=>$id,'action'=>$action)); + $PAGE->set_url($url); + $PAGE->navbar->add(get_string($action, 'lesson')); + $context = get_context_instance(CONTEXT_MODULE, $cm->id); /// Set up some general variables diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index 678c6ad94c..145fb67a11 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -804,7 +804,7 @@ function lesson_supports($feature) { case FEATURE_GROUPS: return false; case FEATURE_GROUPINGS: return false; case FEATURE_GROUPMEMBERSONLY: return true; - case FEATURE_MOD_INTRO: return true; + case FEATURE_MOD_INTRO: return false; case FEATURE_COMPLETION_TRACKS_VIEWS: return true; case FEATURE_GRADE_HAS_GRADE: return true; case FEATURE_GRADE_OUTCOMES: return true; @@ -812,3 +812,78 @@ function lesson_supports($feature) { default: return null; } } + +/** + * This fucntion extends the global navigaiton for the site. + * It is important to note that you should not rely on PAGE objects within this + * body of code as there is no guarantee that during an AJAX request they are + * available + * + * @param navigation_node $navigation The lesson node within the global navigation + * @param stdClass $course The course object returned from the DB + * @param stdClass $module The module object returned from the DB + * @param stdClass $cm The course module isntance returned from the DB + */ +function lesson_extend_navigation($navigation, $course, $module, $cm) { + /** + * This is currently just a stub so that it can be easily expanded upon. + * When expanding just remove this comment and the line below and then add + * you content. + */ + $navigation->nodetype = navigation_node::NODETYPE_LEAF; +} + +/** + * This function extends the settings navigation block for the site. + * + * It is safe to rely on PAGE here as we will only ever be within the module + * context when this is called + * + * @param navigation_node $settings + * @param stdClass $module + */ +function lesson_extend_settings_navigation($settings, $module) { + global $PAGE, $CFG, $DB, $USER, $OUTPUT; + + $lesson = $DB->get_record('lesson', array('id'=>$PAGE->cm->instance)); + $lessonnavkey = $settings->add(get_string('lessonadministration', 'lesson')); + $lessonnav = $settings->get($lessonnavkey); + $lessonnav->forceopen = true; + + $canedit = has_capability('mod/lesson:edit', $PAGE->cm->context); + + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/view.php', array('id'=>$PAGE->cm->id)); + $key = $lessonnav->add(get_string('preview', 'lesson'), $url); + + if ($canedit) { + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/edit.php', array('id'=>$PAGE->cm->id)); + $key = $lessonnav->add(get_string('edit', 'lesson'), $url); + } + + if (has_capability('mod/lesson:manage', $PAGE->cm->context)) { + $key = $lessonnav->add(get_string('reports', 'lesson')); + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/report.php', array('id'=>$PAGE->cm->id, 'action'=>'reportoverview')); + $lessonnav->get($key)->add(get_string('overview', 'lesson'), $url); + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/report.php', array('id'=>$PAGE->cm->id, 'action'=>'reportdetail')); + $lessonnav->get($key)->add(get_string('detailedstats', 'lesson'), $url); + } + + if ($canedit) { + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/essay.php', array('id'=>$PAGE->cm->id)); + $lessonnav->add(get_string('manualgrading', 'lesson'), $url); + } + + if ($lesson->highscores) { + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id)); + $lessonnav->add(get_string('highscores', 'lesson'), $url); + } + + if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) { + $url = new moodle_url($CFG->wwwroot.'/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())); + $lessonnav->add(get_string('updatethis', '', get_string('modulename', 'lesson')), $url); + } + + if (count($lessonnav->children)<1) { + $settings->remove_child($lessonnavkey); + } +} \ No newline at end of file diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 03f4103dd4..efea9a9be2 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -42,6 +42,17 @@ // make sure people are where they should be require_login($course->id, false, $cm); + + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/report.php', array('id'=>$id)); + if ($action !== 'reportoverview') { + $url->param('action', $action); + } + if ($pageid !== NULL) { + $url->param('pageid', $pageid); + } + $PAGE->set_url($url); + $PAGE->navbar->add(get_string('reports', 'lesson'), new moodle_url($CFG->wwwroot.'/mod/lesson/report.php', array('id'=>$id))); + $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/lesson:manage', $context); -- 2.39.5