From: martin Date: Wed, 19 Jun 2002 15:42:49 +0000 (+0000) Subject: Modifications to unenrol. Now a teacher can unenrol students from the course. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7dc1ea300ad6a469680d947d6ec5ff85dd14c9bf;p=moodle.git Modifications to unenrol. Now a teacher can unenrol students from the course. --- diff --git a/course/unenrol.php b/course/unenrol.php index 71a2b9adbb..be0fd6b984 100644 --- a/course/unenrol.php +++ b/course/unenrol.php @@ -1,6 +1,6 @@ id); //user if (! $course = get_record("course", "id", $id) ) { error("That's an invalid course id"); } + if (! $user = get_record("user", "id", $user) ) { + error("That's an invalid user id"); + } require_login($course->id); + if ($user->id != $USER->id and !isteacher($course->id)) { + error("You must be a teacher to do this"); + } + if (isset($confirm)) { - if (! unenrol_student_in_course($USER->id, $course->id)) { + + if (! unenrol_student_in_course($user->id, $course->id)) { error("An error occurred while trying to unenrol you."); } // remove some other things - delete_records("discuss_subscriptions", "user", $USER->id); + delete_records("discuss_subscriptions", "user", $user->id); - add_to_log($course->id, "course", "unenrol", "view.php?id=$course->id", "$USER->id"); + add_to_log($course->id, "course", "unenrol", "view.php?id=$course->id", "$user->id"); - unset($USER->student["$id"]); + if ($user->id == $USER->id) { + unset($USER->student["$id"]); + redirect("$CFG->wwwroot"); + } - redirect("$CFG->wwwroot"); + redirect("$CFG->wwwroot/user/index.php?id=$course->id"); } print_header("Unenrol from $course->shortname", "$course->shortname", "wwwroot/course/view.php?id=$course->id\">$course->shortname -> Unenrol"); - notice_yesno ("Are you sure you want to remove yourself from this course?", - "unenrol.php?id=$id&confirm=yes", - "$HTTP_REFERER"); + if ($user->id == $USER->id) { + notice_yesno ("Are you sure you want to remove yourself from this course?", + "unenrol.php?id=$id&user=$user->id&confirm=yes", "$HTTP_REFERER"); + } else { + notice_yesno ("Are you sure you want to remove $user->firstname $user->lastname from this course?", + "unenrol.php?id=$id&user=$user->id&confirm=yes", "$HTTP_REFERER"); + } print_footer(); diff --git a/user/index.php b/user/index.php index 9f2bb46cfb..9c325df881 100644 --- a/user/index.php +++ b/user/index.php @@ -79,6 +79,7 @@ function print_user($user, $course, $teacherlinks) { echo "id&user=$user->id\">Contributions
"; echo "id&user=$user->id&date=$timemidnight\">Today's logs
"; echo "id&user=$user->id\">All logs
"; + echo "id&user=$user->id\">Unenrol
"; if (isstudent($course->id, $user->id)) { echo "id&user=$user->id\">Login as
"; }