-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
show users that unenrolled prior to the allocation in a seperate row #199
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are no unallocated users, It looks like the problem has already existed before this PR, but it seems a good opportunity to fix it :) |
||
} | ||
// 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. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of
$this->ratingallocate->get_raters_in_course()
, you could use$users