From: pichetp Date: Wed, 20 Feb 2008 09:19:03 +0000 (+0000) Subject: MDL-13457 Validation when moving to another category X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c958ac93012872c6ba6a2751b883abb063f649f0;p=moodle.git MDL-13457 Validation when moving to another category --- diff --git a/question/type/randomsamatch/edit_randomsamatch_form.php b/question/type/randomsamatch/edit_randomsamatch_form.php index 30671507f1..d03fcc4ecc 100644 --- a/question/type/randomsamatch/edit_randomsamatch_form.php +++ b/question/type/randomsamatch/edit_randomsamatch_form.php @@ -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); }