mod-choice MDL-20248 Upgraded choice module to use the new navigation blocks

This commit is contained in:
samhemelryk 2009-09-10 07:51:53 +00:00
parent ee00eb8c69
commit 97011c648c
2 changed files with 31 additions and 0 deletions

View 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';

View 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())));
}
}