From e808d25f566bf3576b8392ea4553206512d050c5 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 14 May 2003 15:58:48 +0000 Subject: [PATCH] Fixed up "Assign teacher" page, and moved it to admin directory. --- admin/admin.php | 13 ++--- admin/index.php | 4 +- {course => admin}/teacher.php | 100 +++++++++++++++------------------- course/edit.php | 2 +- course/lib.php | 2 +- 5 files changed, 54 insertions(+), 67 deletions(-) rename {course => admin}/teacher.php (58%) diff --git a/admin/admin.php b/admin/admin.php index 9a5caff48a..da87eb1ca9 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -1,10 +1,9 @@ id; echo "

$admin->firstname $admin->lastname, - $admin->email    "; + $admin->email    "; if ($primaryadmin->id == $admin->id){ print_spacer(10, 9, false); } else { @@ -151,7 +150,7 @@ } else { if ($search) { - echo "

($strsearchresults)

"; + echo "

($strsearchresults : $search)

"; } if (!$users = get_users(true, $search, true, $adminlist)) { @@ -159,9 +158,9 @@ } foreach ($users as $user) { - echo "

id\"". + echo "

id\"". "title=\"$straddadmin\">  $user->firstname $user->lastname, $user->email"; + "border=0>  $user->firstname $user->lastname, $user->email"; } } diff --git a/admin/index.php b/admin/index.php index 04f312a43a..5939f0dfc0 100644 --- a/admin/index.php +++ b/admin/index.php @@ -337,7 +337,7 @@ $table->data[0][0] .= "

dbtype/frame.php\">".get_string("managedatabase")."

"; } $table->data[0][1] = "

".get_string("addnewcourse")."

". - "

".get_string("assignteachers")."

". + "

".get_string("assignteachers")."

". "

".get_string("deletecourse")."

". "

".get_string("categories")."

"; if ($CFG->auth == "email" || $CFG->auth == "none" || $CFG->auth == "manual") { @@ -351,7 +351,7 @@ $table->head = array (get_string("courses")); $table->align = array ("CENTER"); $table->data[0][1] = "

".get_string("addnewcourse")."

". - "

".get_string("assignteachers")."

"; + "

".get_string("assignteachers")."

"; } print_table($table); diff --git a/course/teacher.php b/admin/teacher.php similarity index 58% rename from course/teacher.php rename to admin/teacher.php index 5bbab39a92..701af60626 100644 --- a/course/teacher.php +++ b/admin/teacher.php @@ -2,7 +2,8 @@ // Admin-only script to assign teachers to courses require_once("../config.php"); - require_once("../user/lib.php"); + + define("MAX_USERS_PER_PAGE", 30); optional_variable($id); // course id @@ -31,18 +32,17 @@ if (!$id) { print_header("$site->shortname: $strassignteachers", "$site->fullname", - "admin/index.php\">$stradministration -> $strassignteachers"); + "$stradministration -> $strassignteachers"); $isadmin = isadmin(); /// cache value $courses = get_courses(); - print_heading(get_string("choosecourse")); - print_simple_box_start("CENTER"); + print_simple_box_start("center"); foreach ($courses as $course) { - if ($isadmin OR isteacher($course->id, $USER->id)){ - echo "id\">$course->fullname ($course->shortname)
\n"; + if ($isadmin or isteacher($course->id, $USER->id)){ + echo "id\">$course->fullname ($course->shortname)
\n"; $coursesfound = TRUE; } } @@ -65,9 +65,10 @@ print_header("$site->shortname: $course->shortname: $strassignteachers", "$site->fullname", - "admin/index.php\">$stradministration -> - $strassignteachers -> $course->shortname", ""); - print_heading("wwwroot/course/view.php?id=$course->id\">$course->fullname ($course->shortname)"); + "$stradministration -> + $strassignteachers -> $course->shortname", ""); + + print_heading("wwwroot/course/view.php?id=$course->id\">$course->fullname ($course->shortname)"); /// Get all existing teachers for this course. @@ -129,76 +130,63 @@ /// Print the lists of existing and potential teachers - echo ""; - echo ""; - echo "
$strexistingteachers$strpotentialteachers
"; + echo ""; + echo ""; + echo "
$strexistingteachers$strpotentialteachers
"; /// First, show existing teachers for this course if (empty($teachers)) { - echo "

$strnoexistingteachers"; + echo "

$strnoexistingteachers"; + $teacherlist = ""; } else { + $teacherarray = array(); foreach ($teachers as $teacher) { - echo "

$teacher->firstname $teacher->lastname, $teacher->email    id&remove=$teacher->id\" TITLE=\"$strremoveteacher\">

"; + $teacherarray[] = $teacher->id; + echo "

$teacher->firstname $teacher->lastname, $teacher->email    id&remove=$teacher->id\" title=\"$strremoveteacher\">

"; } + $teacherlist = implode(",",$teacherarray); + unset($teacherarray); } - echo "
"; + echo ""; /// Print list of potential teachers - if (!empty($search)) { - $users = get_users_search($search); + $usercount = get_users(false, $search, true, $teacherlist); - } else { - $users = get_users_confirmed(); - } + if ($usercount == 0) { + echo "

$strnopotentialteachers

"; - - if (!empty($users)) { - foreach ($users as $user) { // Remove users who are already teachers - if (!empty($teachers)) { - foreach ($teachers as $teacher) { - if ($teacher->id == $user->id) { - continue 2; - } - } - } - $potential[] = $user; - } - } + } else if ($usercount > MAX_USERS_PER_PAGE) { + echo "

$strtoomanytoshow

"; + + } else { - if (empty($potential)) { - echo "

$strnopotentialteachers"; if ($search) { - echo "

"; - echo "id\">"; - echo ""; - echo ""; - echo "
"; + echo "

($strsearchresults : $search)

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

($strsearchresults)

"; + if (!$users = get_users(true, $search, true, $teacherlist)) { + error("Could not get users!"); } - if (count($potential) <= 20) { - foreach ($potential as $user) { - echo "

id&add=$user->id\" TITLE=\"$straddteacher\">  $user->firstname $user->lastname, $user->email"; - } - } else { - echo "

There are too many users to show.
"; - echo "Enter a search word here."; - echo "

"; - echo "id\">"; - echo ""; - echo ""; - echo "
"; + + foreach ($users as $user) { + echo "

id&add=$user->id\"". + "title=\"$straddteacher\">  $user->firstname $user->lastname, $user->email"; } } - echo "

"; + if ($search or $usercount > MAX_USERS_PER_PAGE) { + echo "
"; + echo ""; + echo ""; + echo "
"; + } + + echo "
"; print_footer(); diff --git a/course/edit.php b/course/edit.php index 695cd13b86..36b88a6b54 100644 --- a/course/edit.php +++ b/course/edit.php @@ -64,7 +64,7 @@ add_to_log($newcourseid, "course", "new", "view.php?id=$newcourseid", ""); if (isadmin()) { // Redirect admin to add teachers - redirect("teacher.php?id=$newcourseid", get_string("changessaved")); + redirect("../$CFG->admin/teacher.php?id=$newcourseid", get_string("changessaved")); } else { // Add current teacher and send to course diff --git a/course/lib.php b/course/lib.php index 5a34a89a34..ef78bb43ab 100644 --- a/course/lib.php +++ b/course/lib.php @@ -749,7 +749,7 @@ function print_admin_links ($siteid, $width=180) { if (iscreator()) { $moddata[]="wwwroot/course/edit.php\">".get_string("addnewcourse").""; $modicon[]=$icon; - $moddata[]="wwwroot/course/teacher.php\">".get_string("assignteachers").""; + $moddata[]="wwwroot/$CFG->admin/teacher.php\">".get_string("assignteachers").""; $modicon[]=$icon; $fulladmin = ""; } -- 2.39.5