]> git.mjollnir.org Git - moodle.git/commitdiff
This new moodle_url thing (which is really confusing by the way)
authorthepurpleblob <thepurpleblob>
Thu, 26 Jul 2007 13:43:25 +0000 (13:43 +0000)
committerthepurpleblob <thepurpleblob>
Thu, 26 Jul 2007 13:43:25 +0000 (13:43 +0000)
had broken the page. The selected category was being ignored.
Fixed, but possibly not in the most elegant way!!

question/import.php

index 8afc11e9de8b9c6266bc0e3ab019917b19bdfaef..7946756fdb7029780c16fb1265dd6192b718025a 100644 (file)
     require_once($CFG->libdir . '/questionlib.php');
 
     list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup(false, false);
-    
+
     // get parameters
     $params = new stdClass;
     $params->choosefile = optional_param('choosefile','',PARAM_PATH);
     $catfromfile = optional_param('catfromfile', 0, PARAM_BOOL );
-    $courseid = optional_param('courseid', 0, PARAM_INT);
     $format = optional_param('format','',PARAM_FILE);
     $params->matchgrades = optional_param('matchgrades','',PARAM_ALPHA);
     $params->stoponerror = optional_param('stoponerror', 0, PARAM_BOOL);
+    $params->category = optional_param( 'category', 0, PARAM_INT );
 
     // get display strings
     $txt = new stdClass();
     $matchgrades['error'] = $txt->matchgradeserror;
     $matchgrades['nearest'] = $txt->matchgradesnearest;
 
+    // not sure where $pagevars['cat'] comes from, but it doesn't respect
+    // the user's choice on the form - so this bodge
+    if (empty($params->category)) {
+        $params->category = $pagevars['cat'];
+    }
 
-
-    if (!$category = get_record("question_categories", "id", $pagevars['cat'])) {
+    if (!$category = get_record("question_categories", "id", $params->category)) {
         // if no valid category was given, use the default category
         print_error('nocategory','quiz');
     }
 
     // check category is valid (against THIS courseid, before we change it)
-    $validcats = question_category_options( $courseid, false, true );
-    if (!array_key_exists( $categoryid, $validcats )) {
+    $validcats = question_category_options( $cmid, false, true );
+    if (!array_key_exists( $params->category, $validcats )) {
         print_error( 'invalidcategory', 'quiz' );
     }
 
-    $localcourseid = $courseid;
+    $localcourseid = $cmid;
     $courseid = $category->course;
 
     if (!$course = get_record("course", "id", $courseid)) {