Fix total result for student see BT#13460

pull/2487/head
jmontoyaa 7 years ago
parent b12ac8d66d
commit 6317d469ad
  1. 22
      main/gradebook/lib/fe/displaygradebook.php
  2. 19
      main/gradebook/lib/fe/gradebooktable.class.php

@ -62,7 +62,7 @@ class DisplayGradebook
$scoredisplay = ScoreDisplay::instance();
$student_score = '';
$average = '';
if (($evalobj->has_results())) {
if ($evalobj->has_results()) {
// TODO this check needed ?
$score = $evalobj->calc_score();
if ($score != null) {
@ -74,7 +74,7 @@ class DisplayGradebook
);
}
}
$description = "";
$description = '';
if (!$evalobj->get_description() == '') {
$description = get_lang('Description').' :<b> '.$evalobj->get_description().'</b><br>';
}
@ -322,14 +322,14 @@ class DisplayGradebook
$total_score = array($item_value_total, $item_total);
$scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) {
$aditionalButtons = null;
$additionalButtons = null;
if (!empty($certificateLinkInfo)) {
$aditionalButtons .= '<div class="btn-group pull-right">';
$aditionalButtons .= isset($certificateLinkInfo['certificate_link']) ? $certificateLinkInfo['certificate_link'] : '';
$aditionalButtons .= isset($certificateLinkInfo['badge_link']) ? $certificateLinkInfo['badge_link'] : '';
$aditionalButtons .= '</div>';
$additionalButtons .= '<div class="btn-group pull-right">';
$additionalButtons .= isset($certificateLinkInfo['certificate_link']) ? $certificateLinkInfo['certificate_link'] : '';
$additionalButtons .= isset($certificateLinkInfo['badge_link']) ? $certificateLinkInfo['badge_link'] : '';
$additionalButtons .= '</div>';
}
$scoreinfo .= '<strong>'.sprintf(get_lang('TotalX'), $scorecourse_display.$aditionalButtons).'</strong>';
$scoreinfo .= '<strong>'.sprintf(get_lang('TotalX'), $scorecourse_display.$additionalButtons).'</strong>';
}
echo Display::return_message($scoreinfo, 'normal', false);
@ -503,14 +503,14 @@ class DisplayGradebook
$weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
$weight = '<strong>'.get_lang('TotalWeight').' : </strong>'.$weight;
$min_certification = (intval($catobj->getCertificateMinScore() > 0) ? $catobj->getCertificateMinScore() : 0);
$min_certification = intval($catobj->getCertificateMinScore() > 0) ? $catobj->getCertificateMinScore() : 0;
$min_certification = get_lang('CertificateMinScore').' : '.$min_certification;
$edit_icon = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&amp;cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
//$msg = Display::tag('h3', $weight.' - '.$min_certification);
$msg = $weight.' - '.$min_certification.$edit_icon;
//@todo show description
$description = (($catobj->get_description() == "" || is_null($catobj->get_description())) ? '' : '<strong>'.get_lang('GradebookDescriptionLog').'</strong>'.': '.$catobj->get_description());
$description = (($catobj->get_description() == '' || is_null($catobj->get_description())) ? '' : '<strong>'.get_lang('GradebookDescriptionLog').'</strong>'.': '.$catobj->get_description());
echo Display::return_message($msg, 'normal', false);
if (!empty($description)) {
echo Display::div($description, array());

@ -332,7 +332,6 @@ class GradebookTable extends SortableTable
} else {
$cattotal = Category::load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score($this->userId);
$item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
}
// Edit (for admins).
@ -356,7 +355,6 @@ class GradebookTable extends SortableTable
}
// Students get the results and certificates columns
//if (count($this->evals_links) > 0 && $status_user != 1) {
if (1) {
$value_data = isset($data[4]) ? $data[4] : null;
$best = isset($data['best']) ? $data['best'] : null;
@ -395,6 +393,7 @@ class GradebookTable extends SortableTable
)
);
$this->dataForGraph['my_result'][] = floatval($totalResultAverageValue);
$this->dataForGraph['my_result_no_float'][] = $data['result_score'][0];
$totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, SCORE_AVERAGE));
$this->dataForGraph['average'][] = floatval($totalAverageValue);
@ -500,14 +499,12 @@ class GradebookTable extends SortableTable
} else {
$cattotal = Category::load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score($this->userId);
$item_value = $scoretotal[0];
}
// Admins get an edit column.
if (api_is_allowed_to_edit(null, true) &&
isset($_GET['user_id']) == false &&
(isset($_GET['action']) && $_GET['action'] != 'export_all' || !isset($_GET['action'])
)
(isset($_GET['action']) && $_GET['action'] != 'export_all' || !isset($_GET['action']))
) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
@ -626,13 +623,21 @@ class GradebookTable extends SortableTable
} else {
// Total for student.
if (count($main_cat) > 1) {
$weights = [];
foreach ($main_categories as $cat) {
$weights[] = $cat['weight'];
}
$main_weight = intval($main_cat[0]->get_weight());
$global = null;
$average = null;
$myTotal = 0;
foreach ($this->dataForGraph['my_result_no_float'] as $result) {
$myTotal += $result;
}
$totalResult[0] = $myTotal;
// Overwrite main weight
$totalResult[1] = $main_weight;
$totalResult = $scoredisplay->display_score(
$totalResult,
SCORE_DIV

Loading…
Cancel
Save