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); ?>