]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9004 - Breadcrumb trail is wrong when editing a quiz question. Merged from MOODLE...
authortjhunt <tjhunt>
Thu, 22 Mar 2007 11:46:15 +0000 (11:46 +0000)
committertjhunt <tjhunt>
Thu, 22 Mar 2007 11:46:15 +0000 (11:46 +0000)
mod/quiz/tabs.php
question/edit.php
question/showbank.php

index 8494c670de0718a72a0451c81b7937ced0e45918..bd46d6a5ec45590357bbfca1ae4c8aa4bd416c5e 100644 (file)
@@ -1,95 +1,92 @@
 <?php  // $Id$
 /**
-* Sets up the tabs used by the quiz pages for teachers.
-*
-* @version $Id$
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package quiz
-*/
+ * 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
+ */
 
-/// This file to be included so we can assume config.php has already been included.
+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);
+}
+if (!isset($course)) {
+    $course = get_record('course', 'id', $quiz->course);
+}
 
-    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);
-    }
-    if (!isset($course)) {
-        $course = get_record('course', 'id', $quiz->course);
-    }
+$context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-    //print_heading(format_string($quiz->name));
+$tabs = array();
+$row  = array();
+$inactive = array();
+$activated = array();
 
-    $tabs = array();
-    $row  = array();
-    $inactive = array();
-    $activated = array();
+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'));
+}
+if (has_capability('mod/quiz:manage', $context)) {
+    $row[] = new tabobject('edit', "$CFG->wwwroot/mod/quiz/edit.php?quizid=$quiz->id", get_string('edit'));
+}
 
-    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'));
-    }
-    if (has_capability('mod/quiz:manage', $context)) {
-        $row[] = new tabobject('edit', "$CFG->wwwroot/mod/quiz/edit.php?quizid=$quiz->id", get_string('edit'));
-    }
-
-    if ($currenttab == 'info' && count($row) == 1) {
-        // Don't show only an info tab (e.g. to students).
-    } else {
-        $tabs[] = $row;
-    }
+if ($currenttab == 'info' && count($row) == 1) {
+    // Don't show only an info tab (e.g. to students).
+} else {
+    $tabs[] = $row;
+}
 
-    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
+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
 
-        foreach ($allreports as $report) {
-            if (!in_array($report, $reportlist)) {
-                $reportlist[] = $report;
-            }
+    foreach ($allreports as $report) {
+        if (!in_array($report, $reportlist)) {
+            $reportlist[] = $report;
         }
+    }
 
-        $row  = array();
-        $currenttab = '';
-        foreach ($reportlist as $report) {
-            $row[] = new tabobject($report, "$CFG->wwwroot/mod/quiz/report.php?q=$quiz->id&amp;mode=$report",
-                                    get_string($report, 'quiz_'.$report));
-            if ($report == $mode) {
-                $currenttab = $report;
-            }
+    $row  = array();
+    $currenttab = '';
+    foreach ($reportlist as $report) {
+        $row[] = new tabobject($report, "$CFG->wwwroot/mod/quiz/report.php?q=$quiz->id&amp;mode=$report",
+                                get_string($report, 'quiz_'.$report));
+        if ($report == $mode) {
+            $currenttab = $report;
         }
-        $tabs[] = $row;
     }
+    $tabs[] = $row;
+}
 
-    if ($currenttab == 'edit' and isset($mode)) {
-        $inactive[] = 'edit';
-        $activated[] = 'edit';
+if ($currenttab == 'edit' and isset($mode)) {
+    $inactive[] = 'edit';
+    $activated[] = 'edit';
 
-        $row  = array();
-        $currenttab = $mode;
+    $row  = array();
+    $currenttab = $mode;
 
-        $strquizzes = get_string('modulenameplural', 'quiz');
-        $strquiz = get_string('modulename', 'quiz');
-        $streditingquiz = get_string("editinga", "moodle", $strquiz);
-        $strupdate = get_string('updatethis', 'moodle', $strquiz);
-        $row[] = new tabobject('editq', "$CFG->wwwroot/mod/quiz/edit.php?quizid=$quiz->id", $strquiz, $streditingquiz);
-        questionbank_navigation_tabs($row, $context, $course->id);
-        $tabs[] = $row;
-    }
+    $strquizzes = get_string('modulenameplural', 'quiz');
+    $strquiz = get_string('modulename', 'quiz');
+    $streditingquiz = get_string("editinga", "moodle", $strquiz);
+    $strupdate = get_string('updatethis', 'moodle', $strquiz);
+    $row[] = new tabobject('editq', "$CFG->wwwroot/mod/quiz/edit.php?quizid=$quiz->id", $strquiz, $streditingquiz);
+    questionbank_navigation_tabs($row, $context, $course->id);
+    $tabs[] = $row;
+}
 
-    print_tabs($tabs, $currenttab, $inactive, $activated);
+print_tabs($tabs, $currenttab, $inactive, $activated);
 
 ?>
index b28204018488f93eacc2df0874b1bf41bd3b34b8..3ea031a9bb167f88ed7f9e1201d2b7f86490a64c 100644 (file)
     require_login($course->id, false);
   
     $SESSION->returnurl = $FULLME;
-    $SESSION->fromurl = $FULLME;
 
     // Print basic page layout.
-
     $streditingquestions = get_string('editquestions', "quiz");
 
     // TODO: generalise this to any activity
index d234e983da3e3d31acb93b5bf0849a63dc9db226..ede2540a4dbfa83a4479a2d08538565ce96754ac 100644 (file)
@@ -47,9 +47,9 @@
     } else {
         $sortorder = isset($SESSION->questionsortorder) ? $SESSION->questionsortorder : 'qtype, name ASC';
     }
+    $SESSION->fromurl = $FULLME;
 
 /// Now, check for commands on this page and modify variables as necessary
-
     if (isset($_REQUEST['move']) and confirm_sesskey()) { /// Move selected questions to new category
         $tocategoryid = required_param('category', PARAM_INT);
         if (!$tocategory = get_record('question_categories', 'id', $tocategoryid)) {