Minor - format code

pull/3356/head
Julio Montoya 5 years ago
parent 5c83c2b2a4
commit 781d84c883
  1. 11
      main/gradebook/lib/be/evaluation.class.php
  2. 1
      main/gradebook/lib/fe/flatviewtable.class.php
  3. 27
      main/gradebook/lib/flatview_data_generator.class.php
  4. 22
      main/gradebook/lib/scoredisplay.class.php

@ -536,6 +536,7 @@ class Evaluation implements GradebookItem
public function calc_score($stud_id = null, $type = null)
{
$allowStats = api_get_configuration_value('allow_gradebook_stats');
if ($allowStats) {
$evaluation = $this->entity;
if (!empty($evaluation)) {
@ -602,10 +603,12 @@ class Evaluation implements GradebookItem
Session::write('calc_score', [$key => $results]);
}
$score = 0;
/** @var Result $res */
foreach ($results as $res) {
$score = $res->get_score();
$score = null;
if (!empty($results)) {
/** @var Result $res */
foreach ($results as $res) {
$score = $res->get_score();
}
}
return [$score, $this->get_max()];

@ -93,7 +93,6 @@ class FlatViewTable extends SortableTable
{
$headerName = $this->datagen->get_header_names();
$total_users = $this->datagen->get_total_users_count();
$customdisplays = ScoreDisplay::instance()->get_custom_score_display_settings();
if (empty($customdisplays)) {

@ -924,7 +924,6 @@ class FlatViewDataGenerator
];
$item_value_total += $item_value;
$final_score += $score[0];
//$final_score = ($final_score / $item_total) * 100;
}
$total_score = [$final_score, $item_total];
$row[] = [
@ -942,21 +941,29 @@ class FlatViewDataGenerator
for ($count = 0; $count < count($this->evals_links); $count++) {
$item = $this->evals_links[$count];
$score = $item->calc_score($user[0]);
$divide = 0 == $score[1] ? 1 : $score[1];
$item_value += $score[0] / $divide * $item->get_weight();
$item_total += $item->get_weight();
$score_denom = (0 == $score[1]) ? 1 : $score[1];
$score_final = ($score[0] / $score_denom) * 100;
$row[] = [
$score_final,
trim(
$score_final = null;
$displayScore = null;
if (null !== $score) {
$divide = 0 == $score[1] ? 1 : $score[1];
$item_value += $score[0] / $divide * $item->get_weight();
$item_total += $item->get_weight();
$score_denom = (0 == $score[1]) ? 1 : $score[1];
$score_final = ($score[0] / $score_denom) * 100;
$displayScore = trim(
$scoreDisplay->display_score(
$score,
SCORE_CUSTOM,
null,
true
)
),
);
}
$row[] = [
$score_final,
$displayScore,
];
}
$total_score = [$item_value, $item_total];

@ -302,19 +302,21 @@ class ScoreDisplay
) {
$my_score = $score == 0 ? [] : $score;
if ($type == SCORE_BAR) {
$percentage = $my_score[0] / $my_score[1] * 100;
switch ($type) {
case SCORE_BAR:
$percentage = $my_score[0] / $my_score[1] * 100;
return Display::bar_progress($percentage);
}
if ($type == SCORE_NUMERIC) {
$percentage = $my_score[0] / $my_score[1] * 100;
return Display::bar_progress($percentage);
break;
case SCORE_NUMERIC:
return round($percentage);
}
$percentage = $my_score[0] / $my_score[1] * 100;
if ($type == SCORE_SIMPLE) {
return $this->format_score($my_score[0], $ignoreDecimals);
return round($percentage);
break;
case SCORE_SIMPLE:
return $this->format_score($my_score[0], $ignoreDecimals);
break;
}
if ($this->custom_enabled && isset($this->custom_display_conv)) {

Loading…
Cancel
Save