diff --git a/main/gradebook/gradebook_flatview.php b/main/gradebook/gradebook_flatview.php index 946dad7db0..2dfd3b9b50 100644 --- a/main/gradebook/gradebook_flatview.php +++ b/main/gradebook/gradebook_flatview.php @@ -9,10 +9,8 @@ */ $language_file = 'gradebook'; - require_once '../inc/global.inc.php'; -require_once 'lib/be.inc.php'; -require_once 'lib/gradebook_functions.inc.php'; +require_once 'lib/be.inc.php'; require_once 'lib/fe/dataform.class.php'; require_once 'lib/fe/userform.class.php'; require_once 'lib/flatview_data_generator.class.php'; @@ -23,7 +21,6 @@ require_once 'lib/scoredisplay.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php'; require_once api_get_path(LIBRARY_PATH).'pdf.lib.php'; -if (!class_exists('HTML_Table')) { require_once api_get_path(LIBRARY_PATH).'pear/HTML/Table.php'; } api_block_anonymous_users(); block_students(); @@ -41,7 +38,6 @@ if (($showlink == '0') && ($showeval == '0')) { $showlink = '1'; $showeval = '1'; } - $cat = Category::load($_REQUEST['selectcat']); if (isset($_GET['userid'])) { @@ -96,8 +92,7 @@ if (!empty($keyword)) { $offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; $flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams); -if (isset ($_GET['exportpdf'])) { - +if (isset($_GET['exportpdf'])) { $interbreadcrumb[] = array ( 'url' => api_get_self().'?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('FlatView') @@ -258,12 +253,15 @@ if (isset ($_GET['exportpdf'])) { } if (isset ($_GET['print'])) { - $printable_data = get_printable_data ($users,$alleval, $alllinks); + $printable_data = get_printable_data ($cat[0], $users,$alleval, $alllinks); echo print_table($printable_data[1],$printable_data[0], get_lang('FlatView'), $cat[0]->get_name()); exit; } -if (!empty($_POST['export_report']) && $_POST['export_report'] == 'export_report') { + + + +if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report') { if (api_is_platform_admin() || api_is_course_admin() || api_is_course_coach()) { $user_id = null; @@ -275,12 +273,12 @@ if (!empty($_POST['export_report']) && $_POST['export_report'] == 'export_report } require_once 'gradebook_result.class.php'; - $printable_data = get_printable_data($users, $alleval, $alllinks); - switch($_POST['export_format']) { + $printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks); + + switch($_GET['export_format']) { case 'xls': $export = new GradeBookResult(); $export->exportCompleteReportXLS($printable_data); - exit; break; case 'doc': $export = new GradeBookResult(); @@ -322,8 +320,7 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') { DisplayGradebook :: display_header_reduce_flatview($cat[0], $showeval, $showlink, $simple_search_form); // main graph - $flatviewtable->display(); - + $flatviewtable->display(); // @todo this needs a fix //$image_file = $flatviewtable->display_graph(); //@todo load images with jquery diff --git a/main/gradebook/gradebook_result.class.php b/main/gradebook/gradebook_result.class.php index ea5a29b0ac..a8735a9622 100644 --- a/main/gradebook/gradebook_result.class.php +++ b/main/gradebook/gradebook_result.class.php @@ -239,43 +239,40 @@ class GradeBookResult * Exports the complete report as an XLS file * @return boolean False on error */ - public function exportCompleteReportXLS($data) { - $filename = 'gradebook_results_user_'.gmdate('YmdGis').'.xls'; - //build the results - require_once api_get_path(LIBRARY_PATH).'pear/Spreadsheet_Excel_Writer/Writer.php'; + public function exportCompleteReportXLS($data) { + $filename = 'gradebook-results-'.date('Y-m-d-h:i:s').'.xls'; + include api_get_path(LIBRARY_PATH).'pear/Spreadsheet_Excel_Writer/Writer.php'; $workbook = new Spreadsheet_Excel_Writer(); - $workbook->setVersion(8); // BIFF8 - $workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH)); - + $workbook->setVersion(8); // BIFF8 + $workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH)); $workbook->send($filename); - $worksheet =& $workbook->addWorksheet('Report '.gmdate('YmdGis')); - $worksheet->setInputEncoding(api_get_system_encoding()); + + $worksheet =& $workbook->addWorksheet('Report'); + $worksheet->setInputEncoding(api_get_system_encoding()); + $line = 0; $column = 0; //skip the first column (row titles) + //headers - foreach ($data[0] as $header_col) { - $worksheet->write($line,$column,$header_col); + foreach ($data[0] as $header_col) { + $worksheet->write($line, $column, $header_col); $column++; } - //$worksheet->write($line,$column,get_lang('Total')); - //$column++; - $line++; + $line++; $cant_students = count($data[1]); - //print_r($data); exit(); - + for ($i=0;$i<$cant_students;$i++) { $column = 0; foreach ($data[1][$i] as $col_name) { - $worksheet->write($line,$column,strip_tags($col_name)); + $worksheet->write($line,$column, html_entity_decode(strip_tags($col_name))); $column++; - } $line++; } - //output the results - $workbook->close(); - return true; + $workbook->close(); + exit; + } /** * Exports the complete report as a DOCX file diff --git a/main/gradebook/lib/be.inc.php b/main/gradebook/lib/be.inc.php old mode 100755 new mode 100644 index 1a6dcc125c..e845612307 --- a/main/gradebook/lib/be.inc.php +++ b/main/gradebook/lib/be.inc.php @@ -8,7 +8,6 @@ /** * Code */ -require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; define ('LIMIT', 1000); require_once 'be/gradebookitem.class.php'; require_once 'be/category.class.php'; diff --git a/main/gradebook/lib/be/studentpublicationlink.class.php b/main/gradebook/lib/be/studentpublicationlink.class.php index f2d0ecfaee..ccfe991658 100644 --- a/main/gradebook/lib/be/studentpublicationlink.class.php +++ b/main/gradebook/lib/be/studentpublicationlink.class.php @@ -1,4 +1,4 @@ - get_course_code()); //$url = api_get_path(WEB_PATH).'main/gradebook/open_document.php?file='.$course_info['directory'].'/'.$fileurl[0]; //return $url; - return null; - return null; + return null; } else { return null; } diff --git a/main/gradebook/lib/fe/dataform.class.php b/main/gradebook/lib/fe/dataform.class.php old mode 100755 new mode 100644 index eb52cfb89f..89bfbc482f --- a/main/gradebook/lib/fe/dataform.class.php +++ b/main/gradebook/lib/fe/dataform.class.php @@ -11,7 +11,6 @@ require_once dirname(__FILE__).'/../../../inc/global.inc.php'; require_once dirname(__FILE__).'/../be.inc.php'; require_once dirname(__FILE__).'/../gradebook_functions.inc.php'; require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php'; -require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php'; /** * Extends formvalidator with import and export forms diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php index 9f5f53322f..62709b0178 100644 --- a/main/gradebook/lib/fe/displaygradebook.php +++ b/main/gradebook/lib/fe/displaygradebook.php @@ -167,27 +167,9 @@ class DisplayGradebook } else { $show=''; } - echo '
'; - - echo ''; - echo ''; - - $header .= ''.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'','32').''; - $header .= ''.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'','32').''; - $header .= ''.Display::return_icon('export_doc.png', get_lang('ExportAsDOC'),'','32').''; + $header .= ''.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'','32').''; + $header .= ''.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'','32').''; + $header .= ''.Display::return_icon('export_doc.png', get_lang('ExportAsDOC'),'','32').''; $header .= ''.Display::return_icon('printer.png', get_lang('Print'),'','32').''; $header .= ''.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'','32').''; diff --git a/main/gradebook/lib/fe/flatviewtable.class.php b/main/gradebook/lib/fe/flatviewtable.class.php index eaa952e298..48af4d8bf0 100644 --- a/main/gradebook/lib/fe/flatviewtable.class.php +++ b/main/gradebook/lib/fe/flatviewtable.class.php @@ -493,9 +493,7 @@ class FlatViewTable extends SortableTable $column++; } - //$this->set_header($column++, get_lang('Total')); - - + //$this->set_header($column++, get_lang('Total')); $data_array = $this->datagen->get_data($users_sorting, $from, $this->per_page, $this->offset, $selectlimit); $table_data = array(); diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index b6bc432a93..75a091c20d 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -5125,8 +5125,7 @@ function api_is_global_platform_admin() { * @author Julio Montoya */ function api_protect_global_admin_script() { - if (!api_is_global_platform_admin()) { - include api_get_path(INCLUDE_PATH).'header.inc.php'; + if (!api_is_global_platform_admin()) { api_not_allowed(); return false; }