From 4361ddcb22c0c8e00b5277e5d3cc0129898f4170 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Wed, 18 Aug 2004 15:49:09 +0000 Subject: [PATCH] when adding students the teachers are no longer shown in list of potential students, closing bug 1749 --- course/student.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/course/student.php b/course/student.php index 3ec3d5fc9e..a83d68c475 100644 --- a/course/student.php +++ b/course/student.php @@ -1,7 +1,7 @@ students)"; } - print_header("$course->shortname: $strassignstudents", + print_header("$course->shortname: $strassignstudents", "$site->fullname", "id\">$course->shortname -> $strassignstudents", "studentform.searchtext"); @@ -93,31 +93,36 @@ $previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ; -/// Get all existing students for this course. +/// Get all existing students and teachers for this course. if (!$students = get_course_students($course->id, "u.firstname ASC, u.lastname ASC", "", 0, 99999, '', '', NULL, '', 'u.id,u.firstname,u.lastname,u.email')) { $students = array(); } - - $studentarray = array(); + if (!$teachers = get_course_teachers($course->id)) { + $teachers = array(); + } + $existinguserarray = array(); foreach ($students as $student) { - $studentarray[] = $student->id; + $existinguserarray[] = $student->id; + } + foreach ($teachers as $teacher) { + $existinguserarray[] = $teacher->id; } - $studentlist = implode(',', $studentarray); + $existinguserlist = implode(',', $existinguserarray); - unset($studentarray); + unset($existinguserarray); /// Get search results excluding any users already in this course if (!empty($frm->searchtext) and $previoussearch) { - $searchusers = get_users(true, $frm->searchtext, true, $studentlist, 'firstname ASC, lastname ASC', + $searchusers = get_users(true, $frm->searchtext, true, $existinguserlist, 'firstname ASC, lastname ASC', '', '', 0, 99999, 'id, firstname, lastname, email'); $usercount = get_users(false, '', true, $studentlist); } /// If no search results then get potential students for this course excluding users already in course if (empty($searchusers)) { - if (!$users = get_users(true, '', true, $studentlist, 'firstname ASC, lastname ASC', '', '', + if (!$users = get_users(true, '', true, $existinguserlist, 'firstname ASC, lastname ASC', '', '', 0, 99999, 'id, firstname, lastname, email') ) { $users = array(); } @@ -125,8 +130,6 @@ } - - $searchtext = (isset($frm->searchtext)) ? $frm->searchtext : ""; $previoussearch = ($previoussearch) ? '1' : '0'; -- 2.39.5