Permalink
Browse files

MDL-34337 scorm: Updating export of basic reports as csv, to use new …

…csv exporter class
  • Loading branch information...
1 parent 87e9331 commit 4d26f274c494d12e5620360163ff797b44da91c4 @ankitagarwal ankitagarwal committed Jul 30, 2012
Showing with 7 additions and 10 deletions.
  1. +7 −10 mod/scorm/report/basic/report.php
@@ -22,6 +22,7 @@
*/
defined('MOODLE_INTERNAL') || die();
+require_once($CFG->libdir . '/csvlib.class.php');
class scorm_basic_report extends scorm_default_report {
/**
@@ -260,13 +261,9 @@ function display($scorm, $cm, $course, $download) {
}
$rownum=1;
} else if ($download=='CSV') {
- $filename .= ".txt";
- header("Content-Type: application/download\n");
- header("Content-Disposition: attachment; filename=\"$filename\"");
- header("Expires: 0");
- header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
- header("Pragma: public");
- echo implode("\t", $headers)." \n";
+ $csvexport = new csv_export_writer("tab");
+ $csvexport->set_filename($filename, ".txt");
+ $csvexport->add_data($headers);
}
$params = array();
list($usql, $params) = $DB->get_in_or_equal($allowedlist, SQL_PARAMS_NAMED);
@@ -474,9 +471,8 @@ function display($scorm, $cm, $course, $download) {
$colnum++;
}
$rownum++;
- } else if ($download=='CSV') {
- $text = implode("\t", $row);
- echo $text." \n";
+ } else if ($download == 'CSV') {
+ $csvexport->add_data($row);
}
}
if (!$download) {
@@ -535,6 +531,7 @@ function display($scorm, $cm, $course, $download) {
$workbook->close();
exit;
} else if ($download == 'CSV') {
+ $csvexport->download_file();
exit;
}
} else {

0 comments on commit 4d26f27

Please sign in to comment.