From: samhemelryk Date: Thu, 10 Sep 2009 07:51:53 +0000 (+0000) Subject: mod-choice MDL-20248 Upgraded choice module to use the new navigation blocks X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=97011c648c449bfdbec17cd45f30efcb4212ff38;p=moodle.git mod-choice MDL-20248 Upgraded choice module to use the new navigation blocks --- diff --git a/lang/en_utf8/choice.php b/lang/en_utf8/choice.php index d7dafc8064..1f4c558dfc 100644 --- a/lang/en_utf8/choice.php +++ b/lang/en_utf8/choice.php @@ -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'; diff --git a/mod/choice/lib.php b/mod/choice/lib.php index b6d2cd25b2..40ecb17696 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -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