]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17914: Conditional activities should check that available dates in module form...
authorsam_marshall <sam_marshall>
Thu, 15 Jan 2009 14:30:19 +0000 (14:30 +0000)
committersam_marshall <sam_marshall>
Thu, 15 Jan 2009 14:30:19 +0000 (14:30 +0000)
course/moodleform_mod.php
lang/en_utf8/condition.php

index 3507f28c9727062d16069c1819f8416f0efd340b..2a0283e057e15cc934a3e764cf8d71f62e2c7433 100644 (file)
@@ -248,6 +248,13 @@ class moodleform_mod extends moodleform {
             }
         }
 
+        // Conditions: Don't let them set dates which make no sense
+        if (array_key_exists('availablefrom', $data) && 
+            $data['availablefrom'] && $data['availableuntil'] && 
+            $data['availablefrom']>=$data['availableuntil']) {
+            $errors['availablefrom'] = get_string('badavailabledates', 'condition');
+        }
+        
         return $errors;
     }
 
index b2d1e2d95e3e8c586ea2f7cafe35baa9e843c0fe..eb5ebb9a92ea07aa162d2f7867ada5534d49f0cb 100644 (file)
@@ -4,6 +4,7 @@ $string['addcompletions']='Add {no} activity conditions to form';
 $string['availabilityconditions']='Restrict availability';
 $string['availablefrom']='Only available from';
 $string['availableuntil']='Only available until';
+$string['badavailabledates']='Invalid dates. If you set both dates, the \'available from\' date should be before the \'until\' date.';
 $string['completion_complete']=' must be marked complete';
 $string['completion_incomplete']=' must not be marked complete';
 $string['completion_pass']=' must be complete with pass grade';