MDL-25523 Workshop: not-grouped users are excluded from allocation in visible group mode
There was a bug as these users were ignored only as squares but not as circles. This patch makes sure that no new allocation are added to not-grouped users in visible group mode. However, the options 'Remove current allocations' and 'Add self-assessments' apply to them intentionally. Also, the user is warned if there are some not-grouped users found in a workshop in visible groups mode or separate groups mode.
This commit is contained in:
@@ -33,6 +33,8 @@ $string['assessmentdeleteddetail'] = 'Assessment deallocated: <strong>{$a->revie
|
||||
$string['assesswosubmission'] = 'Participants can assess without having submitted anything';
|
||||
$string['confignumofreviews'] = 'Default number of submissions to be randomly allocated';
|
||||
$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>
|
||||
<p>These users are currently not in a group: {$a}</p>';
|
||||
$string['numofdeallocatedassessment'] = 'Deallocating {$a} assessment(s)';
|
||||
$string['numofrandomlyallocatedsubmissions'] = 'Randomly allocating {$a} submissions';
|
||||
$string['numofreviews'] = 'Number of reviews';
|
||||
|
||||
@@ -178,10 +178,37 @@ class workshop_random_allocator implements workshop_allocator {
|
||||
$this->mform->display();
|
||||
$out .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
$out .= $output->container_end();
|
||||
|
||||
// if there are some not-grouped participant in a group mode, warn the user
|
||||
$gmode = groups_get_activity_groupmode($this->workshop->cm, $this->workshop->course);
|
||||
if (VISIBLEGROUPS == $gmode or SEPARATEGROUPS == $gmode) {
|
||||
$users = $this->workshop->get_potential_authors() + $this->workshop->get_potential_reviewers();
|
||||
$users = $this->workshop->get_grouped($users);
|
||||
if (isset($users[0])) {
|
||||
$nogroupusers = $users[0];
|
||||
foreach ($users as $groupid => $groupusers) {
|
||||
if ($groupid == 0) {
|
||||
continue;
|
||||
}
|
||||
foreach ($groupusers as $groupuserid => $groupuser) {
|
||||
unset($nogroupusers[$groupuserid]);
|
||||
}
|
||||
}
|
||||
if (!empty($nogroupusers)) {
|
||||
$list = array();
|
||||
foreach ($nogroupusers as $nogroupuser) {
|
||||
$list[] = fullname($nogroupuser);
|
||||
}
|
||||
$a = implode(', ', $list);
|
||||
$out .= $output->box(get_string('nogroupusers', 'workshopallocation_random', $a), 'generalbox warning nogroupusers');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO $out .= $output->heading(get_string('stats', 'workshopallocation_random'));
|
||||
|
||||
$out .= $output->container_end();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
@@ -401,6 +428,22 @@ class workshop_random_allocator implements workshop_allocator {
|
||||
} else {
|
||||
throw new moodle_exception('unknownusertypepassed', 'workshop');
|
||||
}
|
||||
// get the users that are not in any group. in visible groups mode, these users are exluded
|
||||
// from allocation by this method
|
||||
// $nogroupcircles is array (int)$userid => undefined
|
||||
if (isset($allcircles[0])) {
|
||||
$nogroupcircles = array_flip(array_keys($allcircles[0]));
|
||||
} else {
|
||||
$nogroupcircles = array();
|
||||
}
|
||||
foreach ($allcircles as $circlegroupid => $circles) {
|
||||
if ($circlegroupid == 0) {
|
||||
continue;
|
||||
}
|
||||
foreach ($circles as $circleid => $circle) {
|
||||
unset($nogroupcircles[$circleid]);
|
||||
}
|
||||
}
|
||||
// $o[] = 'debug::circle links = ' . json_encode($circlelinks);
|
||||
// $o[] = 'debug::square links = ' . json_encode($squarelinks);
|
||||
$squareworkload = array(); // individual workload indexed by squareid
|
||||
@@ -440,6 +483,10 @@ class workshop_random_allocator implements workshop_allocator {
|
||||
$this->shuffle_assoc($circles);
|
||||
$o[] = 'debug::iteration ' . $requiredreviews;
|
||||
foreach ($circles as $circleid => $circle) {
|
||||
if (VISIBLEGROUPS == $gmode and isset($nogroupcircles[$circleid])) {
|
||||
$o[] = 'debug::skipping circle id ' . $circleid;
|
||||
continue;
|
||||
}
|
||||
$o[] = 'debug::processing circle id ' . $circleid;
|
||||
if (!isset($circlelinks[$circleid])) {
|
||||
$circlelinks[$circleid] = array();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
.path-mod-workshop .random-allocator .warning {
|
||||
width: 80%;
|
||||
margin: 0px auto 15px auto;
|
||||
}
|
||||
Reference in New Issue
Block a user