]> git.mjollnir.org Git - moodle.git/commitdiff
when adding students the teachers are no longer shown in list of potential students...
authorgustav_delius <gustav_delius>
Wed, 18 Aug 2004 15:49:09 +0000 (15:49 +0000)
committergustav_delius <gustav_delius>
Wed, 18 Aug 2004 15:49:09 +0000 (15:49 +0000)
course/student.php

index 3ec3d5fc9eedb4cf62358e24ca38de51259df83f..a83d68c4757854108fb7e85690cd53f3766c509d 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP // $Id$
       // Script to assign students to courses
 
-       require_once("../config.php");
+    require_once("../config.php");
 
     define("MAX_USERS_PER_PAGE", 50);
 
@@ -43,7 +43,7 @@
         $strexistingstudents .= " ($course->students)";
     }
 
-       print_header("$course->shortname: $strassignstudents", 
+    print_header("$course->shortname: $strassignstudents", 
                  "$site->fullname", 
                  "<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $strassignstudents", 
                  "studentform.searchtext");
 
     $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();
         }
     }
 
 
-    
-
     $searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
     $previoussearch = ($previoussearch) ? '1' : '0';