MDL-49701 mod_lesson: open time should be before close time
authorJean-Michel Vedrine <vedrine@vedrine.org>
Mon, 30 Mar 2015 18:56:05 +0000 (20:56 +0200)
committerJean-Michel Vedrine <vedrine@vedrine.org>
Sun, 2 Aug 2015 08:33:04 +0000 (10:33 +0200)
mod/lesson/mod_form.php

index 7385e88..5d3eb3a 100644 (file)
@@ -336,6 +336,12 @@ class mod_lesson_mod_form extends moodleform_mod {
     function validation($data, $files) {
         $errors = parent::validation($data, $files);
 
+        // Check open and close times are consistent.
+        if ($data['available'] != 0 && $data['deadline'] != 0 &&
+                $data['deadline'] < $data['available']) {
+            $errors['deadline'] = get_string('closebeforeopen', 'lesson');
+        }
+
         if (!empty($data['usepassword']) && empty($data['password'])) {
             $errors['password'] = get_string('emptypassword', 'lesson');
         }