From dca247464d3500abc4b7ff64373a2cf8e87ec786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Thu, 12 Nov 2009 23:10:26 +0100 Subject: [PATCH] fix gradebook: certificates do not appear anymore and we lost the options that were in the middle page --- main/gradebook/gradebook.php | 2 +- main/gradebook/index.php | 67 +++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/main/gradebook/gradebook.php b/main/gradebook/gradebook.php index d56016fe2a..56e57179dc 100644 --- a/main/gradebook/gradebook.php +++ b/main/gradebook/gradebook.php @@ -541,7 +541,7 @@ if (!empty($keyword)) { if (!api_is_allowed_to_edit(true,true)) { $user_id = api_get_user_id(); } - $category = Category :: load (Security::remove_XSS($_GET['cat'])); + $category = Category :: load (Security::remove_XSS($_GET['cat_id'])); if ($category[0]->is_certificate_available($user_id)) { $user= get_user_info_from_id($user_id); $scoredisplay = ScoreDisplay :: instance(); diff --git a/main/gradebook/index.php b/main/gradebook/index.php index c4ed2b2a8b..69b571adf2 100755 --- a/main/gradebook/index.php +++ b/main/gradebook/index.php @@ -604,7 +604,8 @@ if (isset ($_GET['studentoverview'])) { $user_id = api_get_user_id(); } - $category = Category :: load ($_GET['cat_id']); + $category = Category :: load($category); //hack replace $category = Category :: load ($_GET['cat_id']); to get de course name in certificates + if ($category[0]->is_certificate_available($user_id)) { $user= get_user_info_from_id($user_id); $scoredisplay = ScoreDisplay :: instance(); @@ -660,6 +661,15 @@ if (isset ($_GET['studentoverview'])) { if ($_in_course === true) { // When *inside* a course, we want to make sure there is one (and only // one) category for this course or for this session. + + //hack for delete a gradebook from inside course + $clean_deletecat=Security::remove_XSS($_GET['deletecat']); + if (!empty($clean_deletecat)) + { + exit; + } + //end hack + $cats = Category :: load(null, null, $course_code, null, null, $session_id, false); if (empty($cats)) { // There is no category for this course+session, so create one @@ -737,6 +747,61 @@ if ($category != '0') { $course_id=Database::get_course_by_category($category_id); $show_message=$cat->show_message_resource_delete($course_id); if ($show_message=='') { + + //hack for inside courses menu cat + if (api_is_allowed_to_edit()) { + + $op_cat_weight= get_lang('Weight').': '.$cats[0]->get_weight(); + $opt_cat_cert_min= get_lang('CertificateMinScore').': '.$cats[0]->get_certificate_min_score(); + $opt_cat_descrip= get_lang('GradebookDescriptionLog').': '.$cats[0]->get_description(); + + $visibility_icon= ($cats[0]->is_visible() == 0) ? 'invisible' : 'visible'; + $visibility_command= ($cats[0]->is_visible() == 0) ? 'set_visible' : 'set_invisible'; + echo '
'; + $modify_icons= ''.get_lang('EditCategory').''.get_lang('EditCategory').''; + + $modify_icons .= ' '.get_lang('DeleteAll').''.get_lang('DeleteAll').''; + + $modify_icons .= ' '.get_lang('Visible').''.get_lang('Visible').''; + echo '
'.$opt_cat_descrip.' '.$op_cat_weight.' '.$opt_cat_cert_min.'
'; + echo $modify_icons; + echo '
'; + } + else + { + // generating the total score for a course + $stud_id= api_get_user_id(); + $cats_course = Category :: load ($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); + + $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($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) . ' %)': '-'); + + //show certificate + $certificate_min_score=$cats[0]->get_certificate_min_score(); + if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) { + $certificates = ''.get_lang('Certificates').' '.get_lang('langTotal').': '.$scoretotal_display; + + echo '
'; + echo $certificates; + echo '
'; + + } + } //end hack + DisplayGradebook :: display_header_gradebook($cats[0], 0, $category_id, $is_course_admin, $is_platform_admin, $simple_search_form, false, true); }