# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/blocklib.php
--- moodle/lib/blocklib.php Base (1.248)
+++ moodle/lib/blocklib.php Locally Modified (Based On 1.248)
@@ -147,6 +147,11 @@
      */
     protected $movingblock = null;
 
+    /**
+     * Show only fake blocks
+     */
+    protected $fakeblocksonly = false;
+
 /// Constructor ================================================================
 
     /**
@@ -442,6 +447,12 @@
             }
         }
 
+        // Check if we need to load normal blocks
+        if ($this->fakeblocksonly) {
+            $this->birecordsbyregion = $this->prepare_per_region_arrays();
+            return;
+        }
+
         if (is_null($includeinvisible)) {
             $includeinvisible = $this->page->user_is_editing();
         }
@@ -1316,7 +1327,11 @@
         $this->page->ensure_param_not_in_url('bui_newweight');
         return true;
     }
+
+    public function show_only_fake_blocks($setting=true) {
+        $this->fakeblocksonly = $setting;
 }
+}
 
 /// Helper functions for working with block classes ============================
 
Index: moodle/lib/navigationlib.php
--- moodle/lib/navigationlib.php Base (1.124)
+++ moodle/lib/navigationlib.php Locally Modified (Based On 1.124)
@@ -560,7 +560,16 @@
         }
         return $nodes;
     }
+
+    /**
+     * Removes this node if it is empty
+     */
+    public function trim_if_empty() {
+        if ($this->children->count()==0) {
+            $this->remove();
 }
+    }
+}
 
 /**
  * Navigation node collection
@@ -2712,23 +2721,10 @@
             $coursenode->add(get_string('reset'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/return', ''));
         }
 
-        // Manage questions
-        $questioncaps = array('moodle/question:add',
-                              'moodle/question:editmine',
-                              'moodle/question:editall',
-                              'moodle/question:viewmine',
-                              'moodle/question:viewall',
-                              'moodle/question:movemine',
-                              'moodle/question:moveall');
-        if (has_any_capability($questioncaps, $coursecontext)) {
-            $questionlink = $CFG->wwwroot.'/question/edit.php';
-        } else if (has_capability('moodle/question:managecategory', $coursecontext)) {
-            $questionlink = $CFG->wwwroot.'/question/category.php';
-        }
-        if (isset($questionlink)) {
-            $url = new moodle_url($questionlink, array('courseid'=>$course->id));
-            $coursenode->add(get_string('questions','quiz'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/questions', ''));
-        }
+        // Questions
+        require_once($CFG->dirroot.'/question/editlib.php');
+        $questionsnode = $coursenode->add(get_string('questions','quiz'), null, self::TYPE_CONTAINER, null, null, new pix_icon('i/questions', ''));
+        question_extend_settings_navigation($questionsnode, $coursecontext)->trim_if_empty();
 
         // Repository Instances
         require_once($CFG->dirroot.'/repository/lib.php');
Index: moodle/lib/questionlib.php
--- moodle/lib/questionlib.php Base (1.223)
+++ moodle/lib/questionlib.php Locally Modified (Based On 1.223)
@@ -868,27 +868,6 @@
 }
 
 /**
- * @global object
- * @global object
- * @param array $row tab objects
- * @param question_edit_contexts $contexts object representing contexts available from this context
- * @param string $querystring to append to urls
- * */
-function questionbank_navigation_tabs(&$row, $contexts, array $params) {
-    global $CFG, $QUESTION_EDITTABCAPS;
-    $tabs = array(
-            'questions' =>array(new moodle_url('/question/edit.php', $params), get_string('questions', 'quiz'), get_string('editquestions', 'quiz')),
-            'categories' =>array(new moodle_url('/question/category.php', $params), get_string('categories', 'quiz'), get_string('editqcats', 'quiz')),
-            'import' =>array(new moodle_url('/question/import.php', $params), get_string('import', 'quiz'), get_string('importquestions', 'quiz')),
-            'export' =>array(new moodle_url('/question/export.php', $params), get_string('export', 'quiz'), get_string('exportquestions', 'quiz')));
-    foreach ($tabs as $tabname => $tabparams){
-        if ($contexts->have_one_edit_tab_cap($tabname)) {
-            $row[] = new tabobject($tabname, $tabparams[0], $tabparams[1], $tabparams[2]);
-        }
-    }
-}
-
-/**
  * Given a list of ids, load the basic information about a set of questions from the questions table.
  * The $join and $extrafields arguments can be used together to pull in extra data.
  * See, for example, the usage in mod/quiz/attemptlib.php, and
@@ -3009,3 +2988,189 @@
     }
     return md5($attemptid . "_" . $user->secret . "_" . $questionid . "_" . $sessionid);
 }
+
+/**
+ * Adds question bank setting links to the given navigaiton node if caps are met.
+ *
+ * @param navigation_node $questionnode
+ * @param stdClass $context
+ * @return navigation_node
+ */
+function question_extend_settings_navigation(navigation_node $questionnode, $context) {
+    global $PAGE;
+
+    if ($context->contextlevel == CONTEXT_COURSE) {
+        $params = array('courseid'=>$context->instanceid);
+    } else if ($context->contextlevel == CONTEXT_MODULE) {
+        $params = array('cmid'=>$context->instanceid);
+    } else {
+        return;
+    }
+
+    $contexts = new question_edit_contexts($context);
+    if ($contexts->have_one_edit_tab_cap('questions')) {
+        $questionnode->add(get_string('questions', 'quiz'), new moodle_url('/question/edit.php', $params));
+    }
+    if ($contexts->have_one_edit_tab_cap('categories')) {
+        $questionnode->add(get_string('categories', 'quiz'), new moodle_url('/question/category.php', $params));
+    }
+    if ($contexts->have_one_edit_tab_cap('import')) {
+        $questionnode->add(get_string('import', 'quiz'), new moodle_url('/question/import.php', $params));
+    }
+    if ($contexts->have_one_edit_tab_cap('export')) {
+        $questionnode->add(get_string('export', 'quiz'), new moodle_url('/question/export.php', $params));
+    }
+
+    return $questionnode;
+}
+
+class question_edit_contexts {
+
+    public static $CAPS = array(
+        'editq' => array('moodle/question:add',
+            'moodle/question:editmine',
+            'moodle/question:editall',
+            'moodle/question:viewmine',
+            'moodle/question:viewall',
+            'moodle/question:usemine',
+            'moodle/question:useall',
+            'moodle/question:movemine',
+            'moodle/question:moveall'),
+        'questions'=>array('moodle/question:add',
+            'moodle/question:editmine',
+            'moodle/question:editall',
+            'moodle/question:viewmine',
+            'moodle/question:viewall',
+            'moodle/question:movemine',
+            'moodle/question:moveall'),
+        'categories'=>array('moodle/question:managecategory'),
+        'import'=>array('moodle/question:add'),
+        'export'=>array('moodle/question:viewall', 'moodle/question:viewmine'));
+
+    protected $allcontexts;
+
+    /**
+     * @param current context
+     */
+    public function question_edit_contexts($thiscontext){
+        $pcontextids = get_parent_contexts($thiscontext);
+        $contexts = array($thiscontext);
+        foreach ($pcontextids as $pcontextid){
+            $contexts[] = get_context_instance_by_id($pcontextid);
+        }
+        $this->allcontexts = $contexts;
+    }
+    /**
+     * @return array all parent contexts
+     */
+    public function all(){
+        return $this->allcontexts;
+    }
+    /**
+     * @return object lowest context which must be either the module or course context
+     */
+    public function lowest(){
+        return $this->allcontexts[0];
+    }
+    /**
+     * @param string $cap capability
+     * @return array parent contexts having capability, zero based index
+     */
+    public function having_cap($cap){
+        $contextswithcap = array();
+        foreach ($this->allcontexts as $context){
+            if (has_capability($cap, $context)){
+                $contextswithcap[] = $context;
+            }
+        }
+        return $contextswithcap;
+    }
+    /**
+     * @param array $caps capabilities
+     * @return array parent contexts having at least one of $caps, zero based index
+     */
+    public function having_one_cap($caps){
+        $contextswithacap = array();
+        foreach ($this->allcontexts as $context){
+            foreach ($caps as $cap){
+                if (has_capability($cap, $context)){
+                    $contextswithacap[] = $context;
+                    break; //done with caps loop
+                }
+            }
+        }
+        return $contextswithacap;
+    }
+    /**
+     * @param string $tabname edit tab name
+     * @return array parent contexts having at least one of $caps, zero based index
+     */
+    public function having_one_edit_tab_cap($tabname){
+        return $this->having_one_cap(self::$CAPS[$tabname]);
+    }
+    /**
+     * Has at least one parent context got the cap $cap?
+     *
+     * @param string $cap capability
+     * @return boolean
+     */
+    public function have_cap($cap){
+        return (count($this->having_cap($cap)));
+    }
+
+    /**
+     * Has at least one parent context got one of the caps $caps?
+     *
+     * @param array $caps capability
+     * @return boolean
+     */
+    public function have_one_cap($caps){
+        foreach ($caps as $cap) {
+            if ($this->have_cap($cap)) {
+                return true;
+            }
+        }
+        return false;
+    }
+    /**
+     * Has at least one parent context got one of the caps for actions on $tabname
+     *
+     * @param string $tabname edit tab name
+     * @return boolean
+     */
+    public function have_one_edit_tab_cap($tabname){
+        return $this->have_one_cap(self::$CAPS[$tabname]);
+    }
+    /**
+     * Throw error if at least one parent context hasn't got the cap $cap
+     *
+     * @param string $cap capability
+     */
+    public function require_cap($cap){
+        if (!$this->have_cap($cap)){
+            print_error('nopermissions', '', '', $cap);
+        }
+    }
+    /**
+     * Throw error if at least one parent context hasn't got one of the caps $caps
+     *
+     * @param array $cap capabilities
+     */
+     public function require_one_cap($caps) {
+        if (!$this->have_one_cap($caps)) {
+            $capsstring = join($caps, ', ');
+            print_error('nopermissions', '', '', $capsstring);
+        }
+    }
+
+    /**
+     * Throw error if at least one parent context hasn't got one of the caps $caps
+     *
+     * @param string $tabname edit tab name
+     */
+    public function require_one_edit_tab_cap($tabname){
+        if (!$this->have_one_edit_tab_cap($tabname)) {
+            print_error('nopermissions', '', '', 'access question edit tab '.$tabname);
+        }
+    }
+}
\ No newline at end of file
Index: moodle/mod/quiz/addrandom.php
--- moodle/mod/quiz/addrandom.php Base (1.18)
+++ moodle/mod/quiz/addrandom.php Locally Modified (Based On 1.18)
@@ -79,6 +79,7 @@
 // Print basic page layout.
 $PAGE->navbar->add($streditingquiz);
 $PAGE->set_title($streditingquiz);
+$PAGE->set_heading($course->fullname);
 echo $OUTPUT->header();
 
 if (!$quizname = $DB->get_field($cm->modname, 'name', array('id' => $cm->instance))) {
Index: moodle/mod/quiz/attempt.php
--- moodle/mod/quiz/attempt.php Base (1.181)
+++ moodle/mod/quiz/attempt.php Locally Modified (Based On 1.181)
@@ -36,7 +36,7 @@
     $attemptobj = quiz_attempt::create($attemptid);
 
 /// Check login.
-    require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
+    require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
 
 /// Check that this attempt belongs to this user.
     if ($attemptobj->get_userid() != $USER->id) {
@@ -88,6 +88,10 @@
     $PAGE->requires->js('/lib/overlib/overlib.js', true);
     $PAGE->requires->js('/lib/overlib/overlib_cssstyle.js', true);
 
+    if (empty($attemptobj->get_quiz()->showblocks)) {
+        $PAGE->blocks->show_only_fake_blocks();
+    }
+
     // Arrange for the navigation to be displayed.
     $navbc = $attemptobj->get_navigation_panel('quiz_attempt_nav_panel', $page);
     $firstregion = reset($PAGE->blocks->get_regions());
@@ -96,6 +100,7 @@
     // Print the page header
     $title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number());
     $headtags = $attemptobj->get_html_head_contributions($page);
+    $PAGE->set_heading($attemptobj->get_course()->fullname);
     if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
         $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' .
                 format_string($attemptobj->get_quiz_name()), $headtags);
@@ -110,10 +115,9 @@
     echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib
 
     if ($attemptobj->is_preview_user()) {
-    /// Show the tab bar.
-        $currenttab = 'preview';
-        include('tabs.php');
 
+        $quiz = $attemptobj->get_quiz();
+
     /// Heading and tab bar.
         echo $OUTPUT->heading(get_string('previewquiz', 'quiz', format_string($quiz->name)));
         $attemptobj->print_restart_preview_button();
Index: moodle/mod/quiz/comment.php
--- moodle/mod/quiz/comment.php Base (1.22)
+++ moodle/mod/quiz/comment.php Locally Modified (Based On 1.22)
@@ -37,6 +37,7 @@
             $attemptobj->get_quizid(), $attemptobj->get_cmid());
 
 /// Print the page header
+    $PAGE->set_pagelayout('popup');
     echo $OUTPUT->header();
     echo $OUTPUT->heading(format_string($attemptobj->get_question($questionid)->name));
 
Index: moodle/mod/quiz/db/upgrade.php
--- moodle/mod/quiz/db/upgrade.php Base (1.35)
+++ moodle/mod/quiz/db/upgrade.php Locally Modified (Based On 1.35)
@@ -321,6 +321,21 @@
         upgrade_mod_savepoint($result, 2010030501, 'quiz');
     }
 
+    if ($result && $oldversion < 2010051800) {
+
+    /// Define field showblocks to be added to quiz
+        $table = new xmldb_table('quiz');
+        $field = new xmldb_field('showblocks', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'showuserpicture');
+
+    /// Conditionally launch add field showblocks
+        if (!$dbman->field_exists($table, $field)) {
+            $dbman->add_field($table, $field);
+        }
+
+    /// quiz savepoint reached
+        upgrade_mod_savepoint($result, 2010051800, 'quiz');
+    }
+
     return $result;
 }
 
Index: moodle/mod/quiz/edit.php
--- moodle/mod/quiz/edit.php Base (1.187)
+++ moodle/mod/quiz/edit.php Locally Modified (Based On 1.187)
@@ -112,20 +112,24 @@
     return $out;
 }
 
+//these params are only passed from page request to request while we stay on
+//this page otherwise they would go in question_edit_setup
+$quiz_reordertool = optional_param('reordertool', 0, PARAM_BOOL);
+$quiz_qbanktool = optional_param('qbanktool', -1, PARAM_BOOL);
+
 list($thispageurl, $contexts, $cmid, $cm, $quiz, $pagevars) =
         question_edit_setup('editq', '/mod/quiz/edit.php', true);
-$PAGE->set_url($thispageurl);
-$PAGE->set_pagelayout('base');
+$url = new moodle_url($thispageurl);
+if ($quiz_reordertool) {
+    $url->param('reordertool', $quiz_reordertool);
+}
+$PAGE->set_url($url);
 
 $defaultcategoryobj = question_make_default_categories($contexts->all());
 $defaultcategoryid = $defaultcategoryobj->id;
 $defaultcategorycontext = $defaultcategoryobj->contextid;
 $defaultcategory = $defaultcategoryid . ',' . $defaultcategorycontext;
 
-//these params are only passed from page request to request while we stay on
-//this page otherwise they would go in question_edit_setup
-$quiz_reordertool = optional_param('reordertool', 0, PARAM_BOOL);
-$quiz_qbanktool = optional_param('qbanktool', -1, PARAM_BOOL);
 if ($quiz_qbanktool > -1) {
     $thispageurl->param('qbanktool', $quiz_qbanktool);
     set_user_preference('quiz_qbanktool_open', $quiz_qbanktool);
@@ -165,6 +169,8 @@
 add_to_log($cm->course, 'quiz', 'editquestions',
             "view.php?id=$cm->id", "$quiz->id", $cm->id);
 
+$PAGE->set_pagelayout('admin');
+
 // You need mod/quiz:manage in addition to question capabilities to access this page.
 require_capability('mod/quiz:manage', $contexts->lowest());
 
@@ -435,17 +441,10 @@
 
 // End of process commands =====================================================
 
-// Print the header.
-$questionbankmanagement = '<a href="'.$CFG->wwwroot.
-        '/question/edit.php?courseid='.$course->id.'">'.
-        get_string('questionbankmanagement', 'quiz').'</a> ';
-
-$PAGE->navbar->add($pagetitle);
 $PAGE->requires->skip_link_to('questionbank',  get_string('skipto', 'access', get_string('questionbank', 'question')));
 $PAGE->requires->skip_link_to('quizcontentsblock',  get_string('skipto', 'access', get_string('questionsinthisquiz', 'quiz')));
-
 $PAGE->set_title($pagetitle);
-$PAGE->set_button($questionbankmanagement);
+$PAGE->set_heading($course->fullname);
 echo $OUTPUT->header();
 
 // Initialise the JavaScript.
@@ -459,14 +458,6 @@
 $PAGE->requires->data_for_js('quiz_edit_config', $quizeditconfig);
 $PAGE->requires->js('/mod/quiz/edit.js');
 
-// Print the tabs.
-$currenttab = 'edit';
-$mode = 'editq';
-if ($quiz_reordertool) {
-    $mode = 'reorder';
-}
-include('tabs.php');
-
 if ($quiz_qbanktool) {
     $bankclass = '';
     $quizcontentsclass = '';
@@ -568,7 +559,12 @@
     echo '</div></fieldset></form></div></div>';
 }
 
-echo '<div class="' . $currenttab . '">';
+if ($quiz_reordertool) {
+    echo '<div class="reorder">';
+} else {
+    echo '<div class="editq">';
+}
+
 quiz_print_question_list($quiz, $thispageurl, true,
         $quiz_reordertool, $quiz_qbanktool, $quizhasattempts);
 echo '</div>';
Index: moodle/mod/quiz/index.php
--- moodle/mod/quiz/index.php Base (1.73)
+++ moodle/mod/quiz/index.php Locally Modified (Based On 1.73)
@@ -36,6 +36,7 @@
     $PAGE->navbar->add($strquizzes);
     $PAGE->set_title($strquizzes);
     $PAGE->set_button($streditquestions);
+    $PAGE->set_heading($course->fullname);
     echo $OUTPUT->header();
 
 // Get all the appropriate data
Index: moodle/mod/quiz/lang/en/quiz.php
--- moodle/mod/quiz/lang/en/quiz.php Base (1.23)
+++ moodle/mod/quiz/lang/en/quiz.php Locally Modified (Based On 1.23)
@@ -183,6 +183,7 @@
 $string['configrequirepassword'] = 'Students must enter this password before they can attempt the quiz.';
 $string['configrequiresubnet'] = 'Students can only attempt the quiz from these computers.';
 $string['configreviewoptions'] = 'These options control what information users can see when they review a quiz attempt or look at the quiz reports.';
+$string['configshowblocks'] = 'Show blocks during quiz attempts.';
 $string['configshowuserpicture'] = 'Show the user\'s picture on screen during attempts.';
 $string['configshufflequestions'] = 'If you enable this option, then the order of questions in  the quiz will be randomly shuffled each time a student attempts the quiz.';
 $string['configshufflewithin'] = 'If you enable this option, then the parts making up the individual questions will be randomly shuffled each time a student starts an attempt at this quiz, provided the option is also enabled in the question settings.';
@@ -751,6 +752,8 @@
 $string['shortanswer'] = 'Short Answer';
 $string['show'] = 'Show';
 $string['showall'] = 'Show all questions on one page';
+$string['showblocks'] = 'Show blocks during quiz attempts';
+$string['showblocks_help'] = 'If set to yes then normal blocks will be shown during quiz attempts';
 $string['showbreaks'] = 'Show page breaks';
 $string['showcategorycontents'] = 'Show category contents {$a->arrow}';
 $string['showcorrectanswer'] = 'In feedback, show correct answers?';
Index: moodle/mod/quiz/lib.php
--- moodle/mod/quiz/lib.php Base (1.364)
+++ moodle/mod/quiz/lib.php Locally Modified (Based On 1.364)
@@ -1594,20 +1594,38 @@
  * body of code as there is no guarantee that during an AJAX request they are
  * available
  *
- * @param navigation_node $navigation The quiz node within the global navigation
+ * @param navigation_node $quiznode The quiz node within the global navigation
  * @param stdClass $course The course object returned from the DB
  * @param stdClass $module The module object returned from the DB
  * @param stdClass $cm The course module isntance returned from the DB
  */
-function quiz_extend_navigation($navigation, $course, $module, $cm) {
-    /**
-     * This is currently just a stub so  that it can be easily expanded upon.
-     * When expanding just remove this comment and the line below and then add
-     * you content.
-     */
-    $navigation->nodetype = navigation_node::NODETYPE_LEAF;
+function quiz_extend_navigation($quiznode, $course, $module, $cm) {
+    global $CFG;
+
+    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
+    if (has_capability('mod/quiz:view', $context)) {
+        $url = new moodle_url('/mod/quiz/view.php', array('id'=>$cm->id));
+        $quiznode->add(get_string('info', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/info', ''));
 }
 
+    if (has_capability('mod/quiz:viewreports', $context)) {
+        $url = new moodle_url('/mod/quiz/report.php', array('q'=>$cm->instance));
+        $reportnode = $quiznode->add(get_string('results', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
+
+        require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php');
+        $reportlist = quiz_report_list($context);
+        foreach ($reportlist as $report) {
+            if ($report != 'overview') {
+                $url = new moodle_url('/mod/quiz/report.php', array('q'=>$cm->instance, 'mode'=>$report));
+            } else {
+                $url = new moodle_url('/mod/quiz/report.php', array('q'=>$cm->instance));
+            }
+            $reportnode->add(get_string($report, 'quiz_'.$report), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/item', ''));
+        }
+    }
+}
+
 /**
  * This function extends the settings navigation block for the site.
  *
@@ -1620,27 +1638,39 @@
 function quiz_extend_settings_navigation($settings, $quiznode) {
     global $PAGE, $CFG;
 
-    if (has_capability('mod/quiz:view', $PAGE->cm->context)) {
-        $url = new moodle_url('/mod/quiz/view.php', array('id'=>$PAGE->cm->id));
-        $quiznode->add(get_string('info', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/info', ''));
+    /**
+     * Require {@link questionlib.php}
+     * Included here as we only ever want to include this file if we really need to.
+     */
+    require_once($CFG->libdir . '/questionlib.php');
+
+    if (has_capability('mod/quiz:manageoverrides', $PAGE->cm->context)) {
+        $overrides = $quiznode->add(get_string('overrides', 'quiz'));
+
+        $url = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$PAGE->cm->id));
+        $overrides->add(get_string('groupoverrides', 'quiz'), $url, navigation_node::TYPE_SETTING);
+        $overrides->add(get_string('useroverrides', 'quiz'), new moodle_url($url, array('mode'=>'user')), navigation_node::TYPE_SETTING);
     }
-    if (has_capability('mod/quiz:viewreports', $PAGE->cm->context)) {
-        $url = new moodle_url('/mod/quiz/report.php', array('q'=>$PAGE->cm->instance));
-        $reportnode = $quiznode->add(get_string('results', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
 
-        require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php');
-        $reportlist = quiz_report_list($PAGE->cm->context);
-        foreach ($reportlist as $report) {
-            $url = new moodle_url('/mod/quiz/report.php', array('q'=>$PAGE->cm->instance, 'mode'=>$report));
-            $reportnode->add(get_string($report, 'quiz_'.$report), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/item', ''));
+    if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
+        $editnode = $quiznode->add(get_string('edit'));
+        
+        $url = new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id));
+        $text = get_string("editinga", "moodle", get_string('modulename', 'quiz'));
+        $editnode->add($text, $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('t/edit', ''));
+
+        $url = new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id, 'reordertool'=>'1'));
+        $editnode->add(get_string('orderandpaging','quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('t/edit', ''));
         }
-    }
+
     if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
         $url = new moodle_url('/mod/quiz/startattempt.php', array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
         $quiznode->add(get_string('preview', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('t/preview', ''));
     }
-    if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
-        $url = new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id));
-        $quiznode->add(get_string('edit'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('t/edit', ''));
+
+    $questionnode = $quiznode->add(get_string('questionbankmanagement', 'quiz'));
+    question_extend_settings_navigation($questionnode, $PAGE->context);
+    if ($questionnode->children->count() < 1) {
+        $questionnode->remove();
     }
     }
Index: moodle/mod/quiz/mod_form.php
--- moodle/mod/quiz/mod_form.php Base (1.55)
+++ moodle/mod/quiz/mod_form.php Locally Modified (Based On 1.55)
@@ -233,6 +233,12 @@
         $mform->setAdvanced('questiondecimalpoints', $quizconfig->questiondecimalpoints_adv);
         $mform->setDefault('questiondecimalpoints', $quizconfig->questiondecimalpoints);
 
+        // Show blocks during quiz attempt
+        $mform->addElement('selectyesno', 'showblocks', get_string('showblocks', 'quiz'));
+        $mform->setHelpButton('showblocks', array('showblocks', get_string('showblocks', 'quiz'), 'quiz'));
+        $mform->setAdvanced('showblocks', $quizconfig->showblocks_adv);
+        $mform->setDefault('showblocks', $quizconfig->showblocks);
+
 //-------------------------------------------------------------------------------
         $mform->addElement('header', 'security', get_string('extraattemptrestrictions', 'quiz'));
 
Index: moodle/mod/quiz/overridedelete.php
--- moodle/mod/quiz/overridedelete.php Base (1.1)
+++ moodle/mod/quiz/overridedelete.php Locally Modified (Based On 1.1)
@@ -41,10 +41,11 @@
 if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $quiz->course)) {
     print_error('invalidcoursemodule');
 }
+$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
 
 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
-require_login($cm->course, false, $cm);
+require_login($course, false, $cm);
 
 // Check the user has the required capabilities to modify an override
 require_capability('mod/quiz:manageoverrides', $context);
@@ -79,7 +80,7 @@
 $PAGE->set_url($url);
 $PAGE->navbar->add($title);
 $PAGE->set_title($title);
-$PAGE->set_heading($stroverride);
+$PAGE->set_heading($course->fullname);
 
 echo $OUTPUT->header();
 
Index: moodle/mod/quiz/overrideedit.php
--- moodle/mod/quiz/overrideedit.php Base (1.1)
+++ moodle/mod/quiz/overrideedit.php Locally Modified (Based On 1.1)
@@ -58,6 +58,7 @@
 } else {
     print_error('invalidcoursemodule');
 }
+$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
 
 $url = new moodle_url('/mod/quiz/overrideedit.php');
 if ($action) {
@@ -71,7 +72,7 @@
 
 $PAGE->set_url($url);
 
-require_login($cm->course, false, $cm);
+require_login($course, false, $cm);
 
 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
@@ -191,7 +192,7 @@
 $pagetitle = get_string('editoverride', 'quiz');
 $PAGE->navbar->add($pagetitle);
 $PAGE->set_title($pagetitle);
-
+$PAGE->set_heading($course->fullname);
 echo $OUTPUT->header();
 echo $OUTPUT->heading($pagetitle);
 
Index: moodle/mod/quiz/overrides.php
--- moodle/mod/quiz/overrides.php Base (1.3)
+++ moodle/mod/quiz/overrides.php Locally Modified (Based On 1.3)
@@ -39,6 +39,7 @@
 if (! $quiz = $DB->get_record('quiz', array('id' => $cm->instance))) {
     print_error('invalidcoursemodule');
 }
+$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
 
 // Get the course groups
 $groups = groups_get_all_groups($cm->course);
@@ -60,7 +61,7 @@
 
 $PAGE->set_url($url);
 
-require_login($cm->course, false, $cm);
+require_login($course, false, $cm);
 
 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
@@ -70,6 +71,7 @@
 // Display a list of overrides
 
 $PAGE->set_title(get_string('overrides', 'quiz'));
+$PAGE->set_heading($course->fullname);
 echo $OUTPUT->header();
 
 // Delete orphaned group overrides
@@ -106,10 +108,6 @@
 $params = array($quiz->id);
 $overrides = $DB->get_records_sql($sql, $params);
 
-// Print heading and tabs (if there is more than one).
-$currenttab = 'overrides';
-include('tabs.php');
-
 // Initialise table
 $table = new html_table();
 $table->headspan = array(1,2,1);
Index: moodle/mod/quiz/report.php
--- moodle/mod/quiz/report.php Base (1.55)
+++ moodle/mod/quiz/report.php Locally Modified (Based On 1.55)
@@ -37,12 +37,12 @@
     }
 
     $url = new moodle_url('/mod/quiz/report.php');
-    if ($id !== 0) {
+    if ($id) {
         $url->param('id', $id);
     } else {
         $url->param('q', $q);
     }
-    if ($mode !== '') {
+    if ($mode) {
         $url->param('mode', $mode);
     }
     $PAGE->set_url($url);
Index: moodle/mod/quiz/report/default.php
--- moodle/mod/quiz/report/default.php Base (1.24)
+++ moodle/mod/quiz/report/default.php Locally Modified (Based On 1.24)
@@ -28,11 +28,8 @@
         $strquiz  = get_string("modulename", "quiz");
     /// Print the page header
         $PAGE->set_title(format_string($quiz->name));
+        $PAGE->set_heading($course->fullname);
         echo $OUTPUT->header();
-    /// Print the tabs
-        $currenttab = 'reports';
-        $mode = $reportmode;
-        require($CFG->dirroot . '/mod/quiz/tabs.php');
         $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
         if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
             echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
Index: moodle/mod/quiz/review.php
--- moodle/mod/quiz/review.php Base (1.112)
+++ moodle/mod/quiz/review.php Locally Modified (Based On 1.112)
@@ -27,7 +27,7 @@
     $attemptobj = quiz_attempt::create($attemptid);
 
 /// Check login.
-    require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
+    require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
     $attemptobj->check_review_capability();
 
 /// Create an object to manage all the other (non-roles) access rules.
@@ -80,6 +80,10 @@
         $strreviewtitle = get_string('reviewofattempt', 'quiz', $attemptobj->get_attempt_number());
     }
 
+    if (empty($attemptobj->get_quiz()->showblocks)) {
+        $PAGE->blocks->show_only_fake_blocks();
+    }
+
 /// Arrange for the navigation to be displayed.
     $navbc = $attemptobj->get_navigation_panel('quiz_review_nav_panel', $page, $showall);
     $firstregion = reset($PAGE->blocks->get_regions());
@@ -94,26 +98,17 @@
         $accessmanager->setup_secure_page($attemptobj->get_course()->shortname.': '.format_string($attemptobj->get_quiz_name()), $headtags);
     } elseif ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) {
         $PAGE->set_title($attemptobj->get_course()->shortname . ': '.format_string($attemptobj->get_quiz_name()));
+        $PAGE->set_heading($attemptobj->get_course()->fullname);
         $PAGE->set_cacheable(false);
         echo $OUTPUT->header();
     } else {
         $attemptobj->navigation($strreviewtitle);
         $PAGE->set_title(format_string($attemptobj->get_quiz_name()));
+        $PAGE->set_heading($attemptobj->get_course()->fullname);
         echo $OUTPUT->header();
     }
     echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib
 
-/// Print tabs if they should be there.
-    if ($attemptobj->is_preview_user()) {
-        if ($attemptobj->is_own_attempt()) {
-            $currenttab = 'preview';
-        } else {
-            $currenttab = 'reports';
-            $mode = '';
-        }
-        include('tabs.php');
-    }
-
 /// Print heading.
     if ($attemptobj->is_preview_user() && $attemptobj->is_own_attempt()) {
         $attemptobj->print_restart_preview_button();
Index: moodle/mod/quiz/settingstree.php
--- moodle/mod/quiz/settingstree.php Base (1.8)
+++ moodle/mod/quiz/settingstree.php Locally Modified (Based On 1.8)
@@ -126,6 +126,11 @@
         get_string('decimalplacesquestion', 'quiz'), get_string('configdecimalplacesquestion', 'quiz'),
         array('value' => -1, 'fix' => true), $options));
 
+// Show blocks during quiz attempts
+$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/showblocks',
+        get_string('showblocks', 'quiz'), get_string('configshowblocks', 'quiz'),
+        array('value' => 0, 'adv' => true)));
+
 // Password.
 $quizsettings->add(new admin_setting_configtext_with_advanced('quiz/password',
         get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'),
Index: moodle/mod/quiz/styles.css
--- moodle/mod/quiz/styles.css Base (1.4)
+++ moodle/mod/quiz/styles.css Locally Modified (Based On 1.4)
@@ -146,10 +146,13 @@
 .generalbox#passwordbox { /* Should probably match .generalbox#intro above */width:70%;margin-left:auto;margin-right:auto;}
 #passwordform {margin: 1em 0;}
 
+.questionbankwindow.block {float:right;width:30%;right:0.3em;padding-bottom:0.5em;display:block;border-width:0;}
+.questionbankwindow.block .content {padding:0;}
 .questionbankwindow .choosecategory,
 .questionbankwindow .createnewquestion {padding: 0.3em;}
 .questionbankwindow .createnewquestion .singlebutton {display: inline;}
 .questionbankwindow #catmenu_jump {display: block;}
+
 .questionbank div.categoryquestionscontainer,
 .questionbank .categorysortopotionscontainer,
 .questionbank .categorypagingbarcontainer,
@@ -172,8 +175,8 @@
 /** Mod quiz edit **/
 #page-mod-quiz-edit h2.main{display:inline;padding-right:1em;clear:left;}
 
-#page-mod-quiz-edit div.block {float:right;width:30%;right:0.3em;padding-bottom:0.5em;display:block;border-width:0;}
-#page-mod-quiz-edit div.block .content {padding:0;}
\ No newline at end of file
+
+
\ No newline at end of file
 #page-mod-quiz-edit div.quizcontents {float:left;width:70%;display:block;clear:left;}
 #page-mod-quiz-edit div.quizwhenbankcollapsed {width:100%;}
 #page-mod-quiz-edit div.quizpage {display:block;clear:both;width:100%;}
Index: moodle/mod/quiz/summary.php
--- moodle/mod/quiz/summary.php Base (1.28)
+++ moodle/mod/quiz/summary.php Locally Modified (Based On 1.28)
@@ -17,7 +17,7 @@
 $attemptobj = quiz_attempt::create($attemptid);
 
 /// Check login.
-require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
+require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
 
 /// If this is not our own attempt, display an error.
 if ($attemptobj->get_userid() != $USER->id) {
@@ -46,6 +46,10 @@
 $attemptobj->load_questions();
 $attemptobj->load_question_states();
 
+if (empty($attemptobj->get_quiz()->showblocks)) {
+    $PAGE->blocks->show_only_fake_blocks();
+}
+
 /// Print the page header
 $PAGE->requires->js('/mod/quiz/quiz.js');
 $title = get_string('summaryofattempt', 'quiz');
@@ -54,20 +58,16 @@
             format_string($attemptobj->get_quiz_name()), '');
 } elseif ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) {
     $PAGE->set_title($attemptobj->get_course()->shortname . ': '.format_string($attemptobj->get_quiz_name()));
+    $PAGE->set_heading($attemptobj->get_course()->fullname);
     $PAGE->set_cacheable(false);
     echo $OUTPUT->header();
 } else {
     $attemptobj->navigation($title);
     $PAGE->set_title(format_string($attemptobj->get_quiz_name()));
+    $PAGE->set_heading($attemptobj->get_course()->fullname);
     echo $OUTPUT->header();
 }
 
-/// Print tabs if they should be there.
-if ($attemptobj->is_preview_user()) {
-    $currenttab = 'preview';
-    include('tabs.php');
-}
-
 /// Print heading.
 echo $OUTPUT->heading(format_string($attemptobj->get_quiz_name()));
 if ($attemptobj->is_preview_user()) {
Index: moodle/mod/quiz/tabs.php
--- moodle/mod/quiz/tabs.php Base (1.42)
+++ moodle/mod/quiz/tabs.php Locally Deleted
@@ -1,121 +0,0 @@
-<?php
-/**
- * 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
- */
-global $DB, $OUTPUT;
-if (empty($quiz)) {
-    if (empty($attemptobj)) {
-        print_error('cannotcallscript');
-    }
-    $quiz = $attemptobj->get_quiz();
-    $cm = $attemptobj->get_cm();
-}
-if (!isset($currenttab)) {
-    $currenttab = '';
-}
-if (!isset($cm)) {
-    $cm = get_coursemodule_from_instance('quiz', $quiz->id);
-}
-
-
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-if (!isset($contexts)){
-    $contexts = new question_edit_contexts($context);
-}
-$tabs = array();
-$row  = array();
-$inactive = array();
-$activated = array();
-$stredit=get_string('edit');
-if (has_capability('mod/quiz:view', $context)) {
-    $row[] = new tabobject('info', "$CFG->wwwroot/mod/quiz/view.php?id=$cm->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)) {
-    $strpreview = get_string('preview', 'quiz');
-    $row[] = new tabobject('preview', "$CFG->wwwroot/mod/quiz/startattempt.php?cmid=$cm->id&amp;sesskey=" . sesskey(), "<img src=\"" . $OUTPUT->pix_url('t/preview') . "\" class=\"iconsmall\" alt=\"$strpreview\" /> $strpreview", $strpreview);
-}
-if (has_capability('mod/quiz:manage', $context)) {
-    $row[] = new tabobject('edit', "$CFG->wwwroot/mod/quiz/edit.php?cmid=$cm->id", "<img src=\"" . $OUTPUT->pix_url('t/edit') . "\" class=\"iconsmall\" alt=\"$stredit\" /> $stredit",$stredit);
-}
-if (has_capability('mod/quiz:manageoverrides', $context)) {
-    $row[] = new tabobject('overrides', "$CFG->wwwroot/mod/quiz/overrides.php?cmid=$cm->id", get_string('overrides', 'quiz'));
-}
-
-if ($currenttab == 'info' && count($row) == 1) {
-    // Don't show only an info tab (e.g. to students).
-} else {
-    //$reports is passed in from report.php
-    $tabs[] = $row;
-}
-
-if ($currenttab == 'reports' and isset($mode)) {
-    $activated[] = 'reports';
-
-
-
-    $row  = array();
-    $currenttab = '';
-
-    $reportlist = quiz_report_list($context);
-
-    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;
-}
-
-if ($currenttab == 'edit' and isset($mode)) {
-    $activated[] = 'edit';
-
-    $row  = array();
-    $currenttab = $mode;
-
-    $strquiz = get_string('modulename', 'quiz');
-    $streditingquiz = get_string("editinga", "moodle", $strquiz);
-
-    if (has_capability('mod/quiz:manage', $context) && $contexts->have_one_edit_tab_cap('editq')) {
-        $row[] = new tabobject('editq', "$CFG->wwwroot/mod/quiz/edit.php?cmid=$cm->id", $stredit, $streditingquiz);
-        $row[] = new tabobject('reorder', "$CFG->wwwroot/mod/quiz/edit.php?reordertool=1&amp;cmid=$cm->id", get_string('orderandpaging','quiz'), $streditingquiz);
-    }
-    //questionbank_navigation_tabs($row, $contexts, $thispageurl->params());
-    $tabs[] = $row;
-
-}
-
-if ($currenttab == 'overrides' and isset($mode)) {
-    $activated[] = 'overrides';
-
-    $row  = array();
-    $currenttab = $mode;
-
-    $strgroup = get_string('groupoverrides', 'quiz');
-    if (empty($groups)) {
-        $inactive[] = 'group';
-    }
-    $struser = get_string('useroverrides', 'quiz');
-
-    $row[] = new tabobject('group', "$CFG->wwwroot/mod/quiz/overrides.php?cmid=$cm->id&amp;mode=group", $strgroup);
-    $row[] = new tabobject('user', "$CFG->wwwroot/mod/quiz/overrides.php?cmid=$cm->id&amp;mode=user", $struser);
-    $tabs[] = $row;
-
-}
-
-if (!$quiz->questions) {
-    $inactive += array('info', 'reports', 'preview');
-}
-
-print_tabs($tabs, $currenttab, $inactive, $activated);
-
-
Index: moodle/mod/quiz/version.php
--- moodle/mod/quiz/version.php Base (1.145)
+++ moodle/mod/quiz/version.php Locally Modified (Based On 1.145)
@@ -5,7 +5,7 @@
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2010030501;   // The (date) version of this module
+$module->version  = 2010051801;   // The (date) version of this module
 $module->requires = 2009041700;   // Requires this Moodle version
 $module->cron     = 0;            // How often should cron check this module (seconds)?
 
Index: moodle/mod/quiz/view.php
--- moodle/mod/quiz/view.php Base (1.186)
+++ moodle/mod/quiz/view.php Locally Modified (Based On 1.186)
@@ -85,10 +85,6 @@
 
     echo $OUTPUT->header();
 
-/// Print heading and tabs (if there is more than one).
-    $currenttab = 'info';
-    include('tabs.php');
-
 /// Print quiz name and description
     echo $OUTPUT->heading(format_string($quiz->name));
     if (trim(strip_tags($quiz->intro))) {
Index: moodle/question/category.php
--- moodle/question/category.php Base (1.42)
+++ moodle/question/category.php Locally Modified (Based On 1.42)
@@ -38,6 +38,7 @@
         }
     }
     $PAGE->set_url($url);
+    $PAGE->set_pagelayout('standard');
 
     $qcobject = new question_category_object($pagevars['cpage'], $thispageurl, $contexts->having_one_edit_tab_cap('categories'), $param->edit, $pagevars['cat'], $param->delete,
                                 $contexts->having_cap('moodle/question:add'));
@@ -85,28 +86,14 @@
         redirect($thispageurl);
     }
 
-    if (!$param->edit){
-        $PAGE->navbar->add($streditingcategories);
-    } else {
-        $PAGE->navbar->add($streditingcategories, $thispageurl->out());
+    if ($param->edit){
         $PAGE->navbar->add(get_string('editingcategory', 'question'));
     }
 
     $PAGE->set_title($streditingcategories);
+    $PAGE->set_heading($streditingcategories);
     echo $OUTPUT->header();
 
-    // print tabs
-    if ($cm!==null) {
-        $currenttab = 'edit';
-        $mode = 'categories';
-        ${$cm->modname} = $module;
-        include($CFG->dirroot."/mod/{$cm->modname}/tabs.php");
-    } else {
-        $currenttab = 'categories';
-        $context = $contexts->lowest();
-        include('tabs.php');
-    }
-
     // display UI
     if (!empty($param->edit)) {
         $qcobject->edit_single_category($param->edit);
Index: moodle/question/contextmove.php
--- moodle/question/contextmove.php Base (1.22)
+++ moodle/question/contextmove.php Locally Modified (Based On 1.22)
@@ -196,17 +196,6 @@
     $PAGE->set_title($streditingcategories);
     echo $OUTPUT->header();
 
-    // print tabs
-    if ($cm!==null) {
-        $currenttab = 'edit';
-        $mode = 'categories';
-        ${$cm->modname} = $module;
-        include($CFG->dirroot."/mod/{$cm->modname}/tabs.php");
-    } else {
-        $currenttab = 'categories';
-        $context = $contexts->lowest();
-        include('tabs.php');
-    }
     //parameter for get_string
     $cattomove->contextto = $contexttostring;
     if (count($urls)){
Index: moodle/question/contextmoveq.php
--- moodle/question/contextmoveq.php Base (1.18)
+++ moodle/question/contextmoveq.php Locally Modified (Based On 1.18)
@@ -175,16 +175,6 @@
 $PAGE->set_title($strmovingquestions);
 echo $OUTPUT->header();
 
-// print tabs
-if ($cm!==null) {
-    $currenttab = 'edit';
-    $mode = 'questions';
-    ${$cm->modname} = $module;
-    include($CFG->dirroot."/mod/{$cm->modname}/tabs.php");
-} else {
-    $currenttab = 'questions';
-    include('tabs.php');
-}
 //parameter for get_string
 $questionsstr = new object();
 $questionsstr->tocontext = print_context_name($tocat->context);
Index: moodle/question/edit.php
--- moodle/question/edit.php Base (1.35)
+++ moodle/question/edit.php Locally Modified (Based On 1.35)
@@ -52,7 +52,11 @@
     if (($returnurl = optional_param('returnurl', 0, PARAM_INT)) !== 0) {
         $url->param('returnurl', $returnurl);
     }
+    if (($cmid = optional_param('cmid', 0, PARAM_INT)) !== 0) {
+        $url->param('cmid', $cmid);
+    }
     $PAGE->set_url($url);
+    $PAGE->set_pagelayout('standard');
 
     list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
             question_edit_setup('questions', '/question/edit.php');
@@ -63,26 +67,10 @@
 
     $context = $contexts->lowest();
     $streditingquestions = get_string('editquestions', "quiz");
-    if ($cm!==null) {
-        $PAGE->navbar->add($streditingquestions);
         $PAGE->set_title($streditingquestions);
+    $PAGE->set_heading($streditingquestions);
         echo $OUTPUT->header();
 
-        $currenttab = 'edit';
-        $mode = 'questions';
-        ${$cm->modname} = $module;
-        include($CFG->dirroot."/mod/$cm->modname/tabs.php");
-    } else {
-        // Print basic page layout.
-        $PAGE->navbar->add($streditingquestions);
-        $PAGE->set_title($streditingquestions);
-        echo $OUTPUT->header();
-
-        // print tabs
-        $currenttab = 'questions';
-        include('tabs.php');
-    }
-
     echo '<div class="questionbankwindow boxwidthwide boxaligncenter">';
     $questionbank->display('questions', $pagevars['qpage'],
             $pagevars['qperpage'], $pagevars['qsortorder'], $pagevars['qsortorderdecoded'],
Index: moodle/question/editlib.php
--- moodle/question/editlib.php Base (1.165)
+++ moodle/question/editlib.php Locally Modified (Based On 1.165)
@@ -1522,7 +1522,7 @@
  * @return array $thispageurl, $contexts, $cmid, $cm, $module, $pagevars
  */
 function question_edit_setup($edittab, $baseurl, $requirecmid = false, $requirecourseid = true) {
-    global $QUESTION_EDITTABCAPS, $DB, $PAGE;
+    global $DB, $PAGE;
 
     //$thispageurl is used to construct urls for all question edit pages we link to from this page. It contains an array
     //of parameters that are passed from page to page.
@@ -1656,159 +1656,13 @@
 
     return array($thispageurl, $contexts, $cmid, $cm, $module, $pagevars);
 }
-class question_edit_contexts{
-    var $allcontexts;
-    /**
-     * @param current context
-     */
-    function question_edit_contexts($thiscontext){
-        $pcontextids = get_parent_contexts($thiscontext);
-        $contexts = array($thiscontext);
-        foreach ($pcontextids as $pcontextid){
-            $contexts[] = get_context_instance_by_id($pcontextid);
-        }
-        $this->allcontexts = $contexts;
-    }
-    /**
-     * @return array all parent contexts
-     */
-    function all(){
-        return $this->allcontexts;
-    }
-    /**
-     * @return object lowest context which must be either the module or course context
-     */
-    function lowest(){
-        return $this->allcontexts[0];
-    }
-    /**
-     * @param string $cap capability
-     * @return array parent contexts having capability, zero based index
-     */
-    function having_cap($cap){
-        $contextswithcap = array();
-        foreach ($this->allcontexts as $context){
-            if (has_capability($cap, $context)){
-                $contextswithcap[] = $context;
-            }
-        }
-        return $contextswithcap;
-    }
-    /**
-     * @param array $caps capabilities
-     * @return array parent contexts having at least one of $caps, zero based index
-     */
-    function having_one_cap($caps){
-        $contextswithacap = array();
-        foreach ($this->allcontexts as $context){
-            foreach ($caps as $cap){
-                if (has_capability($cap, $context)){
-                    $contextswithacap[] = $context;
-                    break; //done with caps loop
-                }
-            }
-        }
-        return $contextswithacap;
-    }
-    /**
-     * @param string $tabname edit tab name
-     * @return array parent contexts having at least one of $caps, zero based index
-     */
-    function having_one_edit_tab_cap($tabname){
-        global $QUESTION_EDITTABCAPS;
-        return $this->having_one_cap($QUESTION_EDITTABCAPS[$tabname]);
-    }
-    /**
-     * Has at least one parent context got the cap $cap?
-     *
-     * @param string $cap capability
-     * @return boolean
-     */
-    function have_cap($cap){
-        return (count($this->having_cap($cap)));
-    }
 
     /**
-     * Has at least one parent context got one of the caps $caps?
-     *
-     * @param string $cap capability
-     * @return boolean
+ * Required for legacy reasons. Was originally global then changed to class static
+ * as of Moodle 2.0
      */
-    function have_one_cap($caps){
-        foreach ($caps as $cap){
-            if ($this->have_cap($cap)){
-                return true;
-            }
-        }
-        return false;
-    }
-    /**
-     * Has at least one parent context got one of the caps for actions on $tabname
-     *
-     * @param string $tabname edit tab name
-     * @return boolean
-     */
-    function have_one_edit_tab_cap($tabname){
-        global $QUESTION_EDITTABCAPS;
-        return $this->have_one_cap($QUESTION_EDITTABCAPS[$tabname]);
-    }
-    /**
-     * Throw error if at least one parent context hasn't got the cap $cap
-     *
-     * @param string $cap capability
-     */
-    function require_cap($cap){
-        if (!$this->have_cap($cap)){
-            print_error('nopermissions', '', '', $cap);
-        }
-    }
-    /**
-     * Throw error if at least one parent context hasn't got one of the caps $caps
-     *
-     * @param array $cap capabilities
-     */
-     function require_one_cap($caps){
-        if (!$this->have_one_cap($caps)){
-            $capsstring = join($caps, ', ');
-            print_error('nopermissions', '', '', $capsstring);
-        }
-    }
-    /**
-     * Throw error if at least one parent context hasn't got one of the caps $caps
-     *
-     * @param string $tabname edit tab name
-     */
-     function require_one_edit_tab_cap($tabname){
-        if (!$this->have_one_edit_tab_cap($tabname)){
-            print_error('nopermissions', '', '', 'access question edit tab '.$tabname);
-        }
-    }
-}
+$QUESTION_EDITTABCAPS = question_edit_contexts::$CAPS;
 
-//capabilities for each page of edit tab.
-//this determines which contexts' categories are available. At least one
-//page is displayed if user has one of the capability on at least one context
-$QUESTION_EDITTABCAPS = array(
-        'editq' => array('moodle/question:add',
-            'moodle/question:editmine',
-            'moodle/question:editall',
-            'moodle/question:viewmine',
-            'moodle/question:viewall',
-            'moodle/question:usemine',
-            'moodle/question:useall',
-            'moodle/question:movemine',
-            'moodle/question:moveall'),
-        'questions'=>array('moodle/question:add',
-            'moodle/question:editmine',
-            'moodle/question:editall',
-            'moodle/question:viewmine',
-            'moodle/question:viewall',
-            'moodle/question:movemine',
-            'moodle/question:moveall'),
-        'categories'=>array('moodle/question:managecategory'),
-        'import'=>array('moodle/question:add'),
-        'export'=>array('moodle/question:viewall', 'moodle/question:viewmine'));
-
 /**
  * Make sure user is logged in as required in this context.
  */
Index: moodle/question/export.php
--- moodle/question/export.php Base (1.63)
+++ moodle/question/export.php Locally Modified (Based On 1.63)
@@ -13,6 +13,8 @@
     require_once("editlib.php");
     require_once("export_form.php");
 
+    $PAGE->set_pagelayout('standard');
+
     list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
             question_edit_setup('export', '/question/export.php');
 
@@ -34,21 +36,8 @@
     /// Header
     $PAGE->set_url($thispageurl->out());
     $PAGE->set_title($strexportquestions);
-    if ($cm!==null) {
-        $PAGE->navbar->add($strexportquestions);
+    $PAGE->set_heading($strexportquestions);
         echo $OUTPUT->header();
-        $currenttab = 'edit';
-        $mode = 'export';
-        ${$cm->modname} = $module;
-        include($CFG->dirroot."/mod/$cm->modname/tabs.php");
-    } else {
-        // Print basic page layout.
-        $PAGE->navbar->add($strexportquestions);
-        echo $OUTPUT->header();
-        // print tabs
-        $currenttab = 'export';
-        include('tabs.php');
-    }
 
     $exportfilename = default_export_filename($COURSE, $category);
     $export_form = new question_export_form($thispageurl, array('contexts'=>$contexts->having_one_edit_tab_cap('export'), 'defaultcategory'=>$pagevars['cat'],
Index: moodle/question/import.php
--- moodle/question/import.php Base (1.62)
+++ moodle/question/import.php Locally Modified (Based On 1.62)
@@ -10,9 +10,8 @@
  */
 
     require_once("../config.php");
-    require_once("editlib.php");
+    require_once("editlib.php"); // Includes lib/questionlib.php
     require_once($CFG->libdir . '/uploadlib.php');
-    require_once($CFG->libdir . '/questionlib.php');
     require_once("import_form.php");
 
     list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
@@ -28,6 +27,8 @@
         print_error('nocategory','quiz');
     }
 
+    $PAGE->set_pagelayout('standard');
+
     //this page can be called without courseid or cmid in which case
     //we get the context from the category object.
     if ($contexts === null) { // need to get the course from the chosen category
@@ -56,27 +57,10 @@
     //==========
     // PAGE HEADER
     //==========
-
-    if ($cm!==null) {
-        $PAGE->navbar->add($txt->importquestions);
         $PAGE->set_title($txt->importquestions);
+    $PAGE->set_heading($txt->importquestions);
         echo $OUTPUT->header();
 
-        $currenttab = 'edit';
-        $mode = 'import';
-        ${$cm->modname} = $module;
-        include($CFG->dirroot."/mod/$cm->modname/tabs.php");
-    } else {
-        // Print basic page layout.
-        $PAGE->navbar->add($txt->importquestions);
-        $PAGE->set_title($txt->importquestions);
-        echo $OUTPUT->header();
-        // print tabs
-        $currenttab = 'import';
-        include('tabs.php');
-    }
-
-
     // file upload form sumitted
     if ($form = $import_form->get_data()) {
 
Index: moodle/question/tabs.php
--- moodle/question/tabs.php Base (1.11)
+++ moodle/question/tabs.php Locally Deleted
@@ -1,27 +0,0 @@
-<?php
-/**
- * Sets up the tabs used by the question bank editing page
- *
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package questionbank
- */
-
-/// This file to be included so we can assume config.php has already been included.
-
-    if (!isset($currenttab)) {
-        $currenttab = '';
-    }
-    if (!isset($COURSE)) {
-        print_error('invalidcourse');
-    }
-
-    $tabs = array();
-    $inactive = array();
-    $row  = array();
-    questionbank_navigation_tabs($row, $contexts, $thispageurl->params());
-    $tabs[] = $row;
-
-    print_tabs($tabs, $currenttab, array());
-
-
-
