Skip to content
Browse files

The grades page now supports downloading of grade data! :-)

  • Loading branch information...
1 parent 417e682 commit 952489e16c126a898559ca203611047b8d6052a7 moodler committed Oct 17, 2002
Showing with 138 additions and 40 deletions.
  1. +12 −7 RELEASE.html
  2. +122 −31 course/grades.php
  3. +2 −0 lang/en/moodle.php
  4. +2 −2 version.php
View
19 RELEASE.html
@@ -4,17 +4,22 @@
<UL><DL>
<DT> WYSIWYG Text editing!
-<DT> A WYSIWYG text editor has been added to many of the forms in Moodle. These are currently
+<DD> A WYSIWYG text editor has been added to many of the forms in Moodle. These are currently
only visible when using Microsoft Internet Explorer 5.5 or later - other browsers see the
normal forms exactly as before.
-<DT> Quiz module
-<DT> Finally, the most requested new module is here! This first version of the quiz module as
- it is now is still fairly basic (compared to what I'm aiming for), but I think you'll find
- it very usable for most needs already.
+<DT> Quiz module!
+<DD> Finally, the most requested new module is here! Multiple choice, short answer, true-false
+ quizzes with automatic marking, multiple attempts and many other features.
+
+<DT> Grade manager!
+<DD> A new tool has been added for teachers to see all grades for a course on one page.
+ You can also download/export grades as a tab-separated text file or an Excel
+ Spreadsheet. In future more features will be added to this page like sorting, manual
+ columns and calculations, but it's still pretty useful right now.
<DT> New smilies
-<DT> Many new smilies have been added, and are now also accessible using a GUI in the text editor.
+<DD> Many new smilies have been added, and are now also accessible using a GUI in the text editor.
<DT> Languages
<DD> German and Italian have been added! Many thanks to the translators (see the credits).
@@ -25,7 +30,7 @@
server.
<DT> Miscellaneous
-<DD> Many tweaks to the interface and small bugs fixed.
+<DD> Many small improvements have been made to the interface, and many small bugs have been fixed.
</DL></UL>
View
153 course/grades.php
@@ -3,8 +3,12 @@
require("../config.php");
require("lib.php");
+ require("$CFG->libdir/psxlsgen.php");
- require_variable($id); // course id
+
+
+ require_variable($id); // course id
+ optional_variable($download, ""); // to download data
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect");
@@ -22,13 +26,7 @@
$stractivityreport = get_string("activityreport");
-/// 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);
+/// Get a list of all students
if (!$students = get_course_students($course->id)) {
print_heading(get_string("nostudentsyet"));
@@ -40,11 +38,15 @@
$grades[$student->id] = array(); // Collect all grades in this array
$totals[$student->id] = array(); // Collect all totals in this array
}
- $columns = array(); // Accumulate column names in this array.
+ $columns = array(); // Accumulate column names in this array.
+ $columnhtml = array(); // Accumulate column html in this array.
+
- // Collect module data
+/// Collect modules data
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
+
+/// Search through all the modules, pulling out grade data
$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
@@ -71,10 +73,11 @@
" TITLE=\"$mod->modfullname\">".
"<IMG BORDER=0 VALIGN=absmiddle SRC=\"../mod/$mod->modname/icon.gif\" ".
"HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"></A>";
- $columns[] = "$image ".
+ $columnhtml[] = "$image ".
"<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
"$instance->name".
"</A>$maxgrade";
+ $columns[] = "$mod->modfullname: $instance->name - $modgrades->maxgrade";
foreach ($students as $student) {
$grades[$student->id][] = $modgrades->grades[$student->id]; // may be empty, that's ok
@@ -89,29 +92,117 @@
}
} // a new Moodle nesting record? ;-)
- $table->head = array ("", get_string("name"));
- $table->head = array_merge(array ("", get_string("name")), $columns, get_string("total"));
- $table->width = array(35, "");
- $table->align = array("LEFT", "LEFT");
- foreach ($columns as $column) {
- $table->width[] = "";
- $table->align[] = "CENTER";
- }
- $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", "<A TITLE=\"$stractivityreport\" HREF=\"user.php?id=$course->id&user=$student->id\">$student->firstname&nbsp;$student->lastname</A>");
- $total = array ($totals[$student->id]);
+/// OK, we have all the data, now present it to the user
-
- $table->data[] = array_merge($name, $gradelist, $total);
- }
+ if ($download == "xls") {
+
+ $myxls = new PhpSimpleXlsGen();
+ $myxls->totalcol = count($columns) + 5;
+
+/// Print names of all the fields
+
+ $myxls->ChangePos(0,0);
+ $myxls->InsertText(get_string("firstname"));
+ $myxls->InsertText(get_string("lastname"));
+ foreach ($columns as $column) {
+ $myxls->InsertText($column);
+ }
+ $myxls->InsertText(get_string("total"));
+
+
+/// Print all the lines of data.
+
+ $i = 0;
+ foreach ($grades as $studentid => $studentgrades) {
+ $i++;
+ $student = $students[$studentid];
+
+ $myxls->ChangePos($i,0);
+ $myxls->InsertText($student->firstname);
+ $myxls->InsertText($student->lastname);
+
+ foreach ($studentgrades as $grade) {
+ $myxls->InsertNumber($grade);
+ }
+ $myxls->InsertNumber($totals[$student->id]);
+ }
+
+ $myxls->SendFile("$course->shortname $strgrades");
+
+ exit;
- print_table($table);
- print_footer($course);
+ } else if ($download == "txt") {
+/// Print header to force download
+
+ header("Content-Type: application/download\n");
+ header("Content-Disposition: attachment; filename=\"$course->shortname $strgrades.txt\"");
+
+/// Print names of all the fields
+
+ echo get_string("firstname")."\t".get_string("lastname");
+ foreach ($columns as $column) {
+ echo "\t$column";
+ }
+ echo "\t".get_string("total")."\n";
+
+/// Print all the lines of data.
+
+ foreach ($grades as $studentid => $studentgrades) {
+ $student = $students[$studentid];
+ echo "$student->firstname\t$student->lastname";
+ foreach ($studentgrades as $grade) {
+ echo "\t$grade";
+ }
+ echo "\t".$totals[$student->id];
+ echo "\n";
+ }
+
+ exit;
+
+
+ } else { // Just print the web page
+
+ print_header("$course->shortname: $strgrades", "$course->fullname",
+ "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
+ -> $strgrades");
+
+ print_heading($strgrades);
+
+ $table->head = array_merge(array ("", get_string("name")), $columnhtml, get_string("total"));
+ $table->width = array(35, "");
+ $table->align = array("LEFT", "LEFT");
+ foreach ($columns as $column) {
+ $table->width[] = "";
+ $table->align[] = "CENTER";
+ }
+ $table->width[] = "";
+ $table->align[] = "CENTER";
+
+ foreach ($grades as $studentid => $studentgrades) {
+ $student = $students[$studentid];
+ $picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
+ $name = array ("$picture", "<A TITLE=\"$stractivityreport\" HREF=\"user.php?id=$course->id&user=$student->id\">$student->firstname&nbsp;$student->lastname</A>");
+ $total = array ($totals[$student->id]);
+
+ $table->data[] = array_merge($name, $studentgrades, $total);
+ }
+
+ print_table($table);
+
+ echo "<TABLE BORDER=0 ALIGN=CENTER><TR>";
+ echo "<TD>";
+ $options["id"] = "$course->id";
+ $options["download"] = "xls";
+ print_single_button("grades.php", $options, get_string("downloadexcel"));
+ echo "<TD>";
+ $options["download"] = "txt";
+ print_single_button("grades.php", $options, get_string("downloadtext"));
+ echo "</TABLE>";
+
+ print_footer($course);
+ }
+
?>
View
2 lang/en/moodle.php
@@ -106,6 +106,8 @@
$string['deletingcourse'] = "Deleting \$a";
$string['description'] = "Description";
$string['doyouagree'] = "Have you read these conditions and understood them?";
+$string['downloadexcel'] = "Download in Excel format";
+$string['downloadtext'] = "Download in text format";
$string['edit'] = "Edit \$a";
$string['editcoursesettings'] = "Edit course settings";
$string['editinga'] = "Editing a \$a";
View
4 version.php
@@ -5,7 +5,7 @@
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2002101500; // The current version is a date (YYYYMMDDXX)
+$version = 2002101700; // The current version is a date (YYYYMMDDXX)
-$release = "1.0.6 dev"; // User-friendly version number
+$release = "1.0.6 dev 2"; // User-friendly version number

0 comments on commit 952489e

Please sign in to comment.
Something went wrong with that request. Please try again.