Skip to content

Commit ebe33c4

Browse files
committed
MDL-54911 mod_feedback: start date should be before the end date
1 parent 39087f2 commit ebe33c4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mod/feedback/lang/en/feedback.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
$string['cannotunmap'] = 'Database problem, unable to unmap';
4545
$string['captcha'] = 'Captcha';
4646
$string['captchanotset'] = 'Captcha hasn\'t been set.';
47+
$string['closebeforeopen'] = 'You have specified an end date before the start date.';
4748
$string['completed_feedbacks'] = 'Submitted answers';
4849
$string['complete_the_form'] = 'Answer the questions...';
4950
$string['completionsubmit'] = 'View as completed if the feedback is submitted';

mod/feedback/mod_form.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,21 @@ public function get_data() {
179179
return $data;
180180
}
181181

182+
/**
183+
* Enforce validation rules here
184+
*
185+
* @param array $data array of ("fieldname"=>value) of submitted data
186+
* @param array $files array of uploaded files "element_name"=>tmp_file_path
187+
* @return array
188+
**/
182189
public function validation($data, $files) {
183190
$errors = parent::validation($data, $files);
191+
192+
// Check open and close times are consistent.
193+
if ($data['timeopen'] && $data['timeclose'] &&
194+
$data['timeclose'] < $data['timeopen']) {
195+
$errors['timeclose'] = get_string('closebeforeopen', 'feedback');
196+
}
184197
return $errors;
185198
}
186199

0 commit comments

Comments
 (0)