Merge branch 'MDL-32135_m32v2' of https://github.com/sbourget/moodle

This commit is contained in:
Dan Poltawski 2016-06-28 10:07:43 +01:00
commit bb2c042b96
2 changed files with 20 additions and 0 deletions

View File

@ -28,6 +28,7 @@ $string['allowupdate'] = 'Allow choice to be updated';
$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';

View File

@ -139,6 +139,25 @@ class mod_choice_mod_form extends moodleform_mod {
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;