diff --git a/course/lib.php b/course/lib.php
index 1c9f4f3299b..ec643d98890 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -753,6 +753,9 @@ function print_course_admin_links($course, $width=180) {
$admindata[]="id\">$course->teachers...";
$adminicon[]="
";
+ $admindata[]="id\">$course->students...";
+ $adminicon[]="
";
+
$admindata[]="wwwroot/backup/backup.php?id=$course->id\">".get_string("backup")."...";
$adminicon[]="
";
diff --git a/course/student.php b/course/student.php
new file mode 100644
index 00000000000..e900b12ec0f
--- /dev/null
+++ b/course/student.php
@@ -0,0 +1,141 @@
+wwwroot/$CFG->admin/index.php");
+ }
+
+ if (! $course = get_record("course", "id", $id)) {
+ error("Course ID was incorrect (can't find it)");
+ }
+
+ require_login($course->id);
+
+ if (!isteacheredit($course->id)) {
+ error("You must be able to edit this course to assign students");
+ }
+
+ $strassignstudents = get_string("assignstudents");
+ $strexistingstudents = get_string("existingstudents");
+ $strnoexistingstudents = get_string("noexistingstudents");
+ $strpotentialstudents = get_string("potentialstudents");
+ $strnopotentialstudents = get_string("nopotentialstudents");
+ $straddstudent = get_string("addstudent");
+ $strremovestudent = get_string("removestudent");
+ $strsearch = get_string("search");
+ $strsearchresults = get_string("searchresults");
+ $strsearchagain = get_string("searchagain");
+ $strtoomanytoshow = get_string("toomanytoshow");
+
+ if ($search) {
+ $searchstring = $strsearchagain;
+ } else {
+ $searchstring = $strsearch;
+ }
+
+ print_header("$course->shortname: $strassignstudents",
+ "$site->fullname",
+ "id\">$course->shortname -> $strassignstudents", "");
+
+/// Add a student if one is specified
+
+ if (!empty($add)) {
+ if (! enrol_student($add, $course->id)) {
+ error("Could not add that student to this course!");
+ }
+ }
+
+/// Remove a student if one is specified.
+
+ if (!empty($remove)) {
+ if (! unenrol_student($remove, $course->id)) {
+ error("Could not add that student to this course!");
+ }
+ }
+
+/// Print a help notice about the need to use this page
+
+ if (empty($add) and empty($remove)) {
+ $note = get_string("assignstudentsnote");
+ if ($course->password) {
+ $note .= "
".get_string("assignstudentspass", "", $course->password); + } + print_simple_box($note, "center", "50%"); + } + +/// Get all existing students for this course. + $students = get_course_students($course->id); + +/// Print the lists of existing and potential students + + echo "
| $strexistingstudents | $strpotentialstudents |
|---|---|
| ";
+
+/// First, show existing students for this course
+
+ if (empty($students)) {
+ echo " $strnoexistingstudents"; + $studentlist = ""; + + } else { + $studentarray = array(); + foreach ($students as $student) { + $studentarray[] = $student->id; + echo " $student->firstname $student->lastname, $student->email id&remove=$student->id\" title=\"$strremovestudent\"> | ";
+
+/// Print list of potential students
+
+ $usercount = get_users(false, $search, true, $studentlist);
+
+ if ($usercount == 0) {
+ echo " $strnopotentialstudents "; + + } else if ($usercount > MAX_USERS_PER_PAGE) { + echo "$strtoomanytoshow "; + + } else { + + if ($search) { + echo "($strsearchresults : $search) "; + } + + if (!$users = get_users(true, $search, true, $studentlist)) { + error("Could not get users!"); + } + + foreach ($users as $user) { + echo "id&add=$user->id\"".
+ "title=\"$straddstudent\"> |