]> git.mjollnir.org Git - moodle.git/commitdiff
Deleting deprecated methods of assigning people to courses
authormoodler <moodler>
Fri, 15 Sep 2006 16:03:49 +0000 (16:03 +0000)
committermoodler <moodler>
Fri, 15 Sep 2006 16:03:49 +0000 (16:03 +0000)
course/student.html [deleted file]
course/student.php [deleted file]
course/teacher.php [deleted file]

diff --git a/course/student.html b/course/student.html
deleted file mode 100644 (file)
index a7fdf54..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-
-<form name="studentform" id="studentform" method="post" action="student.php">
-<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>" />
-<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
-<input type="hidden" name="id" value="<?php echo $course->id ?>" />
-  <table align="center" border="0" cellpadding="5" cellspacing="0">
-    <tr>
-      <td valign="top">
-          <?php
-              $a->count = count($students);
-              $a->items = $strexistingstudents;
-              print_string('counteditems', '', $a);
-          ?>
-      </td>
-      <td></td>
-      <td valign="top">
-          <?php
-              $a->count = $usercount;
-              $a->items = $strpotentialstudents;
-              print_string('counteditems', '', $a);
-          ?>
-      </td>
-    </tr>
-    <tr>
-      <td valign="top">
-          <select name="removeselect[]" size="20" id="removeselect" multiple
-                  onFocus="document.studentform.add.disabled=true;
-                           document.studentform.remove.disabled=false;
-                           document.studentform.addselect.selectedIndex=-1;" />
-          <?php 
-              foreach ($students as $student) {
-                  $fullname = fullname($student, true);
-                  echo "<option value=\"$student->id\">".$fullname.", ".$student->email."</option>\n";
-              }
-          ?>
-          
-          </select></td>
-      <td valign="top">
-        <br />
-        <input name="add" type="submit" id="add" value="&larr;" />
-        <br />
-        <input name="remove" type="submit" id="remove" value="&rarr;" />
-        <br />
-      </td>
-      <td valign="top">
-          <select name="addselect[]" size="20" id="addselect" multiple
-                  onFocus="document.studentform.add.disabled=false;
-                           document.studentform.remove.disabled=true;
-                           document.studentform.removeselect.selectedIndex=-1;">
-          <?php
-      
-              if (!empty($searchusers)) {
-                  echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
-                  foreach ($searchusers as $user) {
-                      $fullname = fullname($user, true);
-                      echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
-                  }
-                  echo "</optgroup>\n";
-              }
-        else {
-                  if ($usercount > MAX_USERS_PER_PAGE) {
-                      echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
-                          .'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
-                  }
-                  else {
-                      if ($usercount > 0) {    //fix for bug#4455
-                          foreach ($users as $user) {
-                              $fullname = fullname($user, true);
-                              echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
-                          }
-                      }
-                  }
-              }
-          ?>
-         </select>
-         <br />
-         <input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>" 
-                  onFocus ="document.studentform.add.disabled=true;
-                            document.studentform.remove.disabled=true;
-                            document.studentform.removeselect.selectedIndex=-1;
-                            document.studentform.addselect.selectedIndex=-1;"
-                  onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
-                               if (keyCode == 13) {
-                                    document.studentform.previoussearch.value=1;
-                                    document.studentform.submit();
-                               } " />
-         <input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
-         <?php
-              if (!empty($searchusers)) {
-                  echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
-              }
-         ?>
-       </td>
-    </tr>
-  </table>
-</form>
-
-
diff --git a/course/student.php b/course/student.php
deleted file mode 100644 (file)
index 08387e5..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php // $Id$
-      // Script to assign students to courses
-    //deprecated, should use admin/roles/assign.php now
-    require_once("../config.php");
-
-    define("MAX_USERS_PER_PAGE", 5000);
-
-    $id             = required_param('id',PARAM_INT); // course id
-    $add            = optional_param('add', 0, PARAM_BOOL);
-    $remove         = optional_param('remove', 0, PARAM_BOOL);
-    $showall        = optional_param('showall', 0, PARAM_BOOL);
-    $searchtext     = optional_param('searchtext', '', PARAM_RAW); // search string
-    $previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
-    $previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
-
-    if (! $site = get_site()) {
-        redirect("$CFG->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",
-                 "<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $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 .= "<p>".get_string("assignstudentspass", "",
-                                      "<a href=\"edit.php?id=$course->id\">$course->password</a>");
-        }
-        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 (file)
index fb228a9..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-<?php // $Id$
-      // Admin-only script to assign teachers to courses
-
-    /// This page is deprecated
-
-    require_once("../config.php");
-
-    define("MAX_USERS_PER_PAGE", 50);
-
-    $id     = required_param('id', PARAM_INT);         // course id
-    $add    = optional_param('add', 0, PARAM_INT);
-    $remove = optional_param('remove', 0, PARAM_INT);
-    $search = optional_param('search', '', PARAM_RAW); // search string
-
-    require_login();
-
-    if (! $course = get_record("course", "id", $id)) {
-        error("Course ID was incorrect (can't find it)");
-    }
-
-    if (!(isteacheredit($course->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", 
-                 "<a href=\"index.php\">$strcourses</a> -> ".
-                 "<a href=\"view.php?id=$course->id\">$course->shortname</a> -> ".
-                 "$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 "<p align=\"center\">$strnoexistingteachers</a>";
-        $teacherlist = "";
-
-    } else {
-
-        $table->head  = array ("", $strname, $strorder, $strrole, $stredit, "&nbsp;");
-        $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 "<form action=\"teacher.php\" method=\"post\">";
-        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 = "<input name=\"e$teacher->id\" type=\"hidden\" value=\"1\" />$stryes";
-            } else {
-                $editall = choose_from_menu ($editmenu, "e$teacher->id", $teacher->editall, "", "", "", true);
-            }
-    
-            $removelink = "<a href=\"teacher.php?id=$course->id&amp;remove=$teacher->id&amp;sesskey=$USER->sesskey\">$strremoveteacher</a>";
-
-            if (!$teacher->role) {
-                $teacher->role = $course->teacher;
-            }
-    
-            $table->data[] = array ($picture, fullname($teacher, true), $authority,
-                                    "<input type=\"text\" name=\"r$teacher->id\" value=\"$teacher->role\" size=\"30\" maxlength=\"40\" />",
-                                    $editall, $removelink);
-        }
-        $teacherlist = implode(",",$teacherarray);
-        unset($teacherarray);
-
-        print_table($table);
-        echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
-        echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
-        echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\" /> ";
-        echo "</center>";
-        echo "</form>";
-        echo "<br />";
-    }
-
-
-/// Print list of potential teachers
-
-    print_heading("$strpotentialteachers $parateachers");
-
-    $usercount = get_users(false, $search, true, $teacherlist);
-
-    if ($usercount == 0) {
-        echo "<p align=\"center\">$strnopotentialteachers</p>";
-
-    } else if ($usercount > MAX_USERS_PER_PAGE) {
-        echo "<p align=\"center\">$strtoomanytoshow ($usercount) </p>";
-
-    } else {
-
-        if ($search != '') {
-            echo "<p align=\"center\">($strsearchresults : ".s($search, true).")</p>";
-        }
-
-        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 = "<a href=\"teacher.php?id=$course->id&amp;add=$user->id&amp;sesskey=$USER->sesskey\">$straddteacher</a>";
-            $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 "<center>";
-        echo "<form action=\"teacher.php\" method=\"get\">";
-        echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
-        echo "<input type=\"text\" name=\"search\" size=\"20\" />";
-        echo "<input type=\"submit\" value=\"$searchstring\" />";
-        echo "</form>";
-        echo "</center>";
-    }
-
-    print_footer($course);
-
-?>