MDL-28604 Question bank display forgets sort order
authorTim Hunt <T.J.Hunt@open.ac.uk>
Thu, 4 Aug 2011 12:53:02 +0000 (13:53 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Thu, 4 Aug 2011 12:53:02 +0000 (13:53 +0100)
mod/quiz/edit.php
mod/quiz/editlib.php
question/edit.php
question/editlib.php

index df4668a..15a9d8f 100644 (file)
@@ -453,8 +453,7 @@ echo '<div id="module" class="module">';
 echo '<div class="bd">';
 $questionbank->display('editq',
         $pagevars['qpage'],
-        $pagevars['qperpage'], $pagevars['qsortorder'],
-        $pagevars['qsortorderdecoded'],
+        $pagevars['qperpage'],
         $pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'],
         $pagevars['showquestiontext']);
 echo '</div>';
index 43dffcc..3914e84 100644 (file)
@@ -1129,8 +1129,8 @@ class quiz_question_bank_view extends question_bank_view {
         return new moodle_url('/mod/quiz/edit.php', $params);
     }
 
-    public function display($tabname, $page, $perpage, $sortorder,
-            $sortorderdecoded, $cat, $recurse, $showhidden, $showquestiontext) {
+    public function display($tabname, $page, $perpage, $cat,
+            $recurse, $showhidden, $showquestiontext) {
         global $OUTPUT;
         if ($this->process_actions_needing_ui()) {
             return;
@@ -1150,7 +1150,7 @@ class quiz_question_bank_view extends question_bank_view {
         // continues with list of questions
         $this->display_question_list($this->contexts->having_one_edit_tab_cap($tabname),
                 $this->baseurl, $cat, $this->cm, $recurse, $page,
-                $perpage, $showhidden, $sortorder, $sortorderdecoded, $showquestiontext,
+                $perpage, $showhidden, $showquestiontext,
                 $this->contexts->having_cap('moodle/question:add'));
 
         $this->display_options($recurse, $showhidden, $showquestiontext);
index c52b4a4..5359fe7 100644 (file)
@@ -65,9 +65,9 @@ $PAGE->set_heading($COURSE->fullname);
 echo $OUTPUT->header();
 
 echo '<div class="questionbankwindow boxwidthwide boxaligncenter">';
-$questionbank->display('questions', $pagevars['qpage'],
-        $pagevars['qperpage'], $pagevars['qsortorder'], $pagevars['qsortorderdecoded'],
-        $pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'], $pagevars['showquestiontext']);
+$questionbank->display('questions', $pagevars['qpage'], $pagevars['qperpage'],
+        $pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'],
+        $pagevars['showquestiontext']);
 echo "</div>\n";
 
 echo $OUTPUT->footer();
index 27f74a6..59811a8 100644 (file)
@@ -155,7 +155,6 @@ abstract class question_bank_column_base {
 
     /**
      * Output the column header cell.
-     * @param int $currentsort 0 for none. 1 for normal sort, -1 for reverse sort.
      */
     public function display_header() {
         echo '<th class="header ' . $this->get_classes() . '" scope="col">';
@@ -1168,8 +1167,8 @@ class question_bank_view {
      * category      Chooses the category
      * displayoptions Sets display options
      */
-    public function display($tabname, $page, $perpage, $sortorder,
-            $sortorderdecoded, $cat, $recurse, $showhidden, $showquestiontext){
+    public function display($tabname, $page, $perpage, $cat,
+            $recurse, $showhidden, $showquestiontext) {
         global $PAGE, $OUTPUT;
 
         if ($this->process_actions_needing_ui()) {
@@ -1191,8 +1190,9 @@ class question_bank_view {
         $this->print_category_info($category);
 
         // continues with list of questions
-        $this->display_question_list($this->contexts->having_one_edit_tab_cap($tabname), $this->baseurl, $cat, $this->cm,
-                $recurse, $page, $perpage, $showhidden, $sortorder, $sortorderdecoded, $showquestiontext,
+        $this->display_question_list($this->contexts->having_one_edit_tab_cap($tabname),
+                $this->baseurl, $cat, $this->cm,
+                $recurse, $page, $perpage, $showhidden, $showquestiontext,
                 $this->contexts->having_cap('moodle/question:add'));
     }
 
@@ -1297,7 +1297,6 @@ class question_bank_view {
     */
     protected function display_question_list($contexts, $pageurl, $categoryandcontext,
             $cm = null, $recurse=1, $page=0, $perpage=100, $showhidden=false,
-            $sortorder='typename', $sortorderdecoded='qtype, name ASC',
             $showquestiontext = false, $addcontexts = array()) {
         global $CFG, $DB, $OUTPUT;
 
@@ -1639,17 +1638,12 @@ function question_edit_setup($edittab, $baseurl, $requirecmid = false, $requirec
         $pagevars['qperpage'] = DEFAULT_QUESTIONS_PER_PAGE;
     }
 
-    $sortoptions = array('alpha' => 'name, qtype ASC',
-                          'typealpha' => 'qtype, name ASC',
-                          'age' => 'id ASC');
-
-    if ($sortorder = optional_param('qsortorder', '', PARAM_ALPHA)) {
-        $pagevars['qsortorderdecoded'] = $sortoptions[$sortorder];
-        $pagevars['qsortorder'] = $sortorder;
-        $thispageurl->param('qsortorder', $sortorder);
-    } else {
-        $pagevars['qsortorderdecoded'] = $sortoptions['typealpha'];
-        $pagevars['qsortorder'] = 'typealpha';
+    for ($i = 1; $i <= question_bank_view::MAX_SORTS; $i++) {
+        $param = 'qbs' . $i;
+        if (!$sort = optional_param($param, '', PARAM_ALPHAEXT)) {
+            break;
+        }
+        $thispageurl->param($param, $sort);
     }
 
     $defaultcategory = question_make_default_categories($contexts->all());