]> git.mjollnir.org Git - moodle.git/commitdiff
mod-hotpot MDL-20258 Added skeleton functions to extend navigation and removed update...
authorSam Hemelryk <sam@moodle.com>
Wed, 23 Dec 2009 01:47:01 +0000 (01:47 +0000)
committerSam Hemelryk <sam@moodle.com>
Wed, 23 Dec 2009 01:47:01 +0000 (01:47 +0000)
lang/en_utf8/hotpot.php
mod/hotpot/lib.php
mod/hotpot/report.php
mod/hotpot/review.php
mod/hotpot/view.php

index bf749d1e6cab9aca2b0a139d8f85d29c204970f8..14ad1219cd2a0f144b962f214759f2be4c642842 100644 (file)
@@ -54,6 +54,7 @@ $string['hotpot:deleteattempt'] = 'Delete quiz attempts';
 $string['hotpot:grade'] = 'Modify grades';
 $string['hotpot:view'] = 'Use quiz';
 $string['hotpot:viewreport'] = 'View reports';
+$string['hotpotadministration'] = 'Hot Potatoes quiz administration';
 $string['hotpotcloses'] = 'Hot Potatoes quiz closes';
 $string['hotpotopens'] = 'Hot Potatoes quiz opens';
 $string['ignored'] = 'Ignored';
index f0506759a3cddf47f07d653522908ff377fef2f8..d43d14b4931e584f5743be9388648c10922975ef 100644 (file)
@@ -2984,3 +2984,54 @@ function hotpot_reset_course_form_definition(&$mform) {
 function hotpot_reset_course_form_defaults($course) {
     return array('reset_hotpot_deleteallattempts' => 1);
 }
+
+/**
+ * This function 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 hotpot 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 hotpot_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 settings_navigation $settings
+ * @param stdClass $module
+ */
+function hotpot_extend_settings_navigation($settings, $module) {
+    global $PAGE, $CFG, $DB;
+
+    // Load the hotpot instance from the database
+    $hotpot = $DB->get_record('hotpot', array('id'=>$PAGE->cm->instance));
+    // Add a hotpot node to the settings navigation.
+    $hotpotnavkey = $settings->add(get_string('hotpotadministration', 'hotpot'));
+    $hotpotnav = $settings->get($hotpotnavkey);
+    $hotpotnav->forceopen = true;
+
+    // If the user has the capability add an update this module link for the hotpot instance
+    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()));
+        $hotpotnav->add(get_string('updatethis', '', get_string('modulename', 'hotpot')), $url);
+    }
+
+    // Check if any children have been added. If not remove the node to save on clutter.
+    if (count($hotpotnav->children)<1) {
+        $settings->remove_child($hotpotnav);
+    }
+}
\ No newline at end of file
index f607febbcab5bb0225973083e24df1e7f754704d..72727071ce202e23aaff647b5d179299f2bc5711 100644 (file)
@@ -444,7 +444,6 @@ function hotpot_print_report_heading(&$course, &$cm, &$hotpot, &$mode) {
 
     $PAGE->set_title(format_string($course->shortname) . ": $hotpot->name");
     $PAGE->set_heading($course->fullname);
-    $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'hotpot'));
     echo $OUTPUT->header();
 
     $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
index 56e7757f5bf020d15989c71dbb5b7ff708a2ef56..89b42ffd5501a3d75b140f3ce1f5bd19871980ef 100644 (file)
@@ -59,7 +59,6 @@
     $PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
     $PAGE->set_title(format_string($course->shortname) . ": $hotpot->name");
     $PAGE->set_heading($course->fullname);
-    $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'hotpot'));
     echo $OUTPUT->header();
     print '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib
     echo $OUTPUT->heading($hotpot->name);
index c48b611591c6382e42cec341e674c9855709f4c3..33d616d3e7ac6a0a0783e3c8333751d271083213 100644 (file)
@@ -47,7 +47,6 @@
     $title = format_string($course->shortname.': '.$hotpot->name, true);
     $heading = $course->fullname;
 
-    $button = $OUTPUT->update_module_button($cm->id, 'hotpot');
     $button = '<div style="font-size:0.75em;">'.$button.'</div>';
     $loggedinas = '<span class="logininfo">'.user_login_string($course, $USER).'</span>';