~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to question/type/randomsamatch/edit_randomsamatch_form.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * @copyright © 2007 Jamie Pratt
6
6
 * @author Jamie Pratt me@jamiep.org
7
7
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
8
 
 * @package questions
 
8
 * @package questionbank
 
9
 * @subpackage questiontypes
9
10
 */
10
11
 
11
12
/**
46
47
        return 'randomsamatch';
47
48
    }
48
49
 
49
 
    function validation($data){
 
50
    function validation($data, $files) {
50
51
        global $QTYPES;
51
 
        $errors = array();
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']);
 
55
        } else {
 
56
            list($category) = explode(',', $data['category']);
 
57
        }
 
58
        $saquestions = $QTYPES['randomsamatch']->get_sa_candidates($category);
53
59
        $numberavailable = count($saquestions);
54
60
        if ($saquestions === false){
55
61
            $a = new object();
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);
58
64
 
59
65
        } elseif ($numberavailable < $data['choose']){
60
66
            $a = new object();
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);
64
70
        }
65
71
        return $errors;
66
72
 
67
73
    }
68
 
 
69
74
}
70
75
?>
 
 
b'\\ No newline at end of file'