From: jamiesensei Date: Thu, 1 Mar 2007 07:45:22 +0000 (+0000) Subject: fiexs MDL-8659 : Impossible to create Cloze type question in Moodle 1.8 beta X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=120e5cbf4ca36ee2f30f37d0df6d409305064555;p=moodle.git fiexs MDL-8659 : Impossible to create Cloze type question in Moodle 1.8 beta --- diff --git a/question/type/multianswer/edit_multianswer_form.php b/question/type/multianswer/edit_multianswer_form.php index 79aa7d2c2a..26837a1bbf 100644 --- a/question/type/multianswer/edit_multianswer_form.php +++ b/question/type/multianswer/edit_multianswer_form.php @@ -14,9 +14,13 @@ class question_edit_multianswer_form extends question_edit_form { // No question-type specific form fields. - + function definition(){ + parent::definition(); + $mform =& $this->_form; + $mform->addRule('questiontext', null, 'required', null, 'client'); + } function set_data($question) { - if ($question->questiontext and $question->id and $question->qtype) { + if (isset($question->id) and $question->id and $question->qtype and $question->questiontext) { foreach ($question->options->questions as $key => $wrapped) { // The old way of restoring the definitions is kept to gradually @@ -62,6 +66,19 @@ class question_edit_multianswer_form extends question_edit_form { $question->questiontext = str_replace("{#$key}", $parsableanswerdef, $question->questiontext); } } + parent::set_data($question); + } + + function validation($data){ + //TODO would be nice to parse the question text here and output some error + //messages if there is a problem with the text. + $errors = array(); + //extra check to make sure there is something in the htmlarea besides a
+ $questiontext= trim(strip_tags($data['questiontext'])); + if ($questiontext==''){ + $errors['questiontext'] = get_string('err_required', 'form'); + } + return $errors; } function qtype() {