$caps[] = 'moodle/site:accessallgroups';
return $caps;
}
+
+/**
+ * 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 quiz 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 quiz_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 quiz_extend_settings_navigation($settings, $module) {
+ global $PAGE, $CFG, $DB, $USER, $OUTPUT;
+
+ $quiz = $DB->get_record('quiz', array('id'=>$PAGE->cm->instance));
+ $quiznavkey = $settings->add(get_string('quizadministration', 'quiz'));
+ $quiznav = $settings->get($quiznavkey);
+ $quiznav->forceopen = true;
+
+ if (has_capability('mod/quiz:view', $PAGE->cm->context)) {
+ $url = new moodle_url($CFG->wwwroot.'/mod/quiz/view.php', array('id'=>$PAGE->cm->id));
+ $quiznav->add(get_string('info', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/info'));
+ }
+ if (has_capability('mod/quiz:viewreports', $PAGE->cm->context)) {
+ $url = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', array('q'=>$quiz->id));
+ $reportkey = $quiznav->add(get_string('results', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/report'));
+
+ require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php');
+ $reportlist = quiz_report_list($PAGE->cm->context);
+ foreach ($reportlist as $report) {
+ $url = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', array('q'=>$quiz->id, 'mode'=>$report));
+ $quiznav->get($reportkey)->add(get_string($report, 'quiz_'.$report), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/item'));
+ }
+ }
+ if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
+ $url = new moodle_url($CFG->wwwroot.'/mod/quiz/startattempt.php', array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
+ $quiznav->add(get_string('preview', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('t/preview'));
+ }
+ if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
+ $url = new moodle_url($CFG->wwwroot.'/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id));
+ $quiznav->add(get_string('edit'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('t/edit'));
+ }
+
+ 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()));
+ $quiznav->add(get_string('updatethis', '', get_string('modulename', 'quiz')), $url);
+ }
+
+ if (count($quiznav->children)<1) {
+ $settings->remove_child($quiznavkey);
+ }
+}
\ No newline at end of file