3 * Sets up the tabs used by the quiz pages based on the users capabilites.
5 * @author Tim Hunt and others.
6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
11 error('You cannot call this script in that way');
13 if (!isset($currenttab)) {
17 $cm = get_coursemodule_from_instance('quiz', $quiz->id
);
19 if (!isset($course)) {
20 $course = get_record('course', 'id', $quiz->course
);
23 $context = get_context_instance(CONTEXT_MODULE
, $cm->id
);
30 if (has_capability('mod/quiz:view', $context)) {
31 $row[] = new tabobject('info', "$CFG->wwwroot/mod/quiz/view.php?q=$quiz->id", get_string('info', 'quiz'));
33 if (has_capability('mod/quiz:viewreports', $context)) {
34 $row[] = new tabobject('reports', "$CFG->wwwroot/mod/quiz/report.php?q=$quiz->id", get_string('results', 'quiz'));
36 if (has_capability('mod/quiz:preview', $context)) {
37 $row[] = new tabobject('preview', "$CFG->wwwroot/mod/quiz/attempt.php?q=$quiz->id", get_string('preview', 'quiz'));
39 if (has_capability('mod/quiz:manage', $context)) {
40 $row[] = new tabobject('edit', "$CFG->wwwroot/mod/quiz/edit.php?cmid=$cm->id", get_string('edit'));
43 if ($currenttab == 'info' && count($row) == 1) {
44 // Don't show only an info tab (e.g. to students).
49 if ($currenttab == 'reports' and isset($mode)) {
50 $inactive[] = 'reports';
51 $activated[] = 'reports';
53 $allreports = get_list_of_plugins("mod/quiz/report");
54 $reportlist = array ('overview', 'regrade', 'grading', 'analysis'); // Standard reports we want to show first
56 foreach ($allreports as $report) {
57 if (!in_array($report, $reportlist)) {
58 $reportlist[] = $report;
64 foreach ($reportlist as $report) {
65 $row[] = new tabobject($report, "$CFG->wwwroot/mod/quiz/report.php?q=$quiz->id&mode=$report",
66 get_string($report, 'quiz_'.$report));
67 if ($report == $mode) {
68 $currenttab = $report;
74 if ($currenttab == 'edit' and isset($mode)) {
76 $activated[] = 'edit';
81 $strquizzes = get_string('modulenameplural', 'quiz');
82 $strquiz = get_string('modulename', 'quiz');
83 $streditingquiz = get_string("editinga", "moodle", $strquiz);
84 $strupdate = get_string('updatethis', 'moodle', $strquiz);
86 $row[] = new tabobject('editq', "$CFG->wwwroot/mod/quiz/edit.php?".$thispageurl->get_query_string(), $strquiz, $streditingquiz);
87 questionbank_navigation_tabs($row, $context, $thispageurl->get_query_string());
91 print_tabs($tabs, $currenttab, $inactive, $activated);