diff --git a/classes/allocations_table.php b/classes/allocations_table.php index 5e523e40..87fd93f3 100644 --- a/classes/allocations_table.php +++ b/classes/allocations_table.php @@ -160,17 +160,42 @@ public function build_table_by_sql() { $noallocation->choicetitle = get_string( 'allocations_table_noallocation', ratingallocate_MOD_NAME); + $enrolled_user_ids = array_map(function($x) {return $x->id;}, + $this->ratingallocate->get_raters_in_course()); foreach ($userwithrating as $userid => $user) { + // Ignore users that were not allocated due to them unenrolling from the course. + if (!in_array($userid, $enrolled_user_ids)) { + continue; + } if (object_property_exists($noallocation, 'users')) { $noallocation->users .= ', '; } else { $noallocation->users = ''; } $noallocation->users .= $this->get_user_link($user); + unset($userwithrating[$userid]); } $data []= $noallocation; } + // If there are useres, which rated but unenrolled prior to the allocation, add them to a special row. + if (count($userwithrating) > 0 AND ($this->currpage + 1) * $this->pagesize >= $this->totalrows) { + $unenrolled = new \stdClass(); + $unenrolled->choicetitle = get_string( + 'allocations_table_unenrolled', + ratingallocate_MOD_NAME); + + foreach ($userwithrating as $userid => $user) { + if (object_property_exists($unenrolled, 'users')) { + $unenrolled->users .= ', '; + } else { + $unenrolled->users = ''; + } + $unenrolled->users .= $this->get_user_link($user); + unset($userwithrating[$userid]); + } + $data []= $unenrolled; + } } // Finally, add all data to the table. diff --git a/lang/en/ratingallocate.php b/lang/en/ratingallocate.php index 576acd88..a89ad75a 100644 --- a/lang/en/ratingallocate.php +++ b/lang/en/ratingallocate.php @@ -88,6 +88,7 @@ $string['allocations_table_choice'] = 'Choice'; $string['allocations_table_users'] = 'Users'; $string['allocations_table_noallocation'] = 'No Allocation'; +$string['allocations_table_unenrolled'] = 'Users that unenrolled prior to the allocation'; $string['start_distribution_explanation'] = ' An algorithm will automatically try to fairly allocate the users according to their given ratings.'; $string['distribution_table'] = 'Distribution Table'; $string['download_problem_mps_format'] = 'Download Equation (mps/txt)';