New translationd added.
[moodle.git] / course / grade.php
blobb1bf0ed5f198a100b73b9270a6f77ada5b5d5fe7
1 <?PHP // $Id$
2 // Displays all grades for a student in a course
4 require_once("../config.php");
5 require_once("lib.php");
7 require_variable($id); // course id
9 if (! $course = get_record("course", "id", $id)) {
10 error("Course ID was incorrect");
13 require_login($course->id);
15 $strgrades = get_string("grades");
16 $strgrade = get_string("grade");
17 $strmax = get_string("maximumshort");
18 $stractivityreport = get_string("activityreport");
21 /// Get a list of all students
23 $columnhtml = array(); // Accumulate column html in this array.
24 $grades = array(); // Collect all grades in this array
25 $maxgrades = array(); // Collect all max grades in this array
26 $totalgrade = 0;
27 $totalmaxgrade = 0;
30 /// Collect modules data
31 get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
34 /// Search through all the modules, pulling out grade data
35 $sections = get_all_sections($course->id); // Sort everything the same as the course
36 for ($i=0; $i<=$course->numsections; $i++) {
37 if (isset($sections[$i])) { // should always be true
38 $section = $sections[$i];
39 if (!empty($section->sequence)) {
40 $sectionmods = explode(",", $section->sequence);
41 foreach ($sectionmods as $sectionmod) {
42 $mod = $mods[$sectionmod];
43 if ($mod->visible) {
44 $instance = get_record("$mod->modname", "id", "$mod->instance");
45 $libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
46 if (file_exists($libfile)) {
47 require_once($libfile);
48 $gradefunction = $mod->modname."_grades";
49 if (function_exists($gradefunction)) { // Skip modules without grade function
50 if ($modgrades = $gradefunction($mod->instance)) {
52 $image = "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
53 " TITLE=\"$mod->modfullname\">".
54 "<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ".
55 "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>";
56 $columnhtml[] = "$image ".
57 "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
58 "$instance->name".
59 "</A>";
61 if (empty($modgrades->grades[$USER->id])) {
62 $grades[] = "";
63 } else {
64 $grades[] = $modgrades->grades[$USER->id];
65 $totalgrade += (float)$modgrades->grades[$USER->id];
68 if (empty($modgrades->maxgrade)) {
69 $maxgrades[] = "";
70 } else {
71 $maxgrades[] = $modgrades->maxgrade;
72 $totalmaxgrade += $modgrades->maxgrade;
84 /// OK, we have all the data, now present it to the user
86 print_header("$course->shortname: $strgrades", "$course->fullname",
87 "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
88 -> $strgrades");
90 print_heading($strgrades);
92 $table->head = array( get_string("activity"), get_string("maximumgrade"), get_string("grade"));
93 $table->align = array("LEFT", "RIGHT", "RIGHT");
95 foreach ($grades as $key => $grade) {
96 $table->data[] = array($columnhtml[$key], $maxgrades[$key], $grade);
99 $table->data[] = array(get_string("total"), $totalmaxgrade, $totalgrade);
101 print_table($table);
103 print_continue("view.php?id=$course->id");
105 print_footer($course);