MDL-26633 workshop: Allow to randomly allocate more than 30 reviews

For classes with many students, there may be valid cases for having more
than 30 reviews per submission / reviewer.

The patch changes the type of the input field so that it can freely
editable to any integer value.
This commit is contained in:
David Mudrák 2021-09-06 19:25:25 +02:00
parent e746dc75af
commit 78f9ea3b1c
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;
}
}