Browse Source

More fixes in gradebook see #5168

Julio Montoya 12 years ago
parent
commit
9dac8c9bcd

+ 1 - 1
main/gradebook/lib/be/category.class.php

@@ -1348,5 +1348,5 @@ class Category implements GradebookItem
             }
             event_system($event_type, LOG_GRADEBOOK_ID, $this->id);   
         }
-    }
+    }     
 }

+ 17 - 5
main/gradebook/lib/fe/gradebooktable.class.php

@@ -191,7 +191,12 @@ class GradebookTable extends SortableTable {
             
             $scoredisplay = ScoreDisplay :: instance();            
             $average = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_PERCENT, SCORE_BOTH, true);
-            $row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close;		
+            
+            if (api_is_allowed_to_edit(null, true)) {
+                $row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close;		
+            } else {
+                $row[] = $invisibility_span_open .$average.$invisibility_span_close;		
+            }
             
             $category_weight = $item->get_weight();
             	
@@ -201,7 +206,7 @@ class GradebookTable extends SortableTable {
 				$cattotal   = Category :: load($_GET['selectcat']);
                 $scoretotal = $cattotal[0]->calc_score(api_get_user_id());                    
                 $item_value = $scoretotal[0];
-                $item_value = number_format($item_value, api_get_setting('gradebook_number_decimals'), '.', ' ');			   				  			   	
+                $item_value = number_format($item_value, api_get_setting('gradebook_number_decimals'), '.', ' ');                
 			}
 						
 			//Date
@@ -223,8 +228,14 @@ class GradebookTable extends SortableTable {
 					} else {                        
                         $row[] = $this->build_edit_column($item);     
                     }
-				} else {
-                    $row[] = $this->build_edit_column($item);
+				} else {     
+                    $score = $item->calc_score(api_get_user_id());                    
+                    //$bar = $scoredisplay->display_score($score, SCORE_BAR);
+                    //$score = $scoredisplay->display_score($score);
+                    
+                    $score = $score[0]/$score[1]*$item->get_weight();
+                    
+                    $row[] = $score.' '.$this->build_edit_column($item);
                 }
 			}
             
@@ -312,7 +323,8 @@ class GradebookTable extends SortableTable {
 						
 						if (count($eval_n_links)> 0 && $status_user!=1 ) {
 							$value_data = isset($data[4]) ? $data[4] : null;							
-							if (!is_null($value_data)) {                                
+							if (!is_null($value_data)) {     
+                                $score = $item->calc_score(api_get_user_id());                                
 								$row[] = $value_data;
 							}
 						}

+ 3 - 4
main/gradebook/lib/gradebook_functions.inc.php

@@ -219,10 +219,8 @@ function build_edit_icons_cat($cat, $selectcat) {
                 }
             }
             
-            $modify_icons .= '<a href="gradebook_edit_all.php?&selectcat=' . $cat->get_id() . '">'.Display::return_icon('percentage.png', get_lang('EditAllWeights'),'',ICON_SIZE_SMALL).'</a>';
-            
-            $modify_icons .= '<a href="gradebook_flatview.php?'.api_get_self().'&selectcat=' . $cat->get_id() . '">'.Display::return_icon('stats.png', get_lang('FlatView'),'', ICON_SIZE_SMALL).'</a>';
-            
+            $modify_icons .= '<a href="gradebook_edit_all.php?&selectcat=' . $cat->get_id() . '">'.Display::return_icon('percentage.png', get_lang('EditAllWeights'),'',ICON_SIZE_SMALL).'</a>';            
+            $modify_icons .= '<a href="gradebook_flatview.php?'.api_get_self().'&selectcat=' . $cat->get_id() . '">'.Display::return_icon('stats.png', get_lang('FlatView'),'', ICON_SIZE_SMALL).'</a>';            
             $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visiblecat=' . $cat->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=' . $selectcat . ' ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).'</a>';
 
             //no move ability for root categories
@@ -232,6 +230,7 @@ function build_edit_icons_cat($cat, $selectcat) {
             } else {
                 //$modify_icons .= '&nbsp;<img src="../img/deplacer_fichier_na.gif" border="0" title="' . get_lang('Move') . '" alt="" />';
             }
+            
             if ($cat->is_locked() && !api_is_platform_admin()) {
                 $modify_icons .= Display::return_icon('delete_na.png', get_lang('DeleteAll'),'',ICON_SIZE_SMALL);
             } else {

+ 8 - 1
main/gradebook/lib/scoredisplay.class.php

@@ -15,6 +15,8 @@ define('SCORE_DIV_PERCENT',              3);    // X / Y (XX %)
 define('SCORE_AVERAGE',                  4);    // XX %
 define('SCORE_DECIMAL',                  5);    // 0.50  (X/Y)
 
+define('SCORE_BAR',                      6);    // Uses the Display::bar_progress function
+
 //@todo where is number 6?
 
 define('SCORE_IGNORE_SPLIT',             8);    //  ??
@@ -254,7 +256,12 @@ class ScoreDisplay
 	 * 				(only taken into account if custom score display is enabled and for course/platform admin)
 	 */
 	public function display_score($score, $type = SCORE_DIV_PERCENT, $what = SCORE_BOTH, $no_color = false) {	  
-		$my_score = ($score==0) ? 1 : $score;		        
+		$my_score = ($score==0) ? 1 : $score;	
+        
+        if ($type == SCORE_BAR) {
+            $percentage = $my_score[0]/$my_score[1]*100;            
+            return Display::bar_progress($percentage);
+        }
 		if ($this->custom_enabled && isset($this->custom_display_conv)) {		    
 	        $display = $this->display_default($my_score, $type);	        
 		} else {