From 2f8b24d6dd2baf88c481736c933f09ba0ab3fd04 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 12 Jul 2011 17:58:30 +0200 Subject: [PATCH] Minor gradebook corrections --- main/gradebook/index.php | 24 +++++++++++-------- main/gradebook/lib/fe/displaygradebook.php | 8 +++---- .../gradebook/lib/fe/gradebooktable.class.php | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/main/gradebook/index.php b/main/gradebook/index.php index e5f92f97c9..4419e46bcc 100755 --- a/main/gradebook/index.php +++ b/main/gradebook/index.php @@ -50,7 +50,7 @@ function confirmation() { $tbl_forum_thread = Database :: get_course_table(TABLE_FORUM_THREAD); $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); -$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); +$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); $filter_confirm_msg = true; $filter_warning_msg = true; @@ -540,7 +540,7 @@ if (isset ($move_form)){ // LOAD DATA & DISPLAY TABLE $is_platform_admin = api_is_platform_admin(); -$is_course_admin = api_is_allowed_to_create_course(); +$is_course_admin = api_is_allowed_to_edit(null, true);// api_is_allowed_to_create_course(); //load data for category, evaluation and links if (empty ($_GET['selectcat'])) { @@ -799,15 +799,16 @@ $no_qualification = false; if (( count($allcat) == 0) && ( count($alleval) == 0 ) && ( count($alllink) == 0 )) { $no_qualification = true; if ((($is_course_admin) && (!isset ($_GET['selectcat']))) && api_is_course_tutor()) { - Display :: display_normal_message(get_lang('GradebookWelcomeMessage') . '

',false); + Display :: display_normal_message(get_lang('GradebookWelcomeMessage') . '

',false); } } + //here we are in a sub category if ($category != '0') { $cat = new Category(); $category_id = intval($_GET['selectcat']); $course_id = Database::get_course_by_category($category_id); - $show_message=$cat->show_message_resource_delete($course_id); + $show_message = $cat->show_message_resource_delete($course_id); if ($show_message=='') { //hack for inside courses menu cat @@ -830,7 +831,7 @@ if ($category != '0') { echo ''; } else { // generating the total score for a course - $stud_id= api_get_user_id(); + $stud_id = api_get_user_id(); $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); @@ -851,6 +852,7 @@ if ($category != '0') { $cattotal = Category :: load($category_id); $scoretotal= $cattotal[0]->calc_score(api_get_user_id()); + /* //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; @@ -861,13 +863,13 @@ if ($category != '0') { $my_score_in_gradebook = round($scoretotal[0],2); //Show certificate - $certificate_min_score=$cats[0]->get_certificate_min_score(); + $certificate_min_score = $cats[0]->get_certificate_min_score(); $scoredisplay = ScoreDisplay :: instance(); $scoretotal_display = $scoredisplay->display_score($scoretotal,SCORE_DIV_PERCENT); //a student always sees only the teacher's repartition //$score_compare = ($scoretotal[0] / $scoretotal[1]) * 100; //build the total percentage obtained in order to compare it to the minimum certification percentage if (isset($certificate_min_score) && $item_value >= $certificate_min_score) { $url = api_get_path(WEB_CODE_PATH) .'gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']).'?export_certificate=yes&cat_id='.$cats[0]->get_id(); - //$certificates.= ''.get_lang('Certificates').' '.get_lang('Total').': '.$scoretotal_display.''; + $certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), 48), $url, array('target'=>'_blank')); echo '
'; @@ -875,10 +877,11 @@ if ($category != '0') { echo '
'; } } //end hack + 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 +} else { + //this is the root category //DisplayGradebook :: display_header_gradebook($cats[0], 0, 0, $is_course_admin, $is_platform_admin, $simple_search_form, false, false); } @@ -886,9 +889,10 @@ if (api_is_allowed_to_edit(null, true)) { // Tool introduction Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction')); - if ( (isset ($_GET['selectcat']) && $_GET['selectcat']<>0) ) { + if ( (isset ($_GET['selectcat']) && $_GET['selectcat']<>0) ) { // } else { + if (((isset ($_GET['selectcat']) && $_GET['selectcat']==0) || ((isset($_GET['cidReq']) && $_GET['cidReq']!==''))) || isset($_GET['isStudentView']) && $_GET['isStudentView']=='false') { $cats = Category :: load(null, null, $course_code, null, null, $session_id, false); if (!$first_time=1) { diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php index 444040f7de..2e13b136ae 100755 --- a/main/gradebook/lib/fe/displaygradebook.php +++ b/main/gradebook/lib/fe/displaygradebook.php @@ -198,7 +198,7 @@ class DisplayGradebook $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); $objcat = new Category(); //$objdat=new Database(); - $course_id=Database::get_course_by_category($selectcat); + $course_id = Database::get_course_by_category($selectcat); $message_resource=$objcat->show_message_resource_delete($course_id); if (!$is_course_admin && $status<>1 && $selectcat<>0) { @@ -229,13 +229,13 @@ class DisplayGradebook $cattotal = Category :: load(0); $scoretotal= $cattotal[0]->calc_score(api_get_user_id()); - $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable')); + $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable')); $scoreinfo = get_lang('StatsStudent') . ' : '.api_get_person_name($user['firstname'], $user['lastname']).'
'; if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search']))) { $scoreinfo.= '

'.get_lang('Total') . ' : ' . $scorecourse_display . '

'; } - //$scoreinfo.= '
'.get_lang('Total') . ' : ' . $scoretotal_display . ''; - Display :: display_normal_message($scoreinfo,false); + //$scoreinfo.= '
'.get_lang('Total') . ' : ' . $scoretotal_display . ''; + Display :: display_normal_message($scoreinfo, false); } // show navigation tree and buttons? $header=''; diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php index c29686689e..637b5b081c 100755 --- a/main/gradebook/lib/fe/gradebooktable.class.php +++ b/main/gradebook/lib/fe/gradebooktable.class.php @@ -181,7 +181,7 @@ class GradebookTable extends SortableTable $item_value = number_format($item_value, 2, '.', ' '); $row[] = $invisibility_span_open . $data[3] . $invisibility_span_close; //} - } + } $row[] = $invisibility_span_open.$data[4].$invisibility_span_close; //admins get an edit column