Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-25982 Workshop: users from the same group may be excluded from al…

…location 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.
  • Loading branch information...
commit 241e58e44b1e23bbf153c9cf4df5a082a888ea47 1 parent a1dc301
David Mudrák mudrd8mz authored
1  mod/workshop/allocation/random/lang/en/workshopallocation_random.php
View
@@ -32,6 +32,7 @@
$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['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['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>';
31 mod/workshop/allocation/random/lib.php
View
@@ -76,6 +76,7 @@ public function init() {
$o = array(); // list of output messages
$numofreviews = required_param('numofreviews', PARAM_INT);
$numper = required_param('numper', PARAM_INT);
+ $excludesamegroup = optional_param('excludesamegroup', false, PARAM_BOOL);
$removecurrent = optional_param('removecurrent', false, PARAM_BOOL);
$assesswosubmission = optional_param('assesswosubmission', false, PARAM_BOOL);
$addselfassessment = optional_param('addselfassessment', false, PARAM_BOOL);
@@ -96,7 +97,11 @@ public function init() {
} else {
$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);
$o[] = 'ok::' . get_string('numofrandomlyallocatedsubmissions', 'workshopallocation_random', count($randomallocations));
unset($randomallocations);
@@ -398,19 +403,27 @@ protected function get_unkept_assessments($assessments, $newallocations, $keepse
* is to connect each "circle" (circles are representing either authors or reviewers) with a required
* 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 resource $reviewers structure of grouped reviewers
* @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 $options allocation options
* @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)) {
// nothing to be done
return array();
}
+
+ $numofreviews = $options['numofreviews'];
+ $numper = $options['numper'];
+
if (self::USERTYPE_AUTHOR == $numper) {
// circles are authors, squares are reviewers
$o[] = 'info::Trying to allocate ' . $numofreviews . ' review(s) per author'; // todo translate
@@ -514,6 +527,16 @@ protected function random_allocation($authors, $reviewers, $assessments, $numofr
} elseif (VISIBLEGROUPS == $gmode) {
$trygroups = array_diff_key($squaregroupsworkload, array(0 => null)); // all but [0]
$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);
}
if ($targetgroup === false) {
8 mod/workshop/allocation/random/settings_form.php
View
@@ -74,6 +74,14 @@ public function definition() {
$mform->setDefault('numper', workshop_random_allocator::USERTYPE_AUTHOR);
$mform->addGroup($grpnumofreviews, 'grpnumofreviews', get_string('numofreviews', 'workshopallocation_random'),
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->setDefault('removecurrent', 0);
Please sign in to comment.
Something went wrong with that request. Please try again.