Browse Source

fix gradebook: certificates do not appear anymore and we lost the options that were in the middle page

Juan Carlos Raña 15 years ago
parent
commit
dca247464d
2 changed files with 67 additions and 2 deletions
  1. 1 1
      main/gradebook/gradebook.php
  2. 66 1
      main/gradebook/index.php

+ 1 - 1
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();

+ 66 - 1
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 '<div class="actions" align="right">';
+			$modify_icons= '<a href="gradebook_edit_cat.php?editcat=' . $cats[0]->get_id() . ' &amp;cidReq='.$cats[0]->get_course_code().'"><img src="../img/edit.gif" border="0" title="' . get_lang('EditCategory') . '" alt="'.get_lang('EditCategory').'" />'.get_lang('EditCategory').'</a>';
+			
+			$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $cats[0]->get_id() . '&amp;selectcat=0&amp;cidReq='.$cats[0]->get_course_code().'" onclick="return confirmation();"><img src="../img/delete.gif" border="0" title="' . get_lang('DeleteAll') . '" alt="'.get_lang('DeleteAll').'" />'.get_lang('DeleteAll').'</a>';
+			
+			$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visiblecat=' . $cats[0]->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=0 "><img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang('Visible') . '" alt="'.get_lang('Visible').'" />'.get_lang('Visible').'</a>';
+			echo '<div align="left"><img src="../img/info3.gif" border="0" title="' . $opt_cat_descrip . '" alt="'.$opt_cat_descrip.'" /> '.$op_cat_weight.' '.$opt_cat_cert_min.'</div>';
+			echo $modify_icons;
+			echo '</div>';
+		}
+		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 = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/'.$_SESSION['gradebook_dest'].'?export_certificate=yes&cat_id='.$cats[0]->get_course_code().'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" />'.get_lang('Certificates').'</a>&nbsp;'.get_lang('langTotal').': '.$scoretotal_display;
+			
+			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);
 	}