From d3e47e0d665d56e61a16e51b0ba16f7ba09710ba Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 15 Sep 2006 16:03:49 +0000 Subject: [PATCH] Deleting deprecated methods of assigning people to courses --- course/student.html | 98 ------------------- course/student.php | 148 ----------------------------- course/teacher.php | 226 -------------------------------------------- 3 files changed, 472 deletions(-) delete mode 100644 course/student.html delete mode 100644 course/student.php delete mode 100644 course/teacher.php diff --git a/course/student.html b/course/student.html deleted file mode 100644 index a7fdf549b5..0000000000 --- a/course/student.html +++ /dev/null @@ -1,98 +0,0 @@ - -
- - - - - - - - - - - - - - -
- count = count($students); - $a->items = $strexistingstudents; - print_string('counteditems', '', $a); - ?> - - count = $usercount; - $a->items = $strpotentialstudents; - print_string('counteditems', '', $a); - ?> -
- -
- -
- -
-
- -
- - - '."\n"; - } - ?> -
-
- - diff --git a/course/student.php b/course/student.php deleted file mode 100644 index 08387e5cc1..0000000000 --- a/course/student.php +++ /dev/null @@ -1,148 +0,0 @@ -wwwroot/$CFG->admin/index.php"); - } - - if (! $course = get_record("course", "id", $id)) { - error("Course ID was incorrect (can't find it)"); - } - - if ($course->metacourse) { - redirect("$CFG->wwwroot/course/importstudents.php?id=$course->id"); - } - - require_login($course->id); - - if (!isteacheredit($course->id)) { - error("You must be an editing teacher in this course, or an admin"); - } - - $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"); - $strstudents = get_string("students"); - $strshowall = get_string("showall"); - - - if ($course->students != $strstudents) { - $strassignstudents .= " ($course->students)"; - $strpotentialstudents .= " ($course->students)"; - $strexistingstudents .= " ($course->students)"; - } - - print_header("$course->shortname: $strassignstudents", - "$site->fullname", - "id\">$course->shortname -> $strassignstudents", - "studentform.searchtext"); - - -/// Print a help notice about the need to use this page - - if (!$frm = data_submitted()) { - $note = get_string("assignstudentsnote"); - - if ($course->password) { - $note .= "

".get_string("assignstudentspass", "", - "id\">$course->password"); - } - print_simple_box($note, "center", "50%"); - -/// A form was submitted so process the input - - } else { - if ($add and !empty($frm->addselect) and confirm_sesskey()) { - if ($course->enrolperiod) { - $timestart = time(); - $timeend = $timestart + $course->enrolperiod; - } else { - $timestart = $timeend = 0; - } - foreach ($frm->addselect as $addstudent) { - $addstudent = clean_param($addstudent, PARAM_INT); - if (! enrol_student($addstudent, $course->id, $timestart, $timeend)) { - error("Could not add student with id $addstudent to this course!"); - } - } - } else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) { - foreach ($frm->removeselect as $removestudent) { - $removestudent = clean_param($removestudent, PARAM_INT); - if (! unenrol_student($removestudent, $course->id)) { - error("Could not remove student with id $removestudent from this course!"); - } - } - } else if ($showall) { - $searchtext = ''; - $previoussearch = 0; - } - } - - -/// Get all existing students and teachers for this course. - if (!$students = get_course_students($course->id, "u.firstname ASC, u.lastname ASC", "", 0, '', - '', '', NULL, '', 'u.id,u.firstname,u.lastname,u.email')) { - $students = array(); - } - if (!$teachers = get_course_teachers($course->id)) { - $teachers = array(); - } - $existinguserarray = array(); - foreach ($students as $student) { - $existinguserarray[] = $student->id; - } - foreach ($teachers as $teacher) { - $existinguserarray[] = $teacher->id; - } - $existinguserlist = implode(',', $existinguserarray); - - unset($existinguserarray); - - $usercount = get_users(false, '', true, $existinguserlist); - -/// Get search results excluding any users already in this course - if (($searchtext != '') and $previoussearch) { - $searchusers = get_users(true, $searchtext, true, $existinguserlist, 'firstname ASC, lastname ASC', - '', '', 0, MAX_USERS_PER_PAGE, 'id, firstname, lastname, email'); - } - -/// If no search results then get potential students for this course excluding users already in course - if (empty($searchusers)) { - $users = array(); - if ($usercount <= MAX_USERS_PER_PAGE) { - if (!$users = get_users(true, '', true, $existinguserlist, 'firstname ASC, lastname ASC', '', '', - 0, MAX_USERS_PER_PAGE, 'id, firstname, lastname, email')) { - $users = array(); - } - } - - } - - - print_simple_box_start("center"); - - include('student.html'); - - print_simple_box_end(); - - print_footer($course); - -?> diff --git a/course/teacher.php b/course/teacher.php deleted file mode 100644 index fb228a911f..0000000000 --- a/course/teacher.php +++ /dev/null @@ -1,226 +0,0 @@ -id) and has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) and - !(isteacheredit($course->id) and !empty($CFG->teacherassignteachers) ) ) { - error("You must be an administrator or course creator to use this page."); - } - - $strassignteachers = get_string("assignteachers"); - $strcourses = get_string("courses"); - $strteachers = get_string("teachers"); - $stradministration = get_string("administration"); - $strexistingteachers = get_string("existingteachers"); - $strnoexistingteachers = get_string("noexistingteachers"); - $strpotentialteachers = get_string("potentialteachers"); - $strnopotentialteachers = get_string("nopotentialteachers"); - $straddteacher = get_string("addteacher"); - $strremoveteacher = get_string("removeteacher"); - $strsearch = get_string("search"); - $strsearchresults = get_string("searchresults"); - $strsearchagain = get_string("searchagain"); - $strtoomanytoshow = get_string("toomanytoshow"); - $strname = get_string("name"); - $strorder = get_string("order"); - $strrole = get_string("role"); - $stredit = get_string("editingteachershort"); - $stryes = get_string("yes"); - $strno = get_string("no"); - - if ($search) { - $searchstring = $strsearchagain; - } else { - $searchstring = $strsearch; - } - - if ($course->teachers != $strteachers) { - $parateachers = " ($course->teachers)"; - } else { - $parateachers = ""; - } - - -/// If data submitted, then process and store. - - if ($form = data_submitted() and confirm_sesskey()) { - unset ($form->sesskey); - $rank = array(); - - // Peel out all the data from variable names. - foreach ($form as $key => $val) { - if ($key <> "id") { - $type = substr($key,0,1); - $num = substr($key,1); - $rank[$num][$type] = $val; - } - } - - foreach ($rank as $num => $vals) { - if (! $teacher = get_record("user_teachers", "course", "$course->id", "userid", "$num")) { - error("No such teacher in course $course->shortname with user id $num"); - } - $teacher->role = $vals['r']; - $teacher->authority = $vals['a']; - $teacher->editall = $vals['e']; - if (!update_record("user_teachers", $teacher)) { - error("Could not update teacher entry id = $teacher->id"); - } - } - redirect("teacher.php?id=$course->id", get_string("changessaved")); - } - - -/// Print headers - - print_header("$course->shortname: $strassignteachers", - "$course->fullname", - "$strcourses -> ". - "id\">$course->shortname -> ". - "$strassignteachers", ""); - -/// Add a teacher if one is specified - - if (!empty($add) and confirm_sesskey()) { - if (! add_teacher($add, $course->id)) { - error("Could not add that teacher to this course!"); - } - } - -/// Remove a teacher if one is specified. - - if (!empty($remove) and confirm_sesskey()) { - if (! remove_teacher($remove, $course->id)) { - error("Could not remove that teacher from this course!"); - } - } - -/// Display all current teachers for this course. - $teachers = get_course_teachers($course->id); - - print_heading_with_help("$strexistingteachers $parateachers", "teachers"); - - if (empty($teachers)) { - echo "

$strnoexistingteachers"; - $teacherlist = ""; - - } else { - - $table->head = array ("", $strname, $strorder, $strrole, $stredit, " "); - $table->align = array ("right", "left", "center", "center", "center", "center"); - $table->size = array ("35", "", "", "", "10", ""); - - $ordermenu = NULL; - $ordermenu[0] = get_string("hide"); - for ($i=1; $i<=8; $i++) { - $ordermenu[$i] = $i; - } - - $editmenu = NULL; - $editmenu[0] = $strno; - $editmenu[1] = $stryes; - - $teacherarray = array(); - - echo "

"; - foreach ($teachers as $teacher) { - $teacherarray[] = $teacher->id; - - $picture = print_user_picture($teacher->id, $course->id, $teacher->picture, false, true); - - $authority = choose_from_menu ($ordermenu, "a$teacher->id", $teacher->authority, "", "", "", true); - - if ($USER->id == $teacher->id) { - $editall = "id\" type=\"hidden\" value=\"1\" />$stryes"; - } else { - $editall = choose_from_menu ($editmenu, "e$teacher->id", $teacher->editall, "", "", "", true); - } - - $removelink = "id&remove=$teacher->id&sesskey=$USER->sesskey\">$strremoveteacher"; - - if (!$teacher->role) { - $teacher->role = $course->teacher; - } - - $table->data[] = array ($picture, fullname($teacher, true), $authority, - "id\" value=\"$teacher->role\" size=\"30\" maxlength=\"40\" />", - $editall, $removelink); - } - $teacherlist = implode(",",$teacherarray); - unset($teacherarray); - - print_table($table); - echo "id\" />"; - echo "sesskey\" />"; - echo "
"; - echo "
"; - echo "
"; - echo "
"; - } - - -/// Print list of potential teachers - - print_heading("$strpotentialteachers $parateachers"); - - $usercount = get_users(false, $search, true, $teacherlist); - - if ($usercount == 0) { - echo "

$strnopotentialteachers

"; - - } else if ($usercount > MAX_USERS_PER_PAGE) { - echo "

$strtoomanytoshow ($usercount)

"; - - } else { - - if ($search != '') { - echo "

($strsearchresults : ".s($search, true).")

"; - } - - if (!$users = get_users(true, $search, true, $teacherlist)) { - error("Could not get users!"); - } - - unset($table); - $table->head = array ("", get_string("name"), get_string("email"), ""); - $table->align = array ("right", "left", "center", "center"); - $table->size = array ("35", "", "", ""); - - - foreach ($users as $user) { - $addlink = "id&add=$user->id&sesskey=$USER->sesskey\">$straddteacher"; - $picture = print_user_picture($user->id, $course->id, $user->picture, false, true); - $table->data[] = array ($picture, fullname($user, true), $user->email, $addlink); - } - print_table($table); - } - - if (($search != '') or $usercount > MAX_USERS_PER_PAGE) { - echo "
"; - echo "
"; - echo "id\" />"; - echo ""; - echo ""; - echo "
"; - echo "
"; - } - - print_footer($course); - -?> -- 2.39.5