hotpot_delete_selected_attempts($hotpot, $del);
}
+ // check for groups
+ if (preg_match('/^group(\d*)$/', $formdata['reportusers'], $matches)) {
+ // validate groupid
+ if (is_numeric($matches[1]) && get_field('groups', 'courseid', 'id', $matches[1])===$course->id) {
+ $formdata['reportusers'] = 'group';
+ $formdata['reportgroupid'] = $matches[1];
+ } else {
+ $formdata['reportgroupid'] = 0; // groupid is invalid
+ }
+ }
+
$user_ids = '';
$users = array();
+
switch ($formdata['reportusers']) {
+
case 'allusers':
// anyone who has ever attempted this hotpot
if ($records = get_records_select('hotpot_attempts', "hotpot=$hotpot->id", '', 'id,userid')) {
}
break;
+ case 'group':
+ // group members
+ if ($records = get_records_select('groups_members', "groupid=".$formdata['reportgroupid'], '', 'id,userid')) {
+ foreach ($records as $record) {
+ $users[$record->userid] = 1; // "1" signifies currently recognized participant
+ }
+ }
+ break;
+
case 'allparticipants':
// anyone currently allowed to attempt this HotPot
if ($records = get_users_by_capability($modulecontext, 'mod/hotpot:attempt', 'u.id,u.id', 'u.id')) {
}
}
- $menus['reportusers'] = array('allusers' => get_string('allusers', 'hotpot'));
+ $menus['reportusers'] = array(
+ 'allusers' => get_string('allusers', 'hotpot'),
+ 'allparticipants' => get_string('allparticipants')
+ );
+
+ // groups
+ if ($groups = get_records_select('groups', "courseid='$course->id'", '', 'id,name')) {
+ foreach ($groups as $group) {
+ $menus['reportusers']["group$group->id"] = get_string('group').': '.$group->name;
+ }
+ }
// get users who have ever atetmpted this HotPot
$users = get_records_sql("
$teachers = get_users_by_capability($modulecontext, 'mod/hotpot:viewreport', 'u.id,u.firstname,u.lastname', 'u.lastname');
$students = get_users_by_capability($modulecontext, 'mod/hotpot:attempt', 'u.id,u.firstname,u.lastname', 'u.lastname');
+ // current students
if (!empty($students)) {
$firsttime = true;
- foreach ($students as $id=>$user) {
- if (isset($users[$id]) && empty($teachers[$id])) {
+ foreach ($students as $user) {
+ if (isset($users[$user->id])) {
if ($firsttime) {
$firsttime = false; // so we only do this once
- $menus['reportusers']['allparticipants'] = get_string('allparticipants');
$menus['reportusers']['existingstudents'] = get_string('existingstudents');
$menus['reportusers'][] = '------';
}
- $menus['reportusers']["$id"] = fullname($user);
- unset($users[$id]);
+ $menus['reportusers']["$user->id"] = fullname($user);
+ unset($users[$user->id]);
}
}
}
+ // others (former students, teachers, admins, course creators)
if (!empty($users)) {
$firsttime = true;
- foreach ($users as $id=>$user) {
+ foreach ($users as $user) {
if ($firsttime) {
$firsttime = false; // so we only do this once
$menus['reportusers'][] = '======';
}
- $menus['reportusers']["$id"] = fullname($user);
+ $menus['reportusers']["$user->id"] = fullname($user);
}
}