mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-25982 Workshop: users from the same group may be excluded from allocation in visible group mode
If the Workshop is in the visible group mode, members of the same group can be now optionally excluded from random allocation for a given user.
This commit is contained in:
parent
a1dc301ed5
commit
241e58e44b
3 changed files with 36 additions and 4 deletions
|
@ -32,6 +32,7 @@ $string['allocationsettings'] = 'Allocation settings';
|
||||||
$string['assessmentdeleteddetail'] = 'Assessment deallocated: <strong>{$a->reviewername}</strong> is no longer reviewer of <strong>{$a->authorname}</strong>';
|
$string['assessmentdeleteddetail'] = 'Assessment deallocated: <strong>{$a->reviewername}</strong> is no longer reviewer of <strong>{$a->authorname}</strong>';
|
||||||
$string['assesswosubmission'] = 'Participants can assess without having submitted anything';
|
$string['assesswosubmission'] = 'Participants can assess without having submitted anything';
|
||||||
$string['confignumofreviews'] = 'Default number of submissions to be randomly allocated';
|
$string['confignumofreviews'] = 'Default number of submissions to be randomly allocated';
|
||||||
|
$string['excludesamegroup'] = 'Prevent reviews by peers from the same group';
|
||||||
$string['noallocationtoadd'] = 'No allocations to add';
|
$string['noallocationtoadd'] = 'No allocations to add';
|
||||||
$string['nogroupusers'] = '<p>Warning: If the workshop is in \'visible groups\' mode or \'separate groups\' mode, then users MUST be part of at least one group to have peer-assessments allocated to them by this tool. Non-grouped users can still be given new self-assessments or have existing assessments removed.</p>
|
$string['nogroupusers'] = '<p>Warning: If the workshop is in \'visible groups\' mode or \'separate groups\' mode, then users MUST be part of at least one group to have peer-assessments allocated to them by this tool. Non-grouped users can still be given new self-assessments or have existing assessments removed.</p>
|
||||||
<p>These users are currently not in a group: {$a}</p>';
|
<p>These users are currently not in a group: {$a}</p>';
|
||||||
|
|
|
@ -76,6 +76,7 @@ class workshop_random_allocator implements workshop_allocator {
|
||||||
$o = array(); // list of output messages
|
$o = array(); // list of output messages
|
||||||
$numofreviews = required_param('numofreviews', PARAM_INT);
|
$numofreviews = required_param('numofreviews', PARAM_INT);
|
||||||
$numper = required_param('numper', PARAM_INT);
|
$numper = required_param('numper', PARAM_INT);
|
||||||
|
$excludesamegroup = optional_param('excludesamegroup', false, PARAM_BOOL);
|
||||||
$removecurrent = optional_param('removecurrent', false, PARAM_BOOL);
|
$removecurrent = optional_param('removecurrent', false, PARAM_BOOL);
|
||||||
$assesswosubmission = optional_param('assesswosubmission', false, PARAM_BOOL);
|
$assesswosubmission = optional_param('assesswosubmission', false, PARAM_BOOL);
|
||||||
$addselfassessment = optional_param('addselfassessment', false, PARAM_BOOL);
|
$addselfassessment = optional_param('addselfassessment', false, PARAM_BOOL);
|
||||||
|
@ -96,7 +97,11 @@ class workshop_random_allocator implements workshop_allocator {
|
||||||
} else {
|
} else {
|
||||||
$curassessments = $assessments;
|
$curassessments = $assessments;
|
||||||
}
|
}
|
||||||
$randomallocations = $this->random_allocation($authors, $reviewers, $curassessments, $numofreviews, $numper, $o);
|
$options = array();
|
||||||
|
$options['numofreviews'] = $numofreviews;
|
||||||
|
$options['numper'] = $numper;
|
||||||
|
$options['excludesamegroup'] = $excludesamegroup;
|
||||||
|
$randomallocations = $this->random_allocation($authors, $reviewers, $curassessments, $o, $options);
|
||||||
$newallocations = array_merge($newallocations, $randomallocations);
|
$newallocations = array_merge($newallocations, $randomallocations);
|
||||||
$o[] = 'ok::' . get_string('numofrandomlyallocatedsubmissions', 'workshopallocation_random', count($randomallocations));
|
$o[] = 'ok::' . get_string('numofrandomlyallocatedsubmissions', 'workshopallocation_random', count($randomallocations));
|
||||||
unset($randomallocations);
|
unset($randomallocations);
|
||||||
|
@ -398,19 +403,27 @@ class workshop_random_allocator implements workshop_allocator {
|
||||||
* is to connect each "circle" (circles are representing either authors or reviewers) with a required
|
* is to connect each "circle" (circles are representing either authors or reviewers) with a required
|
||||||
* number of "squares" (the other type than circles are).
|
* number of "squares" (the other type than circles are).
|
||||||
*
|
*
|
||||||
|
* The passed $options array must provide keys:
|
||||||
|
* (int)numofreviews - number of reviews to be allocated to each circle
|
||||||
|
* (int)numper - what user type the circles represent.
|
||||||
|
* (bool)excludesamegroup - whether to prevent peer submissions from the same group in visible group mode
|
||||||
|
*
|
||||||
* @param array $authors structure of grouped authors
|
* @param array $authors structure of grouped authors
|
||||||
* @param resource $reviewers structure of grouped reviewers
|
* @param resource $reviewers structure of grouped reviewers
|
||||||
* @param array $assessments currently assigned assessments to be kept
|
* @param array $assessments currently assigned assessments to be kept
|
||||||
* @param mixed $numofreviews number of reviews to be allocated to each circle
|
|
||||||
* @param mixed $numper what user type the circles represent
|
|
||||||
* @param array $o reference to an array of log messages
|
* @param array $o reference to an array of log messages
|
||||||
|
* @param array $options allocation options
|
||||||
* @return array array of (reviewerid => authorid) pairs
|
* @return array array of (reviewerid => authorid) pairs
|
||||||
*/
|
*/
|
||||||
protected function random_allocation($authors, $reviewers, $assessments, $numofreviews, $numper, &$o) {
|
protected function random_allocation($authors, $reviewers, $assessments, &$o, array $options) {
|
||||||
if (empty($authors) || empty($reviewers)) {
|
if (empty($authors) || empty($reviewers)) {
|
||||||
// nothing to be done
|
// nothing to be done
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$numofreviews = $options['numofreviews'];
|
||||||
|
$numper = $options['numper'];
|
||||||
|
|
||||||
if (self::USERTYPE_AUTHOR == $numper) {
|
if (self::USERTYPE_AUTHOR == $numper) {
|
||||||
// circles are authors, squares are reviewers
|
// circles are authors, squares are reviewers
|
||||||
$o[] = 'info::Trying to allocate ' . $numofreviews . ' review(s) per author'; // todo translate
|
$o[] = 'info::Trying to allocate ' . $numofreviews . ' review(s) per author'; // todo translate
|
||||||
|
@ -514,6 +527,16 @@ class workshop_random_allocator implements workshop_allocator {
|
||||||
} elseif (VISIBLEGROUPS == $gmode) {
|
} elseif (VISIBLEGROUPS == $gmode) {
|
||||||
$trygroups = array_diff_key($squaregroupsworkload, array(0 => null)); // all but [0]
|
$trygroups = array_diff_key($squaregroupsworkload, array(0 => null)); // all but [0]
|
||||||
$trygroups = array_diff_key($trygroups, array_flip($failedgroups)); // without previous failures
|
$trygroups = array_diff_key($trygroups, array_flip($failedgroups)); // without previous failures
|
||||||
|
if ($options['excludesamegroup']) {
|
||||||
|
// exclude groups the circle is member of
|
||||||
|
$excludegroups = array();
|
||||||
|
foreach (array_diff_key($allcircles, array(0 => null)) as $exgroupid => $exgroupmembers) {
|
||||||
|
if (array_key_exists($circleid, $exgroupmembers)) {
|
||||||
|
$excludegroups[$exgroupid] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$trygroups = array_diff_key($trygroups, $excludegroups);
|
||||||
|
}
|
||||||
$targetgroup = $this->get_element_with_lowest_workload($trygroups);
|
$targetgroup = $this->get_element_with_lowest_workload($trygroups);
|
||||||
}
|
}
|
||||||
if ($targetgroup === false) {
|
if ($targetgroup === false) {
|
||||||
|
|
|
@ -74,6 +74,14 @@ class workshop_random_allocator_form extends moodleform {
|
||||||
$mform->setDefault('numper', workshop_random_allocator::USERTYPE_AUTHOR);
|
$mform->setDefault('numper', workshop_random_allocator::USERTYPE_AUTHOR);
|
||||||
$mform->addGroup($grpnumofreviews, 'grpnumofreviews', get_string('numofreviews', 'workshopallocation_random'),
|
$mform->addGroup($grpnumofreviews, 'grpnumofreviews', get_string('numofreviews', 'workshopallocation_random'),
|
||||||
array(' '), false);
|
array(' '), false);
|
||||||
|
|
||||||
|
if (VISIBLEGROUPS == $gmode) {
|
||||||
|
$mform->addElement('checkbox', 'excludesamegroup', get_string('excludesamegroup', 'workshopallocation_random'));
|
||||||
|
$mform->setDefault('excludesamegroup', 0);
|
||||||
|
} else {
|
||||||
|
$mform->addElement('hidden', 'excludesamegroup', 0);
|
||||||
|
}
|
||||||
|
|
||||||
$mform->addElement('checkbox', 'removecurrent', get_string('removecurrentallocations', 'workshopallocation_random'));
|
$mform->addElement('checkbox', 'removecurrent', get_string('removecurrentallocations', 'workshopallocation_random'));
|
||||||
$mform->setDefault('removecurrent', 0);
|
$mform->setDefault('removecurrent', 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue