]> git.mjollnir.org Git - moodle.git/commitdiff
added check to see if at least two choices have been entered when setting up or updat...
authorjamiesensei <jamiesensei>
Mon, 27 Nov 2006 09:02:35 +0000 (09:02 +0000)
committerjamiesensei <jamiesensei>
Mon, 27 Nov 2006 09:02:35 +0000 (09:02 +0000)
lang/en_utf8/choice.php
mod/choice/mod_form.php

index 4451e9c043c3ba2621f1ad33aaf094c29de45054..ea8a47106bbc40283ce10d9445a572dff599bbd4 100644 (file)
@@ -1,4 +1,4 @@
-<?PHP // $Id$ 
+<?PHP // $Id$
       // choice.php - created with Moodle 1.7 beta + (2006101003)
 
 
@@ -17,6 +17,7 @@ $string['choicetext'] = 'Choice text';
 $string['displayhorizontal'] = 'Display horizontally';
 $string['displaymode'] = 'Display Mode';
 $string['displayvertical'] = 'Display vertically';
+$string['fillinatleastoneoption'] = 'You need to provide at least two possible answers.';
 $string['full'] = '(Full)';
 $string['havetologin'] = 'You have to log in before you can submit your choice';
 $string['limit'] = 'Limit';
index ea6260874e0feca91370f27fa0dc4f10e2d18422..f36af538e7abc3a44b3b888149e455ee33cabc2a 100644 (file)
@@ -112,5 +112,23 @@ class choice_mod_form extends moodleform_mod {
 
        }
 
+       function validation($data){
+           $choices=0;
+           foreach ($data['option'] as $option){
+               if (trim($option)!=''){
+                   $choices++;
+               }
+           }
+           if ($choices>1){
+              return true;
+           } elseif ($choices==0) {
+              return array('option[0]'=>get_string('fillinatleastoneoption', 'choice'));
+        } else  {
+              return array('option[1]'=>get_string('fillinatleastoneoption', 'choice'));
+        }
+
+
+       }
+
 }
 ?>
\ No newline at end of file