Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / mod / quiz / tabs.php
blob059e435941e5e7164bc44daffc8689c27e97fefd
1 <?php // $Id$
2 /**
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
7 * @package quiz
8 */
10 if (empty($quiz)) {
11 error('You cannot call this script in that way');
13 if (!isset($currenttab)) {
14 $currenttab = '';
16 if (!isset($cm)) {
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);
25 $tabs = array();
26 $row = array();
27 $inactive = array();
28 $activated = array();
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).
45 } else {
46 $tabs[] = $row;
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;
62 $row = array();
63 $currenttab = '';
64 foreach ($reportlist as $report) {
65 $row[] = new tabobject($report, "$CFG->wwwroot/mod/quiz/report.php?q=$quiz->id&amp;mode=$report",
66 get_string($report, 'quiz_'.$report));
67 if ($report == $mode) {
68 $currenttab = $report;
71 $tabs[] = $row;
74 if ($currenttab == 'edit' and isset($mode)) {
75 $inactive[] = 'edit';
76 $activated[] = 'edit';
78 $row = array();
79 $currenttab = $mode;
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());
88 $tabs[] = $row;
91 print_tabs($tabs, $currenttab, $inactive, $activated);