Fixes #190 Show warning message when no users in course
authorDan Marsden <dan@danmarsden.com>
Mon, 14 Mar 2016 20:02:06 +0000 (09:02 +1300)
committerDan Marsden <dan@danmarsden.com>
Mon, 14 Mar 2016 20:04:21 +0000 (09:04 +1300)
export_form.php
lang/en/attendance.php

index ba048e5..c53ff71 100644 (file)
@@ -58,7 +58,6 @@ class mod_attendance_export_form extends moodleform {
                 $grouplist[$group->id] = $group->name;
             }
         }
-        $mform->addElement('select', 'group', get_string('group'), $grouplist);
 
         // Restrict the export to the selected users.
         $namefields = get_all_user_name_fields(true, 'u');
@@ -72,6 +71,11 @@ class mod_attendance_export_form extends moodleform {
         foreach ($tempusers as $user) {
             $userlist[$user->studentid] = $user->fullname;
         }
+        if (empty($userlist)) {
+            $mform->addElement('static', 'nousers', '', get_string('noattendanceusers', 'attendance'));
+            return;
+        }
+
         list($gsql, $gparams) = $DB->get_in_or_equal(array_keys($grouplist), SQL_PARAMS_NAMED);
         list($usql, $uparams) = $DB->get_in_or_equal(array_keys($userlist), SQL_PARAMS_NAMED);
         $params = array_merge($gparams, $uparams);
@@ -88,6 +92,8 @@ class mod_attendance_export_form extends moodleform {
             $groupmappings[0] = $userlist;
         }
 
+        $mform->addElement('select', 'group', get_string('group'), $grouplist);
+
         $mform->addElement('selectyesno', 'selectedusers', get_string('onlyselectedusers', 'mod_attendance'));
         $sel = $mform->addElement('select', 'users', get_string('users', 'mod_attendance'), $userlist, array('size' => 12));
         $sel->setMultiple(true);
index 2ec8406..7871676 100644 (file)
@@ -312,3 +312,4 @@ $string['hiddensessionsdeleted'] = 'All hidden sessions were delete';
 
 $string['timeahead'] = 'Multiple sessions that exceed one year cannot be created, please adjust the start and end dates.';
 $string['priorto'] = 'The session date is prior to the course start date ({$a}) so that the new sessions scheduled before this date will be hidden (not accessible). You can change the course start date at any time (see course settings) in order to have access to earlier sessions.<br><br>Please change the session date or just click the "Add session" button again to confirm?';
+$string['noattendanceusers'] = 'It is not possible to export any data as there are no students enrolled in the course.';