Skip to content

Commit

Permalink
Fix total result for student see BT#13460
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Oct 2, 2017
1 parent b12ac8d commit 6317d46
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
22 changes: 11 additions & 11 deletions main/gradebook/lib/fe/displaygradebook.php
Expand Up @@ -62,7 +62,7 @@ public static function display_header_result($evalobj, $selectcat, $page)
$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) {
Expand All @@ -74,7 +74,7 @@ public static function display_header_result($evalobj, $selectcat, $page)
);
}
}
$description = "";
$description = '';
if (!$evalobj->get_description() == '') {
$description = get_lang('Description').' :<b> '.$evalobj->get_description().'</b><br>';
}
Expand Down Expand Up @@ -322,14 +322,14 @@ public static function header(
$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);
Expand Down Expand Up @@ -503,14 +503,14 @@ public static function header(
$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());
Expand Down
19 changes: 12 additions & 7 deletions main/gradebook/lib/fe/gradebooktable.class.php
Expand Up @@ -332,7 +332,6 @@ public function get_table_data($from = 1, $per_page = null, $column = null, $dir
} else {
$cattotal = Category::load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score($this->userId);
$item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
}

// Edit (for admins).
Expand All @@ -356,7 +355,6 @@ public function get_table_data($from = 1, $per_page = null, $column = null, $dir
}

// 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;
Expand Down Expand Up @@ -395,6 +393,7 @@ public function get_table_data($from = 1, $per_page = null, $column = null, $dir
)
);
$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);

Expand Down Expand Up @@ -500,14 +499,12 @@ public function get_table_data($from = 1, $per_page = null, $column = null, $dir
} 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());
Expand Down Expand Up @@ -626,13 +623,21 @@ public function get_table_data($from = 1, $per_page = null, $column = null, $dir
} 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
Expand Down

0 comments on commit 6317d46

Please sign in to comment.