Merge branch 'MDL-26633-master-workshopnumofreviews' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2021-10-14 22:40:43 +02:00
commit fc77e5e2ab
2 changed files with 29 additions and 7 deletions

View File

@ -263,13 +263,17 @@ class workshop_random_allocator implements workshop_allocator {
* @return array of integers
*/
public static function available_numofreviews_list() {
$options = array();
$options[30] = 30;
$options[20] = 20;
$options[15] = 15;
for ($i = 10; $i >= 0; $i--) {
$options = [];
for ($i = 100; $i > 20; $i = $i - 10) {
$options[$i] = $i;
}
for ($i = 20; $i >= 0; $i--) {
$options[$i] = $i;
}
return $options;
}

View File

@ -67,8 +67,8 @@ class workshop_random_allocator_form extends moodleform {
workshop_random_allocator_setting::NUMPER_REVIEWER => get_string('numperreviewer', 'workshopallocation_random')
);
$grpnumofreviews = array();
$grpnumofreviews[] = $mform->createElement('select', 'numofreviews', '',
workshop_random_allocator::available_numofreviews_list());
$grpnumofreviews[] = $mform->createElement('text', 'numofreviews', '', array('size' => 5, 'maxlength' => 20));
$mform->setType('numofreviews', PARAM_INT);
$mform->setDefault('numofreviews', $plugindefaults->numofreviews);
$grpnumofreviews[] = $mform->createElement('select', 'numper', '', $options_numper);
$mform->setDefault('numper', workshop_random_allocator_setting::NUMPER_SUBMISSION);
@ -98,4 +98,22 @@ class workshop_random_allocator_form extends moodleform {
$this->add_action_buttons();
}
/**
* Validate the allocation settings.
*
* @param array $data
* @param array $files
* @return array
*/
public function validation($data, $files): array {
$errors = parent::validation($data, $files);
if ($data['numofreviews'] < 0) {
$errors['grpnumofreviews'] = get_string('invalidnum', 'core_error');
}
return $errors;
}
}