MDL-38301 mod_assign: Fix date validation logic & message consistency

This commit is contained in:
Zig Tan 2018-06-18 16:41:53 +08:00 committed by Jun Pataleta
parent 8df868e9e0
commit 8f7d07fa7d
2 changed files with 9 additions and 9 deletions

View file

@ -223,18 +223,18 @@ class mod_assign_mod_form extends moodleform_mod {
public function validation($data, $files) {
$errors = parent::validation($data, $files);
if ($data['allowsubmissionsfromdate'] && $data['duedate']) {
if ($data['allowsubmissionsfromdate'] > $data['duedate']) {
if (!empty($data['allowsubmissionsfromdate']) && !empty($data['duedate'])) {
if ($data['duedate'] < $data['allowsubmissionsfromdate']) {
$errors['duedate'] = get_string('duedatevalidation', 'assign');
}
}
if ($data['duedate'] && $data['cutoffdate']) {
if ($data['duedate'] > $data['cutoffdate']) {
if (!empty($data['cutoffdate']) && !empty($data['duedate'])) {
if ($data['cutoffdate'] < $data['duedate'] ) {
$errors['cutoffdate'] = get_string('cutoffdatevalidation', 'assign');
}
}
if ($data['allowsubmissionsfromdate'] && $data['cutoffdate']) {
if ($data['allowsubmissionsfromdate'] > $data['cutoffdate']) {
if (!empty($data['allowsubmissionsfromdate']) && !empty($data['cutoffdate'])) {
if ($data['cutoffdate'] < $data['allowsubmissionsfromdate']) {
$errors['cutoffdate'] = get_string('cutoffdatefromdatevalidation', 'assign');
}
}