]> git.mjollnir.org Git - moodle.git/commitdiff
The grades page now supports downloading of grade data! :-)
authormoodler <moodler>
Thu, 17 Oct 2002 10:34:11 +0000 (10:34 +0000)
committermoodler <moodler>
Thu, 17 Oct 2002 10:34:11 +0000 (10:34 +0000)
RELEASE.html
course/grades.php
lang/en/moodle.php
version.php

index fcdcec4eae6f037cce71770fcb6ef30c14c3d9eb..74d751553f28e7eeefd615df575d2ac1416e487e 100644 (file)
@@ -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>
 
index c6ef5f915e8c8b670de8c950c2ca2373f7223671..3acc4e9cc26f306542456666aa1b4cf52e4840a7 100644 (file)
@@ -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");
     $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"));
         $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
                                      "   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
         }
     } // 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);
+    }
+    
 ?>
index e5c29fce90c7d14029c9a0122793027c0c4c6358..755d894a06fcee8f42c887d101b7266e00b8b528 100644 (file)
@@ -106,6 +106,8 @@ $string['deletednot'] = "Could not delete \$a !";
 $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";
index d7e0504865b975dec999fad425404c0a5421050d..c6f0c0bbb0a9d72532a2e557513d6125c8c239b1 100644 (file)
@@ -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