]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13457 Validation when moving to another category
authorpichetp <pichetp>
Wed, 20 Feb 2008 09:19:03 +0000 (09:19 +0000)
committerpichetp <pichetp>
Wed, 20 Feb 2008 09:19:03 +0000 (09:19 +0000)
question/type/randomsamatch/edit_randomsamatch_form.php

index 30671507f18b6dd44d964a3c5df8ffff452ea23e..d03fcc4ecceca79e322a4177f74dd7ac5f06bef5 100644 (file)
@@ -50,16 +50,22 @@ class question_edit_randomsamatch_form extends question_edit_form {
     function validation($data, $files) {
         global $QTYPES;
         $errors = parent::validation($data, $files);
-        $saquestions = $QTYPES['randomsamatch']->get_sa_candidates($data['category']);
+        if (isset($data['usecurrentcat'])){
+            $category = $data['category'];
+        }else{
+            $category = $data['categorymoveto'];
+        }
+            
+        $saquestions = $QTYPES['randomsamatch']->get_sa_candidates($category);
         $numberavailable = count($saquestions);
         if ($saquestions === false){
             $a = new object();
-            $a->catname = get_field('question_categories', 'name', 'id', $data['category']);
+            $a->catname = get_field('question_categories', 'name', 'id', $category);
             $errors['choose'] = get_string('nosaincategory', 'qtype_randomsamatch', $a);
 
         } elseif ($numberavailable < $data['choose']){
             $a = new object();
-            $a->catname = get_field('question_categories', 'name', 'id', $data['category']);
+            $a->catname = get_field('question_categories', 'name', 'id', $category);
             $a->nosaquestions = $numberavailable;
             $errors['choose'] = get_string('notenoughsaincategory', 'qtype_randomsamatch', $a);
         }