From 3486b7bee5de8213ded8caea64e88a0318fa0d2f Mon Sep 17 00:00:00 2001 From: moodler <moodler> Date: Thu, 17 Oct 2002 07:23:12 +0000 Subject: [PATCH] Added a new grading tool for teachers to see all grades on one page. Grades are collected from each module using the module_grades function in each mod/*/lib.php. --- course/grades.php | 100 ++++++++++++++++++++++++++++++++++++++++++++++ course/lib.php | 3 ++ pix/i/grades.gif | Bin 0 -> 88 bytes 3 files changed, 103 insertions(+) create mode 100644 course/grades.php create mode 100755 pix/i/grades.gif diff --git a/course/grades.php b/course/grades.php new file mode 100644 index 0000000000..6d80221182 --- /dev/null +++ b/course/grades.php @@ -0,0 +1,100 @@ +<?PHP // $Id$ + // Displays all grades for a course + + require("../config.php"); + require("lib.php"); + + require_variable($id); // course id + + if (! $course = get_record("course", "id", $id)) { + error("Course ID was incorrect"); + } + + require_login($course->id); + + if (!isteacher($course->id)) { + error("Only teachers can use this page!"); + } + + $strgrades = get_string("grades"); + $strgrade = get_string("grade"); + + +/// Otherwise fill and print the form. + + print_header("$course->shortname: $strgrades", "$course->fullname", + "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> + -> $strgrades"); + + print_heading($strgrades); + + if (!$students = get_course_students($course->id)) { + print_heading(get_string("nostudentsyet")); + print_footer($course); + exit; + } + + foreach ($students as $student) { + $grades[$student->id] = array(); // Collect all grades in this array + } + $columns = array(); // Accumulate column names in this array. + + // Collect module data + get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts); + + $sections = get_all_sections($course->id); // Sort everything the same as the course + for ($i=0; $i<=$course->numsections; $i++) { + if (isset($sections[$i])) { // should always be true + $section = $sections[$i]; + if ($section->sequence) { + $sectionmods = explode(",", $section->sequence); + foreach ($sectionmods as $sectionmod) { + $mod = $mods[$sectionmod]; + $instance = get_record("$mod->modname", "id", "$mod->instance"); + $libfile = "$CFG->dirroot/mod/$mod->modname/lib.php"; + if (file_exists($libfile)) { + require_once($libfile); + $gradefunction = $mod->modname."_grades"; + if (function_exists($gradefunction)) { // Skip modules without grade function + $image = "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"". + " TITLE=\"$mod->modfullname\">". + "<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ". + "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>"; + $columns[] = "$image ". + "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">". + "$instance->name". + "</A>"; + + $modgrades = $gradefunction($mod->instance); + + foreach ($students as $student) { + $grades[$student->id][] = $modgrades[$student->id]->grade; // may be empty, that's ok + } + } + } + } + } + } + } // a new Moodle nesting record? ;-) + + $table->head = array ("", get_string("name")); + $table->head = array_merge($table->head, $columns); + $table->width = array(35, ""); + $table->align = array("LEFT", "LEFT"); + foreach ($columns as $column) { + $table->width[] = ""; + $table->align[] = "CENTER"; + } + + foreach ($grades as $studentid => $gradelist) { + $student = $students[$studentid]; + $picture = print_user_picture($student->id, $course->id, $student->picture, false, true); + $name = array ("$picture", "$student->firstname $student->lastname"); + $table->data[] = array_merge($name, $gradelist); + } + + print_table($table); + + print_footer($course); + +?> diff --git a/course/lib.php b/course/lib.php index 874849cb42..00cd86132b 100644 --- a/course/lib.php +++ b/course/lib.php @@ -534,6 +534,9 @@ function print_course_admin_links($course, $width=180) { $admindata[]="<A HREF=\"teachers.php?id=$course->id\">$course->teachers...</A>"; $adminicon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; + $admindata[]="<A HREF=\"grades.php?id=$course->id\">".get_string("grades")."...</A>"; + $adminicon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/grades.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; + $admindata[]="<A HREF=\"log.php?id=$course->id\">".get_string("logs")."...</A>"; $adminicon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; $admindata[]="<A HREF=\"$CFG->wwwroot/files/index.php?id=$course->id\">".get_string("files")."...</A>"; diff --git a/pix/i/grades.gif b/pix/i/grades.gif new file mode 100755 index 0000000000000000000000000000000000000000..355e73458612551323aa89595d6a61fcca2fb838 GIT binary patch literal 88 zcmZ?wbhEHb6krfwn8?5&{~ieC|NsBbz`&pb#6VF21_ma>DgBv;-`29tnB-^h=yv7Z pF4iRVg6J=uj2^T2vjVeTJH_?XM%`Vuc;ADs1v+k?Gc*|(tO4f2AMXGF literal 0 HcmV?d00001 -- 2.39.5