From: martin Date: Tue, 4 Dec 2001 14:02:36 +0000 (+0000) Subject: Improvements to the process of setting up Moodle the first time, also better interfac... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c88f014ac63dc8590527218fb4bb65aaaec684cf;p=moodle.git Improvements to the process of setting up Moodle the first time, also better interface for adding/removing teachers --- diff --git a/admin/cron.php b/admin/cron.php index 7b2851cfc5..899efc6ab2 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -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"; ?> diff --git a/admin/index.php b/admin/index.php index c68dd77ce1..b6fdd252d1 100644 --- a/admin/index.php +++ b/admin/index.php @@ -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("Continue"); + die; + } + // Set up the overall site name etc. if (! $course = get_record("course", "category", 0)) { redirect("site.php"); diff --git a/admin/teacher.php b/admin/teacher.php index f274272cb7..1c576e68bc 100644 --- a/admin/teacher.php +++ b/admin/teacher.php @@ -35,6 +35,7 @@ print_header("Add teachers to $course->shortname", "Add teachers to a course", "wwwroot/admin\">Admin -> 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 ""; + echo ""; + echo "
Existing TeachersPotential Teachers
"; + +/// First, show existing teachers for this course - if ($teachers) { - print_simple_box_start("center", "", "$THEME->cellheading"); - print_heading("Existing teachers"); + if (! $teachers) { + echo "

No existing teachers"; + + } else { foreach ($teachers as $teacher) { - echo "

  • $teacher->firstname $teacher->lastname, $teacher->email    id&remove=$teacher->id\">remove"; + echo "

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

    "; } - print_simple_box_end(); } -/// Print list of potential teachers + echo "
  • "; - echo "
    "; - 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 "

    No potential teachers"; + if ($search) { + echo "

    "; + echo "id\">"; + echo ""; + echo ""; + echo "
    "; + } } else { + if ($search) { + echo "

    (Search results)

    "; + } if (count($potential) <= 20) { foreach ($potential as $user) { - echo "
  • $user->firstname $user->lastname, $user->email    id&add=$user->id\">add"; + echo "

    id&add=$user->id\" TITLE=\"Add teacher\">  $user->firstname $user->lastname, $user->email"; } } else { - echo "There are too many users to show.
    Enter a search word here."; + echo "

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

    "; echo "id\">"; echo ""; @@ -143,7 +167,7 @@ } } - print_simple_box_end(); + echo "
  • "; print_footer();