Improve export PDF in gradebook BT#911

skala
Carlos Vargas 15 years ago
parent 81aa5e178e
commit c8b883cee6
  1. 18
      main/gradebook/gradebook_view_result.php
  2. 2
      main/gradebook/lib/fe/dataform.class.php
  3. 32
      main/gradebook/lib/fe/exportgradebook.php
  4. 2
      main/work/work.lib.php

@ -198,12 +198,12 @@ if ($export_result_form->validate()) {
// set headers pdf
$h1 = array(get_lang('Teacher'),$_user['firstName'].' '.$_user['lastName']);
$h2 = array(get_lang('QualificationNumeric'),$eval[0]->get_max());
$h2 = array(get_lang('Score'),$eval[0]->get_max());
$h3 = array(get_lang('Course'),$_course['name']);
$h4 = array(get_lang('Weight'),$eval[0]->get_weight());
$h5 = array(get_lang('Session'),api_get_session_name(api_get_session_id()));
$date = date('Y-m-d H:i', time());
$h6 = array(get_lang('Date'),api_convert_and_format_date($date, DATE_TIME_FORMAT_LONG));
$date = date('d-m-Y', time());
$h6 = array(get_lang('DateTime'),api_convert_and_format_date($date, DATE_FORMAT_SHORT));
$header_pdf = array($h1, $h2, $h3, $h4, $h5, $h6);
// set footer pdf
@ -217,7 +217,7 @@ if ($export_result_form->validate()) {
// set headers data table
$head_ape_name = '';
if (api_is_western_name_order()) {
if (!api_is_western_name_order()) {
$head_ape_name = get_lang('FirstName').' '.get_lang('LastName');
} else {
$head_ape_name = get_lang('LastName').' '.get_lang('FirstName');
@ -229,11 +229,11 @@ if ($export_result_form->validate()) {
}
$head_table = array(
array(get_lang('Item'),10),
array(get_lang('Code'),10),
array(get_lang('Item'),5),
array(get_lang('Code'),15),
array($head_ape_name, 50),
array(get_lang('Score'),10),
array($head_display_score,20)
array(get_lang('Score'),15),
array($head_display_score,15)
);
// get data table
@ -248,7 +248,7 @@ if ($export_result_form->validate()) {
$result = array();
$user_info = api_get_user_info($data['id']);
$result[] = $user_info['username'];
if (api_is_western_name_order()) {
if (!api_is_western_name_order()) {
$result[] = $user_info['firstname'].' '.$user_info['lastname'];
} else {
$result[] = $user_info['lastname'].' '.$user_info['firstname'];

@ -61,7 +61,7 @@ class DataForm extends FormValidator {
$this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
$this->addElement('radio', 'file_type', null, 'PDF (Portable Document Format)', 'pdf');
$this->addElement('submit', 'submit', get_lang('Ok'));
$this->addElement('style_submit_button', 'submit', get_lang('Export'), 'class="upload"');
$this->setDefaults(array (
'file_type' => 'csv'
));

@ -92,21 +92,25 @@ function export_pdf_with_html($headers_table, $data_table, $headers_pdf, $footer
require_once api_get_path(LIBRARY_PATH).'mpdf/mpdf.php';
$mpdf = new mPDF('UTF-8', 'A4', '', '', 32, 25, 70, 40, 16, 13, 'P');
$mpdf = new mPDF('UTF-8', 'A4', '', '', 18, 15, 70, 35, 16, 13, 'P');
$mpdf->useOnlyCoreFonts = true;
$mpdf->mirrorMargins = 0; // Use different Odd/Even headers and footers and mirror margins
if (is_array($headers_pdf)) {
// preparing headers pdf
$header = '<table width="100%" cellspacing="2" cellpadding="10" border="0">
<tr><td width="100%" style="text-align: center;" class="title" colspan="2"><h1>'.get_lang('EvaluationName').' : '.$title_pdf.'</h1></td></tr>
<tr><td width="50%">'.$headers_pdf[0][0].' : '.$headers_pdf[0][1].'</td>
<td width="50%">'.$headers_pdf[1][0].' : '.$headers_pdf[1][1].'</td></tr>
<tr><td width="50%">'.$headers_pdf[2][0].' : '.$headers_pdf[2][1].'</td>
<td width="50%" rowspan="1">'.$headers_pdf[3][0].' : '.$headers_pdf[3][1].'</td></tr>
<tr><td width="50%">'.$headers_pdf[4][0].' : '.$headers_pdf[4][1].'</td>
<td width="50%" rowspan="1">'.$headers_pdf[5][0].' : '.$headers_pdf[5][1].'</td></tr>
</table>';
$header = '<table width="100%" cellspacing="2" cellpadding="10" border="0" class="strong">
<tr><td width="100%" style="text-align: left;" class="title" colspan="4"><h3>'.api_get_setting('Institution').'</h3></td></tr>
<tr><td width="100%" style="text-align: center;" class="title" colspan="4"><h1>'.$title_pdf.'</h1></td></tr>
<tr><td><strong>'.$headers_pdf[0][0].'</strong> </td><td> <strong>'.$headers_pdf[0][1].'</strong></td>
<td><strong>'.$headers_pdf[1][0].'</strong> </td><td> <strong>'.$headers_pdf[1][1].'</strong></td>
</tr>
<tr><td><strong>'.$headers_pdf[2][0].'</strong> </td><td> <strong>'.$headers_pdf[2][1].'</strong></td>
<td><strong>'.$headers_pdf[3][0].' </strong></td><td> <strong>'.$headers_pdf[3][1].'</strong></td>
</tr>
<tr><td><strong>'.$headers_pdf[4][0].'</strong></td><td> <strong>'.$headers_pdf[4][1].'</strong></td>
<td><strong>'.$headers_pdf[5][0].'</strong> </td><td> <strong>'.$headers_pdf[5][1].'</strong></td>
</tr>
</table>';
}
// preparing footer pdf
@ -128,7 +132,7 @@ function export_pdf_with_html($headers_table, $data_table, $headers_pdf, $footer
$css = '';
}
$items_per_page = 32;
$items_per_page = 30;
$count_pages = ceil(count($data_table) / $items_per_page);
for ($x = 0; $x<$count_pages; $x++) {
$content_table .= '<table width="100%" border="1" style="border-collapse:collapse">';
@ -138,8 +142,8 @@ function export_pdf_with_html($headers_table, $data_table, $headers_pdf, $footer
if (is_array($headers_table)) {
foreach ($headers_table as $head_table) {
if (!empty($head_table[0])) {
$width = (!empty($head_table[1])?' style = "width : '.$head_table[1].'%" ':'');
$content_table .= '<th width="20px">'.$head_table[0].'</th>';
$width = (!empty($head_table[1])?$head_table[1].'%':'');
$content_table .= '<th width="'.$width.'">'.$head_table[0].'</th>';
$i++;
}
}
@ -156,7 +160,7 @@ function export_pdf_with_html($headers_table, $data_table, $headers_pdf, $footer
$content_table .= '<td>'.($item<10?'0'.$item:$item).'</td>';
foreach ($data as $content) {
if (!empty($content)) {
$content_table .= '<td>'.$content.'</td>';
$content_table .= '<td style="padding:4px" >'.$content.'</td>';
}
}
$content_table .= '</tr>';

@ -1461,8 +1461,8 @@ function get_list_users_without_publication($task_id) {
*/
function display_list_users_without_publication($task_id) {
global $origin;
$table_header[] = array(get_lang('FirstName'), true);
$table_header[] = array(get_lang('LastName'), true);
$table_header[] = array(get_lang('FirstName'), true);
$table_header[] = array(get_lang('Email'), true);
// table_data
$table_data = get_list_users_without_publication($task_id);

Loading…
Cancel
Save