]> git.mjollnir.org Git - moodle.git/commitdiff
You can now unenrol all students quickly with one button
authormoodler <moodler>
Mon, 26 Apr 2004 14:16:05 +0000 (14:16 +0000)
committermoodler <moodler>
Mon, 26 Apr 2004 14:16:05 +0000 (14:16 +0000)
bug 1238

course/student.php
lang/en/moodle.php

index 416f1bb61eabc8d3d81ce0f422dba76ca893d55f..db40e9abba561bb2c0dd693906f31abac4be9d92 100644 (file)
@@ -36,6 +36,9 @@
     $strsearchagain   = get_string("searchagain");
     $strtoomanytoshow   = get_string("toomanytoshow");
     $strstudents   = get_string("students");
+    $strunenrolallstudents  = get_string("unenrolallstudents");
+    $strunenrolallstudentssure  = get_string("unenrolallstudentssure");
+
 
     if ($search) {
         $searchstring = $strsearchagain;
         }
     }
 
+/// Remove all students from specified course
+
+    if (!empty($removeall)) {
+        $students = get_course_students($course->id, "u.lastname ASC, u.firstname ASC");
+        foreach ($students as $student) {
+            if (! unenrol_student($student->id, $course->id)) {
+                $fullname = fullname($student, true);
+                notify("Could not remove $fullname from this course!");
+            }
+        }
+    }
+
 /// Print a help notice about the need to use this page
 
     if (empty($add) and empty($remove) and empty($search)) {
         }
         $studentlist = implode(",",$studentarray);
         unset($studentarray);
+
+        // button to unenrol all students from course
+
+        echo "<p>&nbsp;</p>\n";
+        echo "<p align=\"center\">\n";
+        echo "<input type=\"button\" value=\"$strunenrolallstudents\" ".
+             " OnClick=\"ctemp = window.confirm('".addslashes($strunenrolallstudentssure)."'); ".
+             " if(ctemp) window.location.href='student.php?id=$course->id&removeall=1';\"/>\n";
+        echo "</p>\n";
     }
 
     echo "<td>&nbsp;</td>";
index 9dea4c7a1c89d2384bc1c3929fcea8d49b5c0b69..63c9f24641b475b48e1ddbb6eea9c1de61fe3426 100644 (file)
@@ -852,6 +852,8 @@ $string['turneditingoff'] = 'Turn editing off';
 $string['turneditingon'] = 'Turn editing on';
 $string['undecided'] = 'Undecided';
 $string['unenrol'] = 'Unenrol';
+$string['unenrolallstudents'] = 'Unenrol all students';
+$string['unenrolallstudentssure'] = 'Are you sure you want to completely unenrol all students from this course?';
 $string['unenrolme'] = 'Unenrol me from $a';
 $string['unenrolsure'] = 'Are you sure you want to unenrol $a from this course?';
 $string['unknowncategory'] = 'Unknown category';