Permalink
Browse files

Improvements to the process of setting up Moodle the first time, also…

… better interface for adding/removing teachers
  • Loading branch information...
1 parent f3c7560 commit c88f014ac63dc8590527218fb4bb65aaaec684cf martin committed Dec 4, 2001
Showing with 69 additions and 25 deletions.
  1. +10 −0 admin/cron.php
  2. +10 −0 admin/index.php
  3. +49 −25 admin/teacher.php
View
@@ -32,6 +32,8 @@
$timenow = time();
+// Run all cron jobs for each module
+
if ($mods = get_records_sql("SELECT * FROM modules WHERE cron > 0 AND (($timenow - lastcron) > cron)")) {
foreach ($mods as $mod) {
$cronfile = "$CFG->dirroot/mod/$mod->name/cron.php";
@@ -43,6 +45,14 @@
}
}
}
+
+
+// Any system-wide Moodle cron jobs should be run here
+
+ // Clean up users who never confirmed.
+
+
+
echo "Cron script completed correctly\n";
?>
View
@@ -46,11 +46,16 @@
// do nothing
} else if ($currmodule->version < $module->version) {
notify("$module->name module needs upgrading"); // XXX do the upgrade here
+ $updated_modules = true;
} else {
error("Version mismatch: $module->name can't downgrade $currmodule->version -> $module->version !");
}
} else { // module not installed yet, so install it
+ if (!$updated_modules) {
+ print_header("Setting up database", "Setting up database", "Setting up module tables", "");
+ }
+ $updated_modules = true;
if (modify_database("$fullmod/install.sql")) {
if ($module->id = insert_record("modules", $module)) {
notify("$module->name tables have been set up correctly");
@@ -63,6 +68,11 @@
}
}
+ if ($updated_modules) {
+ print_heading("<A HREF=\"index.php\">Continue</A>");
+ die;
+ }
+
// Set up the overall site name etc.
if (! $course = get_record("course", "category", 0)) {
redirect("site.php");
View
@@ -35,6 +35,7 @@
print_header("Add teachers to $course->shortname", "Add teachers to a course", "<A HREF=\"$CFG->wwwroot/admin\">Admin</A> -> Add teachers to $course->shortname", "");
+ print_heading($course->fullname);
/// Get all existing teachers for this course.
@@ -50,9 +51,11 @@
error("That teacher (id = $add) doesn't exist", "teacher.php?id=$course->id");
}
- foreach ($teachers as $tt) {
- if ($tt->id == $user->id) {
- error("That user is already a teacher for this course.", "teacher.php?id=$course->id");
+ if ($teachers) {
+ foreach ($teachers as $tt) {
+ if ($tt->id == $user->id) {
+ error("That user is already a teacher for this course.", "teacher.php?id=$course->id");
+ }
}
}
@@ -77,9 +80,11 @@
if (! $user = get_record("user", "id", $remove)) {
error("That teacher (id = $remove) doesn't exist", "teacher.php?id=$course->id");
}
- foreach ($teachers as $tt) {
- if ($tt->id == $user->id) {
- delete_records("user_teachers", "id", "$tt->teachid");
+ if ($teachers) {
+ foreach ($teachers as $tt) {
+ if ($tt->id == $user->id) {
+ delete_records("user_teachers", "id", "$tt->teachid");
+ }
}
}
$teachers = get_records_sql("SELECT u.*,t.authority,t.id as teachid FROM user u, user_teachers t
@@ -89,22 +94,26 @@
}
-/// Show existing teachers for this course
+/// Print the lists of existing and potential teachers
+
+ echo "<TABLE CELLPADDING=2 CELLSPACING=10 ALIGN=CENTER>";
+ echo "<TR><TH WIDTH=50%>Existing Teachers</TH><TH WIDTH=50%>Potential Teachers</TH></TR>";
+ echo "<TR><TD WIDTH=50% NOWRAP VALIGN=TOP>";
+
+/// First, show existing teachers for this course
- if ($teachers) {
- print_simple_box_start("center", "", "$THEME->cellheading");
- print_heading("Existing teachers");
+ if (! $teachers) {
+ echo "<P ALIGN=CENTER>No existing teachers</A>";
+
+ } else {
foreach ($teachers as $teacher) {
- echo "<LI>$teacher->firstname $teacher->lastname, $teacher->email &nbsp;&nbsp; <A HREF=\"teacher.php?id=$course->id&remove=$teacher->id\">remove</A>";
+ echo "<P ALIGN=right>$teacher->firstname $teacher->lastname, $teacher->email &nbsp;&nbsp; <A HREF=\"teacher.php?id=$course->id&remove=$teacher->id\" TITLE=\"Remove teacher\"><IMG SRC=\"../pix/t/right.gif\" BORDER=0></A></P>";
}
- print_simple_box_end();
}
-/// Print list of potential teachers
+ echo "<TD WIDTH=50% NOWRAP VALIGN=TOP>";
- echo "<BR>";
- print_simple_box_start("center", "", "$THEME->cellcontent");
- print_heading("Potential teachers");
+/// Print list of potential teachers
if ($search) {
$users = get_records_sql("SELECT * from user WHERE confirmed = 1
@@ -116,25 +125,40 @@
}
- foreach ($users as $user) { // Remove users who are already teachers
- foreach ($teachers as $teacher) {
- if ($teacher->id == $user->id) {
- continue 2;
+ if ($users) {
+ foreach ($users as $user) { // Remove users who are already teachers
+ if ($teachers) {
+ foreach ($teachers as $teacher) {
+ if ($teacher->id == $user->id) {
+ continue 2;
+ }
+ }
}
+ $potential[] = $user;
}
- $potential[] = $user;
}
if (! $potential) {
- echo "No potential teachers";
+ echo "<P ALIGN=CENTER>No potential teachers</A>";
+ if ($search) {
+ 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=\"Search again\">";
+ echo "</FORM>";
+ }
} else {
+ if ($search) {
+ echo "<P ALIGN=CENTER>(Search results)</P>";
+ }
if (count($potential) <= 20) {
foreach ($potential as $user) {
- echo "<LI>$user->firstname $user->lastname, $user->email &nbsp;&nbsp; <A HREF=\"teacher.php?id=$course->id&add=$user->id\">add</A>";
+ echo "<P ALIGN=LEFT><A HREF=\"teacher.php?id=$course->id&add=$user->id\" TITLE=\"Add teacher\"><IMG SRC=\"../pix/t/left.gif\" BORDER=0></A>&nbsp;&nbsp;$user->firstname $user->lastname, $user->email";
}
} else {
- echo "There are too many users to show.<BR>Enter a search word here.";
+ echo "<P ALIGN=CENTER>There are too many users to show.<BR>";
+ echo "Enter a search word here.";
echo "<FORM ACTION=teacher.php METHOD=GET>";
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">";
echo "<INPUT TYPE=text NAME=search SIZE=20>";
@@ -143,7 +167,7 @@
}
}
- print_simple_box_end();
+ echo "</TR></TABLE>";
print_footer();

0 comments on commit c88f014

Please sign in to comment.