]> git.mjollnir.org Git - moodle.git/commitdiff
changes to pass category id from page to page in question bank editing.
authorjamiesensei <jamiesensei>
Mon, 7 May 2007 04:55:55 +0000 (04:55 +0000)
committerjamiesensei <jamiesensei>
Mon, 7 May 2007 04:55:55 +0000 (04:55 +0000)
question/editlib.php
question/export.php
question/import.php

index 7a27faec9c60857434e368ba756c800e16f1559a..c45cd4f23abd70c5694a2e5244327da6227e8b3e 100644 (file)
@@ -124,7 +124,7 @@ function question_category_form($course, $pageurl, $current, $recurse=1, $showhi
     $strshow = get_string("show", "quiz");
     $streditcats = get_string("editcategories", "quiz");
 
-    popup_form ("edit.php?".$pageurl->get_query_string()."&amp;catchange=", $catmenu, "catmenu", $current, "", "", "", false, "self", "<strong>$strcategory</strong>");
+    popup_form ("edit.php?".$pageurl->get_query_string()."&amp;category=", $catmenu, "catmenu", $current, "", "", "", false, "self", "<strong>$strcategory</strong>");
 
     echo '<form method="post" action="edit.php" id="displayoptions">';
     echo "<fieldset class='invisiblefieldset'>";
@@ -413,7 +413,7 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
  * move           Moves a question to a different category
  * deleteselected Deletes the selected questions from the category
  * Other actions:
- * catchange      Chooses the category
+ * category      Chooses the category
  * displayoptions Sets display options
  *
  * @author Martin Dougiamas and many others. This has recently been extensively
@@ -567,6 +567,18 @@ function question_edit_setup($requirecmid = false, $requirecourseid = true){
     
     
     $pagevars['qpage'] = optional_param('qpage', -1, PARAM_INT);
+    
+    //pass 'cat' from page to page and when 'category' comes from a drop down menu
+    //then we also reset the qpage so we go to page 1 of 
+    //a new cat.
+    $pagevars['cat'] = optional_param('cat', 0, PARAM_INT);
+    if  ($category = optional_param('category', 0, PARAM_INT)){
+        $pagevars['cat'] = $category;
+        $pagevars['qpage'] = 0;
+    }
+    if ($pagevars['cat']){
+        $thispageurl->param('cat', $pagevars['cat']);
+    }
     if ($pagevars['qpage'] > -1) {
         $thispageurl->param('qpage', $pagevars['qpage']);
     } else {
@@ -589,20 +601,10 @@ function question_edit_setup($requirecmid = false, $requirecourseid = true){
         $pagevars['qsortorder'] = $sortorder;
         $thispageurl->param('qsortorder', $sortorder);
     } else {
-        $pagevars['qsortorder'] = 'qtype, name ASC';
+        $pagevars['qsortorderdecoded'] = $sortoptions['typealpha'];
+        $pagevars['qsortorder'] = 'typealpha';
     }    
     
-    //pass cat from page to page and catchange comes a drop down menu
-    //on catchange then we also reset the qpage so we go to page 1 of 
-    //a new cat.
-    $pagevars['cat'] = optional_param('cat', 0, PARAM_INT);
-    if  ($catchange = optional_param('catchange', 0, PARAM_INT)){
-        $pagevars['cat'] = $catchange;
-        $pagevars['qpage'] = 0;
-    }
-    if ($pagevars['cat']){
-        $thispageurl->param('cat', $pagevars['cat']);
-    }
 
     if (empty($pagevars['cat']) or !count_records_select("question_categories", "id = '".$pagevars['cat']."' AND (course = '{$COURSE->id}' OR publish = '1')")) {
         $category = get_default_question_category($COURSE->id);
@@ -632,6 +634,5 @@ function question_edit_setup($requirecmid = false, $requirecourseid = true){
     }
 
     return array($thispageurl, $courseid, $cmid, $cm, $module, $pagevars);
-    
 }
 ?>
index 32b1e22f2e0ed2a07a8d8db6b11eab2c229e025d..c792ddbf2eb05a4a730f688ac8bc58b22a88f709 100644 (file)
@@ -14,7 +14,6 @@
 
     list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup();
 
-    $categoryid = optional_param('category',0, PARAM_INT);
     $cattofile = optional_param('cattofile',0, PARAM_BOOL);
     
     $exportfilename = optional_param('exportfilename','',PARAM_FILE );
         error("Course does not exist!");
     }
 
-    if ($categoryid) { // update category in session variable
-        $SESSION->questioncat = $categoryid;
-    } else { // try to get category from session
-        if (isset($SESSION->questioncat)) {
-            $categoryid = $SESSION->questioncat;
-        }
-    }
 
-    if (!$category = get_record("question_categories", "id", $categoryid)) {   
+    if (!$category = get_record("question_categories", "id", $pagevars['cat'])) {   
         $category = get_default_question_category($courseid); 
     }
     
@@ -66,9 +58,9 @@
     make_upload_directory( "$course->id" );
 
     // check category is valid
-    if (!empty($categoryid)) {
+    if (!empty($pagevars['cat'])) {
         $validcats = question_category_options( $course->id, true, false );
-        if (!array_key_exists( $categoryid, $validcats)) {
+        if (!array_key_exists( $pagevars['cat'], $validcats)) {
             print_error( 'invalidcategory','quiz' );
         }
     }
         $qformat->setCattofile( $cattofile );
 
         if (! $qformat->exportpreprocess()) {   // Do anything before that we need to
-            error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id)));
+            error( $txt->exporterror, $thispageurl->out());
         }
 
         if (! $qformat->exportprocess()) {         // Process the export data
-            error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id)));
+            error( $txt->exporterror, $thispageurl->out());
         }
 
         if (! $qformat->exportpostprocess()) {                    // In case anything needs to be done after
-            error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id)));
+            error( $txt->exporterror, $thispageurl->out());
         }
         echo "<hr />";
 
index 1d2115d54b718c2110c40427457f28b97a98d656..7e0b794e7502d50c0c2364f5d6f364efe96c732e 100644 (file)
@@ -19,7 +19,6 @@
     // get parameters
     $params = new stdClass;
     $params->choosefile = optional_param('choosefile','',PARAM_PATH);
-    $categoryid = optional_param('category', 0, PARAM_INT);
     $catfromfile = optional_param('catfromfile', 0, PARAM_BOOL );
     $format = optional_param('format','',PARAM_FILE);
     $params->matchgrades = optional_param('matchgrades','',PARAM_ALPHA);
     $matchgrades['error'] = $txt->matchgradeserror;
     $matchgrades['nearest'] = $txt->matchgradesnearest;
 
-    if ($categoryid) { // update category in session variable
-        $SESSION->questioncat = $categoryid;
-    } else { // try to get category from session
-        if (isset($SESSION->questioncat)) {
-            $categoryid = $SESSION->questioncat;
-        }
-    }
 
-    if (!$category = get_record("question_categories", "id", $categoryid)) {
+
+    if ($category = get_record("question_categories", "id", $pagevars['cat'])) {
         // if no valid category was given, use the default category
-        if ($courseid) {
-            $category = get_default_question_category($courseid);
-        } else {
-            print_error('nocategory','quiz');
-        }
+        print_error('nocategory','quiz');
     }
 
     if (!$courseid) { // need to get the course from the chosen category