Fixing certificate logo, removing results next to the logo see BT#2295

skala
Julio Montoya 14 years ago
parent 10f58ba114
commit 0065678559
  1. 41
      main/gradebook/index.php
  2. 12
      main/gradebook/lib/be/category.class.php
  3. 2
      main/gradebook/lib/be/evallink.class.php
  4. 8
      main/gradebook/lib/be/exerciselink.class.php

@ -834,33 +834,45 @@ if ($category != '0') {
$cats_course = Category :: load ($category_id, null, null, null, null, null, false);
$alleval_course= $cats_course[0]->get_evaluations($stud_id,true);
$alllink_course= $cats_course[0]->get_links($stud_id,true);
$evals_links = array_merge($alleval_course, $alllink_course);
$item_value=0;
$item_total=0;
for ($count=0; $count < count($evals_links); $count++) {
$item = $evals_links[$count];
$score = $item->calc_score($stud_id);
$item = $evals_links[$count];
$score = $item->calc_score($stud_id);
$score_denom=($score[1]==0) ? 1 : $score[1];
$item_value+=$score[0]/$score_denom*$item->get_weight();
$item_total+=$item->get_weight();
}
$score_denom=($score[1]==0) ? 1 : $score[1];
$item_value+=$score[0]/$score_denom*$item->get_weight();
$item_total+=$item->get_weight();
}
$item_value = number_format($item_value, 2, '.', ' ');
/*
$cattotal = Category :: load($category_id);
$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
$scoretotal_display = (isset($scoretotal)? round($scoretotal[0],2).'/'.round($scoretotal[1],2).' ('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)': '-');
//Overwritten the old total with the real total of the gradebook if the line below is deleted, then when a user doesn't finish a test the total will be different from the real total
$scoretotal[1] = $item_total;
//$scoretotal_display = (isset($scoretotal)? round($scoretotal[0],2).'/'.round($scoretotal[1],2).' ('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)': '-');
$my_score_in_gradebook = round($scoretotal[0],2);
//show certificate
$certificate_min_score=$cats[0]->get_certificate_min_score();
*/
//Show certificate
$certificate_min_score=$cats[0]->get_certificate_min_score();
$scoredisplay = ScoreDisplay :: instance();
$scoretotal_display = $scoredisplay->display_score($scoretotal,SCORE_DIV_PERCENT);
if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {
$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']).'?export_certificate=yes&cat_id='.$cats[0]->get_id().'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/logo.gif" />'.get_lang('Certificates').'</a>&nbsp;'.get_lang('langTotal').': '.$scoretotal_display;
$url = api_get_path(WEB_CODE_PATH) .'gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']).'?export_certificate=yes&cat_id='.$cats[0]->get_id();
//$certificates.= '<img src="'.api_get_path(WEB_CODE_PATH) . 'img/logo.gif" />'.get_lang('Certificates').'</a>&nbsp;<strong>'.get_lang('Total').': '.$scoretotal_display.'</strong>';
$certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), 48), $url, array('target'=>'_blank'));
echo '<div class="actions" align="right">';
echo $certificates;
echo '</div>';
}
} //end hack
DisplayGradebook :: display_header_gradebook($cats[0], 0, $category_id, $is_course_admin, $is_platform_admin, $simple_search_form, false, true);
DisplayGradebook::display_header_gradebook($cats[0], 0, $category_id, $is_course_admin, $is_platform_admin, $simple_search_form, false, true);
}
} else {
//this is the root category
@ -869,9 +881,7 @@ if ($category != '0') {
if (api_is_allowed_to_edit(null, true)) {
/*
-----------------------------------------------------------
Introduction section (teacher edit)
-----------------------------------------------------------
*/
// Tool introduction
@ -888,8 +898,7 @@ if (api_is_allowed_to_edit(null, true)) {
}
}
}
if($first_time==1 && api_is_allowed_to_edit(null,true))
{
if($first_time==1 && api_is_allowed_to_edit(null,true)) {
echo '<meta http-equiv="refresh" content="0;url='.api_get_self().'?cidReq='.$course_code.'" />';
} else {
$gradebooktable->display();

@ -465,10 +465,9 @@ class Category implements GradebookItem
}
}
}
if (!empty($evals)) {
foreach ($evals as $eval) {
$evalres = $eval->calc_score ($stud_id);
$evalres = $eval->calc_score($stud_id);
if (isset($evalres) && $eval->get_weight() != 0) {
$evalweight = $eval->get_weight();
$rescount++;
@ -477,10 +476,9 @@ class Category implements GradebookItem
}
}
}
if (!empty($links)) {
foreach ($links as $link) {
$linkres = $link->calc_score ($stud_id);
foreach ($links as $link) {
$linkres = $link->calc_score($stud_id);
if (isset($linkres) && $link->get_weight() != 0) {
$linkweight = $link->get_weight();
$link_res_denom = ($linkres[1]==0) ? 1 : $linkres[1];
@ -490,13 +488,11 @@ class Category implements GradebookItem
}
}
}
if ($rescount == 0) {
return null;
} else {
return array ($ressum, $weightsum);
}
}
/**
@ -1067,7 +1063,7 @@ class Category implements GradebookItem
// no links in root or course independent categories
if ($this->id == 0) {
;
}
// 1 student $stud_id
elseif (isset($stud_id)) {

@ -23,7 +23,7 @@ abstract class EvalLink extends AbstractLink
return $eval->has_results();
}
public function calc_score($stud_id = null) {
public function calc_score($stud_id = null) {
$eval = $this->get_evaluation();
return $eval->calc_score($stud_id);
}

@ -102,19 +102,15 @@ class ExerciseLink extends AbstractLink
$course_code_exe = $this->get_course_code();
$sql .= ' AND exe_cours_id="'.$course_code_exe.'" AND exe_user_id = '."'".$stud_id."'";
}
$sql .= ' ORDER BY exe_id DESC';
$sql .= ' ORDER BY exe_id DESC';
$scores = Database::query($sql);
if (isset($stud_id)) {
// for 1 student
if ($data=Database::fetch_array($scores)) {
return array ($data['exe_result'], $data['exe_weighting']);
} else {
return null;
return null;
}
} else {// all students -> get average
// normal way of getting the info

Loading…
Cancel
Save