Fix export gradebook to pdf - refs BT#14687 #2609

pull/2606/head
Angel Fernando Quiroz Campos 7 years ago
parent 4d67dfb66a
commit c51000cb5c
  1. 113
      main/gradebook/lib/fe/gradebooktable.class.php

@ -683,83 +683,72 @@ class GradebookTable extends SortableTable
SCORE_DIV SCORE_DIV
); );
$totalRanking = []; $row = [
$invalidateRanking = true; null,
$average = 0; '<h3>'.get_lang('Total').'</h3>',
foreach ($this->studentList as $student) { ];
$score = $main_cat[0]->calc_score($student['user_id']);
if (!empty($score[0])) {
$invalidateRanking = false;
}
$totalRanking[$student['user_id']] = $score[0];
$average += $score[0];
}
$totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking);
$totalRanking = $scoredisplay->display_score(
$totalRanking,
SCORE_DIV,
SCORE_BOTH,
true
);
if ($invalidateRanking) { if (!$this->exportToPdf) {
$totalRanking = null; $row[] = null;
} }
// Overwrite main weight $row[] = $main_weight;
$totalBest[1] = $main_weight; $row[] = $totalResult;
$totalBest = $scoredisplay->display_score( if (in_array(1, $this->loadStats)) {
$totalBest, $totalRanking = [];
SCORE_DIV, $invalidateRanking = true;
SCORE_BOTH, $average = 0;
true foreach ($this->studentList as $student) {
); $score = $main_cat[0]->calc_score($student['user_id']);
if (!empty($score[0])) {
$invalidateRanking = false;
}
$totalRanking[$student['user_id']] = $score[0];
$average += $score[0];
}
if ($this->exportToPdf || $this->loadStats) { $totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking);
// Overwrite main weight
$totalAverage[0] = $average / count($this->studentList);
$totalAverage[1] = $main_weight;
$totalAverage = $scoredisplay->display_score( $totalRanking = $scoredisplay->display_score(
$totalAverage, $totalRanking,
SCORE_DIV, SCORE_DIV,
SCORE_BOTH, SCORE_BOTH,
true true
); );
}
if ($this->exportToPdf) { if ($invalidateRanking) {
$row = [ $totalRanking = null;
null, }
'<h3>'.get_lang('Total').'</h3>',
$main_weight,
$totalResult,
$totalRanking,
$totalBest,
$totalAverage,
];
} else {
$row = [
null,
'<h3>'.get_lang('Total').'</h3>',
null,
$main_weight,
$totalResult,
];
if (in_array(1, $this->loadStats)) {
$row[] = $totalRanking; $row[] = $totalRanking;
} }
if (in_array(2, $this->loadStats)) { if (in_array(2, $this->loadStats)) {
// Overwrite main weight
$totalBest[1] = $main_weight;
$totalBest = $scoredisplay->display_score(
$totalBest,
SCORE_DIV,
SCORE_BOTH,
true
);
$row[] = $totalBest; $row[] = $totalBest;
} }
if (in_array(3, $this->loadStats)) { if (in_array(3, $this->loadStats)) {
// Overwrite main weight
$totalAverage[0] = $average / count($this->studentList);
$totalAverage[1] = $main_weight;
$totalAverage = $scoredisplay->display_score(
$totalAverage,
SCORE_DIV,
SCORE_BOTH,
true
);
$row[] = $totalAverage; $row[] = $totalAverage;
} }
}
$sortable_data[] = $row; $sortable_data[] = $row;
} }

Loading…
Cancel
Save