2005-05-06 06:24:04 +00:00
|
|
|
<?php // $Id$
|
2006-02-09 13:57:22 +00:00
|
|
|
/**
|
2007-03-22 11:46:15 +00:00
|
|
|
* Sets up the tabs used by the quiz pages based on the users capabilites.
|
|
|
|
*
|
|
|
|
* @author Tim Hunt and others.
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
|
|
|
* @package quiz
|
|
|
|
*/
|
2006-02-09 13:57:22 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
if (empty($quiz)) {
|
|
|
|
error('You cannot call this script in that way');
|
|
|
|
}
|
|
|
|
if (!isset($currenttab)) {
|
|
|
|
$currenttab = '';
|
|
|
|
}
|
|
|
|
if (!isset($cm)) {
|
|
|
|
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
|
|
|
|
}
|
2007-08-09 21:51:09 +00:00
|
|
|
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2007-08-09 21:51:09 +00:00
|
|
|
if (!isset($contexts)){
|
|
|
|
$contexts = new question_edit_contexts($context);
|
|
|
|
}
|
2007-03-22 11:46:15 +00:00
|
|
|
$tabs = array();
|
|
|
|
$row = array();
|
|
|
|
$inactive = array();
|
|
|
|
$activated = array();
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
if (has_capability('mod/quiz:view', $context)) {
|
|
|
|
$row[] = new tabobject('info', "$CFG->wwwroot/mod/quiz/view.php?q=$quiz->id", get_string('info', 'quiz'));
|
|
|
|
}
|
|
|
|
if (has_capability('mod/quiz:viewreports', $context)) {
|
|
|
|
$row[] = new tabobject('reports', "$CFG->wwwroot/mod/quiz/report.php?q=$quiz->id", get_string('results', 'quiz'));
|
|
|
|
}
|
|
|
|
if (has_capability('mod/quiz:preview', $context)) {
|
|
|
|
$row[] = new tabobject('preview', "$CFG->wwwroot/mod/quiz/attempt.php?q=$quiz->id", get_string('preview', 'quiz'));
|
|
|
|
}
|
2007-08-09 21:51:09 +00:00
|
|
|
if ($contexts->have_one_edit_tab_cap('editq')) {
|
2007-07-07 14:18:30 +12:00
|
|
|
$row[] = new tabobject('edit', "$CFG->wwwroot/mod/quiz/edit.php?cmid=$cm->id", get_string('edit'));
|
2007-03-22 11:46:15 +00:00
|
|
|
}
|
2007-01-26 06:59:16 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
if ($currenttab == 'info' && count($row) == 1) {
|
|
|
|
// Don't show only an info tab (e.g. to students).
|
|
|
|
} else {
|
|
|
|
$tabs[] = $row;
|
|
|
|
}
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
if ($currenttab == 'reports' and isset($mode)) {
|
|
|
|
$inactive[] = 'reports';
|
|
|
|
$activated[] = 'reports';
|
|
|
|
|
|
|
|
$allreports = get_list_of_plugins("mod/quiz/report");
|
|
|
|
$reportlist = array ('overview', 'regrade', 'grading', 'analysis'); // Standard reports we want to show first
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
foreach ($allreports as $report) {
|
|
|
|
if (!in_array($report, $reportlist)) {
|
|
|
|
$reportlist[] = $report;
|
2005-05-06 06:24:04 +00:00
|
|
|
}
|
2007-03-22 11:46:15 +00:00
|
|
|
}
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
$row = array();
|
|
|
|
$currenttab = '';
|
|
|
|
foreach ($reportlist as $report) {
|
|
|
|
$row[] = new tabobject($report, "$CFG->wwwroot/mod/quiz/report.php?q=$quiz->id&mode=$report",
|
|
|
|
get_string($report, 'quiz_'.$report));
|
|
|
|
if ($report == $mode) {
|
|
|
|
$currenttab = $report;
|
2005-05-06 06:24:04 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-22 11:46:15 +00:00
|
|
|
$tabs[] = $row;
|
|
|
|
}
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
if ($currenttab == 'edit' and isset($mode)) {
|
|
|
|
$inactive[] = 'edit';
|
|
|
|
$activated[] = 'edit';
|
2006-02-09 13:57:22 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
$row = array();
|
|
|
|
$currenttab = $mode;
|
2006-03-01 09:30:21 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
$strquizzes = get_string('modulenameplural', 'quiz');
|
|
|
|
$strquiz = get_string('modulename', 'quiz');
|
|
|
|
$streditingquiz = get_string("editinga", "moodle", $strquiz);
|
|
|
|
$strupdate = get_string('updatethis', 'moodle', $strquiz);
|
2007-07-07 14:18:30 +12:00
|
|
|
|
2007-08-09 21:51:09 +00:00
|
|
|
if ($contexts->have_one_edit_tab_cap('editq')) {
|
|
|
|
$row[] = new tabobject('editq', "$CFG->wwwroot/mod/quiz/edit.php?".$thispageurl->get_query_string(), $strquiz, $streditingquiz);
|
|
|
|
}
|
|
|
|
questionbank_navigation_tabs($row, $contexts, $thispageurl->get_query_string());
|
2007-03-22 11:46:15 +00:00
|
|
|
$tabs[] = $row;
|
2007-08-09 21:51:09 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
}
|
2006-02-09 13:57:22 +00:00
|
|
|
|
2007-03-22 11:46:15 +00:00
|
|
|
print_tabs($tabs, $currenttab, $inactive, $activated);
|
2005-05-06 06:24:04 +00:00
|
|
|
|
|
|
|
?>
|