]> git.mjollnir.org Git - moodle.git/commitdiff
mod-choice MDL-20248 Upgraded choice module to use the new navigation blocks
authorsamhemelryk <samhemelryk>
Thu, 10 Sep 2009 07:51:53 +0000 (07:51 +0000)
committersamhemelryk <samhemelryk>
Thu, 10 Sep 2009 07:51:53 +0000 (07:51 +0000)
lang/en_utf8/choice.php
mod/choice/lib.php

index d7dafc8064d4c9039d62251864a7e905d5133f18..1f4c558dfc6bfc1ad4fa06c9691f3480ce78c078 100644 (file)
@@ -6,6 +6,7 @@ $string['addmorechoices'] = 'Add more choices';
 $string['allowupdate'] = 'Allow choice to be updated';
 $string['answered'] = 'Answered';
 $string['choice'] = 'Choice';
+$string['choiceadministration'] = 'Choice administration';
 $string['choice:choose'] = 'Record a choice';
 $string['choice:deleteresponses'] = 'Delete responses';
 $string['choice:downloadresponses'] = 'Download responses';
index b6d2cd25b29198cddcd43f3861173116002c4184..40ecb1769613e9b44891d3165045c0809bb7fcb7 100644 (file)
@@ -923,3 +923,33 @@ function choice_supports($feature) {
         default: return null;
     }
 }
+
+function choice_extend_settings_navigation($settings, $module) {
+    global $PAGE, $USER, $OUTPUT, $CFG, $DB;
+
+    $choice = $DB->get_record('choice', array('id'=>$PAGE->cm->instance));
+    $choicenavkey = $settings->add(get_string('choiceadministration', 'choice'));
+    $choicenav = $settings->get($choicenavkey);
+    $choicenav->forceopen = true;
+
+    if (has_capability('mod/choice:readresponses', $PAGE->cm->context)) {
+
+        $groupmode = groups_get_activity_groupmode($PAGE->cm);
+        if ($groupmode) {
+            groups_get_activity_group($PAGE->cm, true);
+        }
+        $allresponses = choice_get_response_data($choice, $PAGE->cm, $groupmode);   // Big function, approx 6 SQL calls per user
+
+        $responsecount =0;
+        foreach($allresponses as $optionid => $userlist) {
+            if ($optionid) {
+                $responsecount += count($userlist);
+            }
+        }
+        $choicenav->add(get_string("viewallresponses", "choice", $responsecount), new moodle_url($CFG->wwwroot.'/mod/choice/report.php', array('id'=>$PAGE->cm->id)));
+    }
+
+    if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
+        $choicenav->add(get_string('updatethis', '', get_string('modulename', 'choice')), new moodle_url($CFG->wwwroot.'/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
+    }
+}
\ No newline at end of file