From c2bc0a4573ca9b9510fd9f242ebefc9ae14e4a40 Mon Sep 17 00:00:00 2001 From: martin Date: Sun, 8 Sep 2002 03:34:45 +0000 Subject: [PATCH] Need this file to go with the previous changes! --- course/teachers.php | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 course/teachers.php diff --git a/course/teachers.php b/course/teachers.php new file mode 100644 index 0000000000..8b812ad913 --- /dev/null +++ b/course/teachers.php @@ -0,0 +1,78 @@ +id); + + if (!isteacher($course->id)) { + error("Only teachers can edit the course!"); + } + + +/// If data submitted, then process and store. + + if (match_referer() && isset($HTTP_POST_VARS)) { + + $rank = array(); + + // Peel out all the data from variable names. + foreach ($HTTP_POST_VARS 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_sql("SELECT * FROM user_teachers WHERE course='$course->id' and user='$num'")) { + error("No such teacher in course $course->shortname with user id $num"); + } + $teacher->role = $vals[r]; + $teacher->authority = $vals[a]; + if (!update_record("user_teachers", $teacher)) { + error("Could not update teacher entry id = $teacher->id"); + } + } + redirect("teachers.php?id=$course->id", get_string("changessaved")); + } + +/// Otherwise fill and print the form. + + print_header($streditcoursesettings, "$course->fullname", + "wwwroot/course/view.php?id=$course->id\">$course->shortname + -> $course->teachers"); + + if (!$teachers = get_course_teachers($course->id)) { + error("No teachers found in this course!"); + } + + print_heading($course->teachers); + + echo "
"; + foreach ($teachers as $teacher) { + $table->head = array (get_string("name"), get_string("order"), get_string("role")); + $table->align = array ("LEFT", "CENTER", "CENTER"); + + $picture = print_user_picture($teacher->id, $course->id, $teacher->picture, false, true); + + $table->data[] = array ("$picture $teacher->firstname $teacher->lastname", + "id\" VALUE=\"$teacher->authority\" SIZE=2>", + "id\" VALUE=\"$teacher->role\" SIZE=30>"); + } + print_table($table); + echo "id\">"; + echo "

"; + echo "
"; + + print_footer($course); + +?> -- 2.39.5