From: tjhunt Date: Tue, 22 Apr 2008 15:19:50 +0000 (+0000) Subject: MDL-14363 - Fix a broken redirect from mod/quiz/ attempt.php to edit.php when the... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=44847eb8689aded152d5d843b51c135647cc53c0;p=moodle.git MDL-14363 - Fix a broken redirect from mod/quiz/ attempt.php to edit.php when the quiz has not questions. Also, when the quiz has no questions, disable the Info, Reports and Preview tabs, which, in this case, just redirect back to the Edit tab anyway. Finally, change a redirect in quiz view.php, which used a relative URL, to a full url starting $CFG->wwwroot. --- diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index 31fec0ea51..18c4f8d2b9 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -68,7 +68,7 @@ /// if no questions have been set up yet redirect to edit.php if (!$quiz->questions && has_capability('mod/quiz:manage', $context)) { - redirect($CFG->wwwroot . '/mod/quiz/edit.php?quizid=' . $quiz->id); + redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id); } /// Check capabilites. diff --git a/mod/quiz/tabs.php b/mod/quiz/tabs.php index a6f9b75c6b..096f61c6ba 100644 --- a/mod/quiz/tabs.php +++ b/mod/quiz/tabs.php @@ -48,7 +48,6 @@ if ($currenttab == 'info' && count($row) == 1) { } if ($currenttab == 'reports' and isset($mode)) { - $inactive[] = 'reports'; $activated[] = 'reports'; // Standard reports we want to show first. @@ -81,7 +80,6 @@ if ($currenttab == 'reports' and isset($mode)) { } if ($currenttab == 'edit' and isset($mode)) { - $inactive[] = 'edit'; $activated[] = 'edit'; $row = array(); @@ -98,6 +96,10 @@ if ($currenttab == 'edit' and isset($mode)) { } +if (!$quiz->questions) { + $inactive += array('info', 'reports', 'preview'); +} + print_tabs($tabs, $currenttab, $inactive, $activated); ?> diff --git a/mod/quiz/view.php b/mod/quiz/view.php index c28ebc0ca9..b4c9b35a7b 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -49,7 +49,7 @@ /// If no questions have been set up yet redirect to edit.php if (!$quiz->questions && has_capability('mod/quiz:manage', $context)) { - redirect('edit.php?cmid='.$cm->id); + redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id); } /// Log this request.