Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-16300: small fix to handle case when no users with hotpot attempt…

…s are found
  • Loading branch information...
commit 062b672983ac2bbd0befa4f1d058505ea87d9c4a 1 parent 87ca858
gbateson authored
Showing with 25 additions and 23 deletions.
  1. +25 −23 mod/hotpot/report.php
View
48 mod/hotpot/report.php
@@ -497,34 +497,36 @@ function hotpot_print_report_selector(&$course, &$hotpot, &$formdata) {
u.lastname
");
- // get context
- $cm = get_coursemodule_from_instance('hotpot', $hotpot->id);
- $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ if (!empty($users)) {
- $teachers = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:viewreport');
- $students = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:attempt');
+ // get context
+ $cm = get_coursemodule_from_instance('hotpot', $hotpot->id);
+ $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
- // current students
- if ($students = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:attempt')) {
- $firsttime = true;
- foreach ($users as $user) {
- if (array_key_exists($user->id, $teachers)) {
- continue; // skip teachers
- }
- if (array_key_exists($user->id, $students)) {
- if ($firsttime) {
- $firsttime = false; // so we only do this once
- $menus['reportusers']['existingstudents'] = get_string('existingstudents');
- $menus['reportusers'][] = '------';
+ $teachers = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:viewreport');
+ $students = hotpot_get_users_by_capability($modulecontext, 'mod/hotpot:attempt');
+
+ // current students
+ if (!empty($students)) {
+ $firsttime = true;
+ foreach ($users as $user) {
+ if (array_key_exists($user->id, $teachers)) {
+ continue; // skip teachers
+ }
+ if (array_key_exists($user->id, $students)) {
+ if ($firsttime) {
+ $firsttime = false; // so we only do this once
+ $menus['reportusers']['existingstudents'] = get_string('existingstudents');
+ $menus['reportusers'][] = '------';
+ }
+ $menus['reportusers']["$user->id"] = fullname($user);
+ unset($users[$user->id]);
}
- $menus['reportusers']["$user->id"] = fullname($user);
- unset($users[$user->id]);
}
+ unset($students);
}
- unset($students);
- }
- // others (former students, teachers, admins, course creators)
- if (!empty($users)) {
+
+ // others (former students, teachers, admins, course creators)
$firsttime = true;
foreach ($users as $user) {
if ($firsttime) {
Please sign in to comment.
Something went wrong with that request. Please try again.