Gradebook - Fix export results only score BT#18440

pull/3782/head
Julio Montoya 5 years ago
parent be3f7d2393
commit a3cd0ec489
  1. 2
      main/gradebook/gradebook_flatview.php
  2. 12
      main/gradebook/lib/GradebookUtils.php
  3. 29
      main/gradebook/lib/flatview_data_generator.class.php

@ -214,7 +214,7 @@ if (!empty($_GET['export_report']) &&
if (empty($_SESSION['export_user_fields'])) {
$_SESSION['export_user_fields'] = false;
}
if (!api_is_allowed_to_edit(false, false) && !api_is_course_tutor()) {
if (!api_is_allowed_to_edit() && !api_is_course_tutor()) {
$user_id = api_get_user_id();
}

@ -628,9 +628,10 @@ class GradebookUtils
$offset = isset($_GET['offset']) ? (int) $_GET['offset'] : 0;
// step 2: generate rows: students
$datagen->category = $cat;
$count = (($offset + 10) > $datagen->get_total_items_count()) ? ($datagen->get_total_items_count() - $offset) : GRADEBOOK_ITEM_LIMIT;
$header_names = $datagen->get_header_names($offset, $count, true);
$data_array = $datagen->get_data(
$totalItems = $datagen->get_total_items_count();
$count = (($offset + 10) > $totalItems) ? ($totalItems - $offset) : GRADEBOOK_ITEM_LIMIT;
$headers = $datagen->get_header_names($offset, $count, true);
$list = $datagen->get_data(
FlatViewDataGenerator::FVDG_SORT_LASTNAME,
0,
null,
@ -641,12 +642,11 @@ class GradebookUtils
);
$result = [];
foreach ($data_array as $data) {
foreach ($list as $data) {
$result[] = array_slice($data, 1);
}
$return = [$header_names, $result];
return $return;
return [$headers, $result];
}
/**

@ -566,7 +566,10 @@ class FlatViewDataGenerator
$items_count,
$items_start,
$show_all,
$row
$row,
null,
[],
$ignore_score_color
);
$item_value_total += $result['item_value_total'];
$evaluationsAdded = $result['evaluations_added'];
@ -582,7 +585,8 @@ class FlatViewDataGenerator
$show_all,
$row,
$mainCategoryId,
$evaluationsAdded
$evaluationsAdded,
$ignore_score_color
);
$item_total += $result['item_total'];
@ -655,7 +659,8 @@ class FlatViewDataGenerator
$show_all,
&$row,
$parentCategoryIdFilter = null,
$evaluationsAlreadyAdded = []
$evaluationsAlreadyAdded = [],
$ignoreScoreDecorations = false
) {
// Generate actual data array
$scoreDisplay = ScoreDisplay::instance();
@ -688,13 +693,10 @@ class FlatViewDataGenerator
$evaluationsAdded[] = $item->get_id();
$score = $item->calc_score($user_id);
$real_score = $score;
$divide = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1;
// Sub cat weight
$item_value = isset($score[0]) ? $score[0] / $divide : null;
// Fixing total when using one or multiple gradebooks.
if (empty($parentCategoryIdFilter)) {
if (0 == $this->category->get_parent_id()) {
@ -718,7 +720,8 @@ class FlatViewDataGenerator
$complete_score = $scoreDisplay->display_score(
$score,
SCORE_DIV_PERCENT,
SCORE_ONLY_SCORE
SCORE_ONLY_SCORE,
$ignoreScoreDecorations
);
if ('false' === $showPercentage) {
@ -728,17 +731,23 @@ class FlatViewDataGenerator
}
$real_score = $scoreDisplay->display_score(
$real_score,
$defaultShowPercentageValue
$defaultShowPercentageValue,
null,
$ignoreScoreDecorations
);
$temp_score = $scoreDisplay->display_score(
[$item_value, null],
SCORE_DIV_SIMPLE_WITH_CUSTOM
SCORE_DIV_SIMPLE_WITH_CUSTOM,
null,
$ignoreScoreDecorations
);
$temp_score = Display::tip($real_score, $temp_score);
} else {
$temp_score = $scoreDisplay->display_score(
$real_score,
$defaultStyle
$defaultStyle,
null,
$ignoreScoreDecorations
);
$temp_score = Display::tip($temp_score, $complete_score);
}

Loading…
Cancel
Save