]> git.mjollnir.org Git - moodle.git/commitdiff
mod-lesson MDL-20259 Created callback methods to expand navigation and settings blocks
authorsamhemelryk <samhemelryk>
Wed, 16 Sep 2009 06:22:12 +0000 (06:22 +0000)
committersamhemelryk <samhemelryk>
Wed, 16 Sep 2009 06:22:12 +0000 (06:22 +0000)
 Also fixed up minor bugs and added calls set_url

lang/en_utf8/lesson.php
mod/lesson/edit.php
mod/lesson/essay.php
mod/lesson/lesson.php
mod/lesson/lib.php
mod/lesson/report.php

index 0d84488a58bc2d0ddf3013fbf3da3df42f988447..51bc5534c0099c97385628183f06a689d9cce8cb 100644 (file)
@@ -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 <b>$a</b> 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.<br />Your $a->essayquestions essay question(s) will be graded and added<br />into your final score at a later date.<br /><br />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 <em>$a</em>';
 $string['leftduringtimed'] = 'You have left during a timed lesson.<br />Please click on Continue to restart the lesson.';
 $string['leftduringtimednoretake'] = 'You have left during a timed lesson and you are<br />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';
index cdf71fdaac5e88eb3bf7a347af120b7c73eff050..413ea21ca424e12e613990ecc87012fe838c56c1 100644 (file)
     }
 
     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);
     
index 765319f73e0caa117f05c265f867040c538fcb22..c2e105d74a307b3a27e9824e33f7eff68f3b8aaf 100644 (file)
     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);
index f20d661d9c4f4650f250b236528fc929d92b14dd..8713bdaa551b23754b2624912f8a17213af35fef 100644 (file)
     
     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
index 678c6ad94ca084303f68630e017bcf78ad35877c..145fb67a11a2af8d710299ecd8ca682e0ce3ba09 100644 (file)
@@ -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
index 03f4103dd4441871ee2ed10d84212d4211670ad5..efea9a9be221653ebde4edc3bb0aced3aaac72d7 100644 (file)
     
 // 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);