Fixes bug MDL-9753, "THEME->larrow, rarrow don't work in stock IE6"
[moodle-pu.git] / grade / export / ods / grade_export_ods.php
blobcb21fd078344ab1262377aab8e6cb09b9ab7c9db
1 <?php
2 ///////////////////////////////////////////////////////////////////////////
3 // //
4 // NOTICE OF COPYRIGHT //
5 // //
6 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
7 // http://moodle.com //
8 // //
9 // Copyright (C) 2001-2003 Martin Dougiamas http://dougiamas.com //
10 // //
11 // This program is free software; you can redistribute it and/or modify //
12 // it under the terms of the GNU General Public License as published by //
13 // the Free Software Foundation; either version 2 of the License, or //
14 // (at your option) any later version. //
15 // //
16 // This program is distributed in the hope that it will be useful, //
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
19 // GNU General Public License for more details: //
20 // //
21 // http://www.gnu.org/copyleft/gpl.html //
22 // //
23 ///////////////////////////////////////////////////////////////////////////
25 require_once($CFG->dirroot.'/grade/export/lib.php');
27 class grade_export_ods extends grade_export {
29 var $format = 'ods'; // export format
31 /**
32 * To be implemented by child classes
34 function print_grades() {
36 require_once($CFG->dirroot.'/lib/odslib.class.php');
38 /// Calculate file name
39 $downloadfilename = clean_filename("$course->shortname $this->strgrades.ods");
40 /// Creating a workbook
41 $workbook = new MoodleODSWorkbook("-");
42 /// Sending HTTP headers
43 $workbook->send($downloadfilename);
44 /// Adding the worksheet
45 $myxls =& $workbook->add_worksheet($this->strgrades);
47 /// Print names of all the fields
48 $myxls->write_string(0,0,get_string("firstname"));
49 $myxls->write_string(0,1,get_string("lastname"));
50 $myxls->write_string(0,2,get_string("idnumber"));
51 $myxls->write_string(0,3,get_string("institution"));
52 $myxls->write_string(0,4,get_string("department"));
53 $myxls->write_string(0,5,get_string("email"));
54 $pos=6;
55 foreach ($this->columns as $column) {
56 $myxls->write_string(0,$pos++,strip_tags($column));
58 $myxls->write_string(0,$pos,get_string("total"));
60 /// Print all the lines of data.
61 $i = 0;
62 if (!empty($this->grades)) {
63 foreach ($this->grades as $studentid => $studentgrades) {
64 $i++;
65 $student = $students[$studentid];
66 if (empty($this->totals[$student->id])) {
67 $this->totals[$student->id] = '';
70 $myxls->write_string($i,0,$student->firstname);
71 $myxls->write_string($i,1,$student->lastname);
72 $myxls->write_string($i,2,$student->idnumber);
73 $myxls->write_string($i,3,$student->institution);
74 $myxls->write_string($i,4,$student->department);
75 $myxls->write_string($i,5,$student->email);
76 $j=6;
77 foreach ($studentgrades as $grade) {
78 if (is_numeric($grade)) {
79 $myxls->write_number($i,$j++,strip_tags($grade));
81 else {
82 $myxls->write_string($i,$j++,strip_tags($grade));
85 $myxls->write_number($i,$j,$this->totals[$student->id]);
89 /// Close the workbook
90 $workbook->close();
92 exit;