46
47
return 'randomsamatch';
49
function validation($data){
50
function validation($data, $files) {
52
$saquestions = $QTYPES['randomsamatch']->get_sa_candidates($data['category']);
52
$errors = parent::validation($data, $files);
53
if (isset($data->categorymoveto)) {
54
list($category) = explode(',', $data['categorymoveto']);
56
list($category) = explode(',', $data['category']);
58
$saquestions = $QTYPES['randomsamatch']->get_sa_candidates($category);
53
59
$numberavailable = count($saquestions);
54
60
if ($saquestions === false){
56
$a->catname = get_field('question_categories', 'name', 'id', $data['category']);
62
$a->catname = get_field('question_categories', 'name', 'id', $category);
57
63
$errors['choose'] = get_string('nosaincategory', 'qtype_randomsamatch', $a);
59
65
} elseif ($numberavailable < $data['choose']){
61
$a->catname = get_field('question_categories', 'name', 'id', $data['category']);
67
$a->catname = get_field('question_categories', 'name', 'id', $category);
62
68
$a->nosaquestions = $numberavailable;
63
69
$errors['choose'] = get_string('notenoughsaincategory', 'qtype_randomsamatch', $a);
b'\\ No newline at end of file'