Fixing gradebook PDF export see #7153

1.9.x
Julio Montoya 11 years ago
parent 49b8b167a7
commit 86cab44488
  1. 2
      main/gradebook/gradebook_flatview.php
  2. 12
      main/gradebook/lib/flatview_data_generator.class.php
  3. 19
      main/gradebook/lib/gradebook_functions.inc.php

@ -124,7 +124,7 @@ if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
$params['export_pdf'] = true;
if ($cat[0]->is_locked() == true || api_is_platform_admin()) {
Display :: set_header(null, false, false);
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params);
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params, $mainCourseCategory[0]);
}
}

@ -28,14 +28,19 @@ class FlatViewDataGenerator
/**
* Constructor
*/
public function FlatViewDataGenerator($users = array(), $evals = array(), $links = array(), $params = array(), $mainCategory = null)
{
public function FlatViewDataGenerator(
$users = array(),
$evals = array(),
$links = array(),
$params = array(),
$mainCourseCategory = null
) {
$this->users = (isset($users) ? $users : array());
$this->evals = (isset($evals) ? $evals : array());
$this->links = (isset($links) ? $links : array());
$this->evals_links = array_merge($this->evals, $this->links);
$this->params = $params;
$this->mainCourseCategory = $mainCategory;
$this->mainCourseCategory = $mainCourseCategory;
}
/**
@ -116,6 +121,7 @@ class FlatViewDataGenerator
$mainCategoryId = null;
$mainCourseCategory = $this->getMainCourseCategory();
if (!empty($mainCourseCategory)) {
$mainCategoryId = $mainCourseCategory->get_id();
}

@ -435,15 +435,19 @@ function get_course_id_by_link_id($id_link)
return $array['id'];
}
/**
* @param $type
* @return string
*/
function get_table_type_course($type)
{
global $table_evaluated;
return Database::get_course_table($table_evaluated[$type][0]);
}
function get_printable_data($cat, $users, $alleval, $alllinks, $params)
function get_printable_data($cat, $users, $alleval, $alllinks, $params, $mainCourseCategory = null)
{
$datagen = new FlatViewDataGenerator($users, $alleval, $alllinks, $params);
$datagen = new FlatViewDataGenerator($users, $alleval, $alllinks, $params, $mainCourseCategory);
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$offset = intval($offset);
@ -453,13 +457,16 @@ function get_printable_data($cat, $users, $alleval, $alllinks, $params)
$count = (($offset + 10) > $datagen->get_total_items_count()) ? ($datagen->get_total_items_count() - $offset) : LIMIT;
$header_names = $datagen->get_header_names($offset, $count, true);
$data_array = $datagen->get_data(FlatViewDataGenerator :: FVDG_SORT_LASTNAME, 0, null, $offset, $count, true, true);
$data_array = $datagen->get_data(
FlatViewDataGenerator :: FVDG_SORT_LASTNAME, 0, null, $offset, $count, true, true
);
$newarray = array();
foreach ($data_array as $data) {
$newarray[] = array_slice($data, 1);
}
$return = array($header_names, $newarray);
return $return;
}
@ -751,11 +758,11 @@ function load_gradebook_select_in_tool($form)
/**
* PDF report creation
*/
function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array())
function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array(), $mainCourseCategory = null)
{
global $flatviewtable;
//Getting data
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks, $params);
// Getting data
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks, $params, $mainCourseCategory);
// HTML report creation first
$course_code = trim($cat[0]->get_course_code());

Loading…
Cancel
Save