Add report to pdf export + add graphs per category see BT#9428

1.10.x
Julio Montoya 11 years ago
parent 85951db713
commit dafe35a158
  1. 60
      main/gradebook/index.php
  2. 3
      main/gradebook/lib/be/category.class.php
  3. 92
      main/gradebook/lib/fe/gradebooktable.class.php
  4. 32
      main/gradebook/personal_stats.php
  5. 1
      main/inc/lib/pdf.lib.php
  6. 8
      main/template/default/export/table_pdf.tpl

@ -446,6 +446,10 @@ switch ($action) {
$confirmation_message = get_lang('EvaluationHasBeenUnLocked');
}
break;
case 'export_table':
//table will be export below
ob_start();
break;
}
//actions on the sortabletable
@ -752,6 +756,8 @@ $no_qualification = false;
// Show certificate link.
$certificate = array();
echo '<div class="actions" align="right">';
if ($category != '0') {
$cat = new Category();
$category_id = intval($_GET['selectcat']);
@ -766,14 +772,24 @@ if ($category != '0') {
$stud_id
);
if (!empty($certificate)) {
echo '<div class="actions" align="right">';
echo $certificate['pdf_link'];
echo '</div>';
echo Display::url(
get_lang('CertificateToPdf'),
$certificate['pdf_url'],
['class' => 'btn btn-default']
);
}
}
}
}
echo Display::url(
get_lang('ReportToPdf'),
api_get_self()."?".api_get_self()."&action=export_table",
['class' => 'btn btn-default']
);
echo '</div>';
if (api_is_allowed_to_edit(null, true)) {
// Tool introduction
Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction'));
@ -893,9 +909,41 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
Display::display_normal_message(get_lang('GradeModel').': '.$grade_models[$grade_model_id]['name']);
}
}
$gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, $addparams);
$gradebooktable->display();
echo $gradebooktable->getGraph();
$exportToPdf = false;
if ($action == 'export_table') {
$exportToPdf = true;
}
$gradebooktable = new GradebookTable(
$cat,
$allcat,
$alleval,
$alllink,
$addparams,
$exportToPdf
);
$table = $gradebooktable->return_table();
$graph = $gradebooktable->getGraph();
if ($action == 'export_table') {
ob_clean();
$params = array(
//'filename' => get_lang('FlatView') . '_' . api_get_utc_datetime(),
'pdf_title' => get_lang('Report'),
'course_code' => api_get_course_id(),
'session_info' => api_get_session_info(api_get_session_id()),
'add_signatures' => false,
'student_info' => api_get_user_info()
);
$pdf = new PDF('A4', $params['orientation'], $params);
$pdf->html_to_pdf_with_template($table.$graph);
} else {
echo $table;
echo $graph;
}
}
}
}

@ -1878,7 +1878,8 @@ class Category implements GradebookItem
$html = array(
'certificate_link' => $certificates,
'pdf_link' => $exportToPDF
'pdf_link' => $exportToPDF,
'pdf_url' => "$url&action=export"
);
if (api_get_setting('allow_skills_tool') == 'true') {

@ -28,9 +28,9 @@ class GradebookTable extends SortableTable
* @param array $links
* @param null $addparams
*/
public function __construct($currentcat, $cats = array(), $evals = array(), $links = array(), $addparams = null)
public function __construct($currentcat, $cats = array(), $evals = array(), $links = array(), $addparams = null, $exportToPdf = false)
{
parent::__construct('gradebooklist', null, null, api_is_allowed_to_edit() ? 1 : 0);
parent::__construct('gradebooklist', null, null, api_is_allowed_to_edit() ? 1 : 0, 20, 'ASC', 'gradebook_list');
$this->evals_links = array_merge($evals, $links);
$this->currentcat = $currentcat;
$this->cats = $cats;
@ -42,12 +42,17 @@ class GradebookTable extends SortableTable
$column= 0;
if (api_is_allowed_to_edit(null, true)) {
$this->set_header($column++, '', '', 'width="25px"');
if ($this->exportToPdf == false) {
$this->set_header($column++, '', '', 'width="25px"');
}
}
$this->set_header($column++, get_lang('Type'), '', 'width="35px"');
$this->set_header($column++, get_lang('Name'), false);
$this->set_header($column++, get_lang('Description'), false);
if ($this->exportToPdf == false) {
$this->set_header($column++, get_lang('Description'), false);
}
if (api_is_allowed_to_edit(null, true)) {
$this->set_header(
@ -64,7 +69,9 @@ class GradebookTable extends SortableTable
$this->set_header($column++, get_lang('Average'), false);
if (!empty($cats)) {
$this->set_header($column++, get_lang('Actions'), false);
if ($this->exportToPdf == false) {
$this->set_header($column++, get_lang('Actions'), false);
}
}
}
@ -204,13 +211,14 @@ class GradebookTable extends SortableTable
// Id
if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_id_column($item);
if ($this->exportToPdf == false) {
$row[] = $this->build_id_column($item);
}
}
// Type.
$row[] = $this->build_type_column($item);
$this->dataForGraph['categories'][] = $item->get_name();
// Name.
if (get_class($item) == 'Category') {
@ -221,11 +229,15 @@ class GradebookTable extends SortableTable
$main_categories[$item->get_id()]['name'] = $this->build_name_link($item);
}
$this->dataForGraph['categories'][] = $item->get_name();
$main_categories[$item->get_id()]['weight']= $item->get_weight();
$total_categories_weight += $item->get_weight();
// Description.
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
if ($this->exportToPdf == false) {
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
}
// Weight.
$weight = $scoredisplay->display_score(
@ -285,7 +297,7 @@ class GradebookTable extends SortableTable
$totalResult = [
$totalResult[0] + $data['result_score_weight'][0],
$totalResult[1] + $data['result_score_weight'][1],
$totalResult[1] + $data['result_score_weight'][1]
];
$totalBest = [
@ -311,13 +323,17 @@ class GradebookTable extends SortableTable
$row[] = $average;
if (get_class($item) == 'Category') {
$row[] = $this->build_edit_column($item);
if ($this->exportToPdf == false) {
$row[] = $this->build_edit_column($item);
}
}
} else {
$row[] = $scoreToDisplay;
if (!empty($this->cats)) {
$row[] = $this->build_edit_column($item);
if ($this->exportToPdf == false) {
$row[] = $this->build_edit_column($item);
}
}
}
}
@ -358,20 +374,24 @@ class GradebookTable extends SortableTable
}
if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_id_column($item);
if ($this->exportToPdf == false) {
$row[] = $this->build_id_column($item);
}
}
// Type
$row[] = $this->build_type_column($item, array('style' => 'padding-left:5px'));
// Name.
$row[] = $invisibility_span_open."&nbsp;&nbsp;&nbsp; ".$this->build_name_link($item) . $invisibility_span_close;
// Description.
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
if ($this->exportToPdf == false) {
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
}
$weight = $data[3];
$total_weight += $weight;
// Weight
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
if (api_is_allowed_to_edit(null, true)) {
@ -387,7 +407,9 @@ class GradebookTable extends SortableTable
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
if ($show_message === false) {
$row[] = $this->build_edit_column($item);
if ($this->exportToPdf) {
$row[] = $this->build_edit_column($item);
}
}
} else {
// Students get the results and certificates columns
@ -418,7 +440,9 @@ class GradebookTable extends SortableTable
}
if (!empty($cats)) {
$row[] = null;
if ($this->exportToPdf == false) {
$row[] = null;
}
}
}
$row['child_of'] = $parent_id;
@ -518,16 +542,28 @@ class GradebookTable extends SortableTable
SCORE_DIV
);
$row = array(
null,
'<h3>' . get_lang('Total') . '</h3>',
null,
$main_weight,
$totalResult,
$totalRanking,
$totalBest,
$totalAverage,
);
if ($this->exportToPdf) {
$row = array(
null,
'<h3>' . get_lang('Total') . '</h3>',
$main_weight,
$totalResult,
$totalRanking,
$totalBest,
$totalAverage,
);
} else {
$row = array(
null,
'<h3>' . get_lang('Total') . '</h3>',
null,
$main_weight,
$totalResult,
$totalRanking,
$totalBest,
$totalAverage,
);
}
$sortable_data[] = $row;
}
@ -555,7 +591,7 @@ class GradebookTable extends SortableTable
) {
$warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category);
$modify_icons = '<a class="right_link" href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'.
Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>';
$warning_message .= $modify_icons;
Display::display_warning_message($warning_message, false);
}

@ -0,0 +1,32 @@
<?php
/* See license terms in /license.txt */
require_once '../inc/global.inc.php';
$categoryId = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : false;
if (empty($categoryId)) {
api_not_allowed(false);
}
$userId = api_get_user_id();
$cats = Category::load($categoryId);
if (isset($cats[0])) {
$cat = $cats[0];
}
$allcat = $cats[0]->get_subcategories($userId, api_get_course_id(), api_get_session_id());
$alleval = $cats[0]->get_evaluations($userId);
$alllink = $cats[0]->get_links($userId);
$gradebooktable = new GradebookTable(
$cat,
$allcat,
$alleval,
$alllink,
array(),
false
);
$table = $gradebooktable->return_table();
echo $gradebooktable->getGraph();

@ -45,6 +45,7 @@ class PDF
$this->params['course_code'] = isset($params['course_code']) ? $params['course_code'] : api_get_course_id();
$this->params['add_signatures'] = isset($params['add_signatures']) ? $params['add_signatures'] : false;
$this->params['show_real_course_teachers'] = isset($params['show_real_course_teachers']) ? $params['show_real_course_teachers'] : false;
$this->params['student_info'] = isset($params['student_info']) ? $params['student_info'] : false;
$this->pdf = new mPDF(
'UTF-8',

@ -8,6 +8,14 @@
{% endif %}
<table align="center" width="100%">
{% if pdf_student_info %}
<tr>
<td>
<strong>{{ "Student" | get_lang }}:</strong> {{ pdf_student_info.complete_name }}
</td>
</tr>
{% endif %}
<tr>
<td>
<strong>{{ "Teacher" | get_lang }}:</strong> {{ pdf_teachers }}

Loading…
Cancel
Save