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
);
$totalRanking = [];
$invalidateRanking = true;
$average = 0;
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
);
$row = [
null,
'<h3>'.get_lang('Total').'</h3>',
];
if ($invalidateRanking) {
$totalRanking = null;
}
if (!$this->exportToPdf) {
$row[] = null;
}
// Overwrite main weight
$totalBest[1] = $main_weight;
$row[] = $main_weight;
$row[] = $totalResult;
$totalBest = $scoredisplay->display_score(
$totalBest,
SCORE_DIV,
SCORE_BOTH,
true
);
if (in_array(1, $this->loadStats)) {
$totalRanking = [];
$invalidateRanking = true;
$average = 0;
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) {
// Overwrite main weight
$totalAverage[0] = $average / count($this->studentList);
$totalAverage[1] = $main_weight;
$totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking);
$totalAverage = $scoredisplay->display_score(
$totalAverage,
SCORE_DIV,
SCORE_BOTH,
true
);
}
$totalRanking = $scoredisplay->display_score(
$totalRanking,
SCORE_DIV,
SCORE_BOTH,
true
);
if ($this->exportToPdf) {
$row = [
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 ($invalidateRanking) {
$totalRanking = null;
}
if (in_array(1, $this->loadStats)) {
$row[] = $totalRanking;
}
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;
}
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;
}
}
$sortable_data[] = $row;
}

Loading…
Cancel
Save