Fixing certificate link see #7153

1.9.x
Julio Montoya 12 years ago
parent c6658d2755
commit 31ab7c4c16
  1. 47
      main/gradebook/lib/be/category.class.php

@ -611,9 +611,12 @@ class Category implements GradebookItem
public function show_message_resource_delete($course_id) public function show_message_resource_delete($course_id)
{ {
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT count(*) AS num from '.$tbl_grade_categories.' WHERE course_code ="'.Database::escape_string($course_id).'" AND visible=3'; $sql = 'SELECT count(*) AS num from '.$tbl_grade_categories.'
$res=Database::query($sql); WHERE
$option=Database::fetch_array($res,'ASSOC'); course_code = "'.Database::escape_string($course_id).'" AND
visible=3';
$res = Database::query($sql);
$option = Database::fetch_array($res, 'ASSOC');
if ($option['num']>=1) { if ($option['num']>=1) {
return '&nbsp;&nbsp;<span class="resource-deleted">(&nbsp;'.get_lang('ResourceDeleted').'&nbsp;)</span>'; return '&nbsp;&nbsp;<span class="resource-deleted">(&nbsp;'.get_lang('ResourceDeleted').'&nbsp;)</span>';
} else { } else {
@ -1534,8 +1537,8 @@ class Category implements GradebookItem
*/ */
public static function register_user_certificate($category_id, $user_id) public static function register_user_certificate($category_id, $user_id)
{ {
// generating the total score for a course // Generating the total score for a course
$cats_course = Category :: load($category_id, null, null, null, null, null, false); $cats_course = Category::load($category_id, null, null, null, null, null, false);
$alleval_course = $cats_course[0]->get_evaluations($user_id, true); $alleval_course = $cats_course[0]->get_evaluations($user_id, true);
$alllink_course = $cats_course[0]->get_links($user_id, true); $alllink_course = $cats_course[0]->get_links($user_id, true);
@ -1558,30 +1561,28 @@ class Category implements GradebookItem
$item_total_value = 0; $item_total_value = 0;
$item_value = 0; $item_value = 0;
for ($count=0; $count < count($evals_links); $count++) { for ($count=0; $count < count($evals_links); $count++) {
$item = $evals_links[$count]; $item = $evals_links[$count];
$score = $item->calc_score($user_id); $score = $item->calc_score($user_id);
$divide = ( ($score[1])==0 ) ? 1 : $score[1]; $divide = ( ($score[1])==0 ) ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()]; $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
$item_value = $score[0]/$divide*$item->get_weight()*$sub_cat_percentage/$main_weight; //$item_value = $score[0]/$divide*$item->get_weight()*$sub_cat_percentage/$main_weight;
$item_value = $score[0]/$divide*$item->get_weight();
$item_total_value += $item_value; $item_total_value += $item_value;
} }
$item_total_value = (float)$item_total_value; $item_total_value = (float)$item_total_value;
$cattotal = Category :: load($category_id); $cattotal = Category::load($category_id);
$scoretotal= $cattotal[0]->calc_score($user_id); $scoretotal= $cattotal[0]->calc_score($user_id);
//Do not remove this the gradebook/lib/fe/gradebooktable.class.php file load this variable as a global //Do not remove this the gradebook/lib/fe/gradebooktable.class.php file load this variable as a global
$scoredisplay = ScoreDisplay :: instance(); $scoredisplay = ScoreDisplay::instance();
$my_score_in_gradebook = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE); $my_score_in_gradebook = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
//Show certificate // Show certificate
$certificate_min_score = $cats_course[0]->get_certificate_min_score(); $certificate_min_score = $cats_course[0]->get_certificate_min_score();
//a student always sees only the teacher's repartition // A student always sees only the teacher's repartition
$scoretotal_display = $scoredisplay->display_score($scoretotal, SCORE_DIV_PERCENT); $scoretotal_display = $scoredisplay->display_score($scoretotal, SCORE_DIV_PERCENT);
if (isset($certificate_min_score) && $item_total_value >= $certificate_min_score) { if (isset($certificate_min_score) && $item_total_value >= $certificate_min_score) {
@ -1590,16 +1591,26 @@ class Category implements GradebookItem
register_user_info_about_certificate($category_id, $user_id, $my_score_in_gradebook, api_get_utc_datetime()); register_user_info_about_certificate($category_id, $user_id, $my_score_in_gradebook, api_get_utc_datetime());
$my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id); $my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
} }
if (!empty($my_certificate)) { if (!empty($my_certificate)) {
$certificate_obj = new Certificate($my_certificate['id']); $certificate_obj = new Certificate($my_certificate['id']);
$fileWasGenerated = $certificate_obj->html_file_is_generated();
$url = api_get_path(WEB_PATH) .'certificates/index.php?id='.$my_certificate['id']; $html = null;
$certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), 32), $url, array('target'=>'_blank')); if (!empty($fileWasGenerated)) {
$url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
$certificates = Display::url(
Display::return_icon(
'certificate.png',
get_lang('Certificates'),
array(),
32
),
$url,
array('target' => '_blank')
);
$html = '<div class="actions" align="right">'; $html = '<div class="actions" align="right">';
//$html .= Display::url($url, $url, array('target'=>'_blank'));
$html .= $certificates; $html .= $certificates;
$html .= '</div>'; $html .= '</div>';
}
return $html; return $html;
} }
} else { } else {

Loading…
Cancel
Save