Skip to content

Commit

Permalink
MDL-32135 mod_choice: Open time should be before close time
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourget committed Jun 23, 2016
1 parent 39087f2 commit abef0f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions mod/choice/lang/en/choice.php
Expand Up @@ -28,6 +28,7 @@
$string['allowmultiple'] = 'Allow more than one choice to be selected';
$string['answered'] = 'Answered';
$string['cannotsubmit'] = 'Sorry, there was a problem submitting your choice. Please try again.';
$string['closebeforeopen'] = 'You have specified a close date before the open date.';
$string['completionsubmit'] = 'Show as complete when user makes a choice';
$string['displayhorizontal'] = 'Display horizontally';
$string['displaymode'] = 'Display mode for the options';
Expand Down
19 changes: 19 additions & 0 deletions mod/choice/mod_form.php
Expand Up @@ -139,6 +139,25 @@ function get_data() {
return $data;
}

/**
* Enforce validation rules here
*
* @param array $data array of ("fieldname"=>value) of submitted data
* @param array $files array of uploaded files "element_name"=>tmp_file_path
* @return array
**/
public function validation($data, $files) {
$errors = parent::validation($data, $files);

// Check open and close times are consistent.
if ($data['timeopen'] && $data['timeclose'] &&
$data['timeclose'] < $data['timeopen']) {
$errors['timeclose'] = get_string('closebeforeopen', 'choice');
}

return $errors;
}

function add_completion_rules() {
$mform =& $this->_form;

Expand Down

0 comments on commit abef0f8

Please sign in to comment.