Laurent Opprecht 12 years ago
parent
commit
7f2f4c0737

+ 4 - 61
main/css/base.css

@@ -3970,7 +3970,6 @@ footer {
     padding-left: 25px;
     box-shadow:none;
 }
-
 .btn.show{
     border:none;
     border-radius: 0;
@@ -4031,66 +4030,6 @@ footer {
     box-shadow:none;
 }
 
-.btn.new_folder{
-    border:none;
-    border-radius: 0;
-    background-color: transparent;
-    width:32px;
-    height:32px;
-    margin:0;
-    padding:0;
-    display:inline-block;
-    background-image:  url('../img/icons/32/new_folder.png');
-    background-repeat: no-repeat;
-    background-position:center center; 
-    box-shadow:none;
-}
-
-.btn.new_link{
-    border:none;
-    border-radius: 0;
-    background-color: transparent;
-    width:32px;
-    height:32px;
-    margin:0;
-    padding:0;
-    display:inline-block;
-    background-image:  url('../img/icons/32/new_link.png');
-    background-repeat: no-repeat;
-    background-position:center center; 
-    box-shadow:none;
-}
-
-.btn.expand{
-    border:none;
-    border-radius: 0;
-    background-color: transparent;
-    width:32px;
-    height:32px;
-    margin:0;
-    padding:0;
-    display:inline-block;
-    background-image:  url('../img/div_hide.gif');
-    background-repeat: no-repeat;
-    background-position:center center; 
-    box-shadow:none;
-}
-
-.btn.collapse{
-    border:none;
-    border-radius: 0;
-    background-color: transparent;
-    width:32px;
-    height:32px;
-    margin:0;
-    padding:0;
-    display:inline-block;
-    background-image:  url('../img/div_show.gif');
-    background-repeat: no-repeat;
-    background-position:center center; 
-    box-shadow:none;
-}
-
 .announce.btn.delete-all{
     border:none;
     border-radius: 0;
@@ -4186,6 +4125,10 @@ li.annoucement{
     display:inline-block;
 }
 
+.boot-tooltip {
+    cursor: pointer;
+}
+
 .link_category{
     background-color: #FFFFFF;
     margin-bottom: 5px;

+ 3 - 1
main/gradebook/gradebook_add_eval.php

@@ -49,7 +49,9 @@ if ($form->validate()) {
     
     $parent_cat = Category :: load($values['hid_category_id']);            
     $global_weight = $cat[0]->get_weight();
-    $values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();    
+    //$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();    
+    $values['weight'] = $values['weight_mask'];
+    
     
 	$eval->set_weight($values['weight']);	
 	$eval->set_max($values['max']);

+ 3 - 3
main/gradebook/gradebook_add_link.php

@@ -72,9 +72,9 @@ if (isset($_GET['typeselected']) && $_GET['typeselected'] != '0') {
         $parent_cat = Category :: load($addvalues['select_gradebook']);            
         $global_weight = $category[0]->get_weight();
         
-        $addvalues['weight'] = $addvalues['weight_mask']/$global_weight*$parent_cat[0]->get_weight();    
-    
-		$link->set_weight($addvalues['weight']);
+        //$addvalues['weight'] = $addvalues['weight_mask']/$global_weight*$parent_cat[0]->get_weight();    
+        
+		$link->set_weight($addvalues['weight_mask']);
 
 		if ($link->needs_max()) {
 			$link->set_max($addvalues['max']);

+ 1 - 4
main/gradebook/gradebook_statistics.php

@@ -77,9 +77,7 @@ if (!$displayscore->is_custom() || empty($displays)) {
 		}
 	}
 
-
 	// Generate table
-
 	$stattable= '<table class="data_table" cellspacing="0" cellpadding="3">';
 	$stattable .= '<tr><th>' . get_lang('ScoringSystem') . '</th>';
     $stattable .= '<th>' . get_lang('Percentage') . '</th>';
@@ -92,8 +90,7 @@ if (!$displayscore->is_custom() || empty($displays)) {
 		$stattable .= '<td width="150">' . $key . '</td>';
         
 		$stattable .= '<td width="550">'.Display::bar_progress($bar).'</td>';
-		$stattable .= '<td align="right">' . $nr_items[$key] . '</td>';
-		//$stattable .= '<td align="right"> ' . ($resultcount > 0 ?round(($nr_items[$key] / $resultcount) * 100,2):0) . '%</td>';
+		$stattable .= '<td align="right">' . $nr_items[$key] . '</td>';		
 		$counter++;
 	}
 	$stattable .= '</tr></table>';

+ 14 - 17
main/gradebook/index.php

@@ -731,6 +731,7 @@ if ($category != '0') {
 	$category_id   = intval($_GET['selectcat']);
 	$course_id     = Database::get_course_by_category($category_id);
 	$show_message  = $cat->show_message_resource_delete($course_id);
+    
 	if ($show_message=='') {
 
 		//student
@@ -743,8 +744,8 @@ if ($category != '0') {
 			$alllink_course  = $cats_course[0]->get_links($stud_id,true);
 			
 			$evals_links = array_merge($alleval_course, $alllink_course);
-			$item_value=0;
-			$item_total=0;
+			$item_value = 0;
+			$item_total = 0;
             
             //@todo move these in a function            
             $sum_categories_weight_array = array();     
@@ -768,34 +769,30 @@ if ($category != '0') {
 				
 				$score_denom    = ($score[1]==0) ? 1 : $score[1];
 				$item_value     = $score[0]/$score_denom*$item->get_weight();
-                        
-                $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
-                $percentage     = round($item->get_weight()/($sub_cat_percentage) *  $sub_cat_percentage/$cats_course[0]->get_weight(), 2);
                 
                 $item_total         += $item->get_weight();                
                 $item_total_value   += $item_value;                                
 			}			
                         
-		    $item_total_value = (float)$item_total_value;
-            
+		    $item_total_value = (float)$item_total_value;            
 			
 			$cattotal = Category :: load($category_id);
-            //echo 'start';            
+            
 			$scoretotal= $cattotal[0]->calc_score(api_get_user_id());            
 					
-			//Do not remove this the gradebook/lib/fe/gradebooktable.class.php file load this variable as a global 		
-			$my_score_in_gradebook =  round($scoretotal[0],2);
+			//Do not remove this the gradebook/lib/fe/gradebooktable.class.php file load this variable as a global
+            $scoredisplay = ScoreDisplay :: instance();
+            
+			//$my_score_in_gradebook =  round($scoretotal[0],2);
+            $my_score_in_gradebook = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
 			
 			//Show certificate
-			$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
+			$certificate_min_score = $cats[0]->get_certificate_min_score();	            		
+			
+			$scoretotal_display = $scoredisplay->display_score($scoretotal, SCORE_DIV_PERCENT); //a student always sees only the teacher's repartition
 			//var_dump($certificate_min_score, $item_total_value);
 			if (isset($certificate_min_score) && $item_total_value >= $certificate_min_score) {
-			    
-				$my_certificate = get_certificate_by_user_id($cats[0]->get_id(), api_get_user_id());
-								
+				$my_certificate = get_certificate_by_user_id($cats[0]->get_id(), api_get_user_id());								
 				if (empty($my_certificate)) {
 					register_user_info_about_certificate($category_id, api_get_user_id(), $my_score_in_gradebook, api_get_utc_datetime());
 					$my_certificate = get_certificate_by_user_id($cats[0]->get_id(), api_get_user_id());

+ 3 - 6
main/gradebook/lib/fe/displaygradebook.php

@@ -401,16 +401,13 @@ class DisplayGradebook
                 
                 $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
                 
-                $item_value     = round($score[0]/$divide, 2);
+                $item_value     = $score[0]/$divide;
                 //$item_value     = $item_value*$item->get_weight();
-                $item_value     =round($score[0]/$divide*$item->get_weight(),2)*$sub_cat_percentage/$main_weight;      
+                $item_value     = $score[0]/$divide*$item->get_weight()*$sub_cat_percentage/$main_weight;
                 //var_dump($score[0].' '.$divide.' '.$item->get_weight().' - '.$item_value.' '.$sub_cat_percentage);
                 $item_value_total +=$item_value;
-			}
-            
+			}            
             $item_total = $main_weight;
-            
-            $item_total = round($item_total);
 			$total_score = array($item_value_total, $item_total);       
 			$scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
 

+ 8 - 6
main/gradebook/lib/fe/evalform.class.php

@@ -234,6 +234,7 @@ class EvalForm extends FormValidator
 		}
 		$this->addElement('style_submit_button' , 'submit', get_lang('Ok'),'class="save"');
 	}
+    
 	/**
 	 * Builds a result form containing inputs for all students with a given course_code
 	 */
@@ -377,6 +378,7 @@ class EvalForm extends FormValidator
 		}
 		$this->addElement('style_submit_button', 'submit', get_lang('AddAssessment'),'class="add"');
 	}
+    
 	/**
 	 * Builds a form to edit an evaluation
 	 */
@@ -389,6 +391,7 @@ class EvalForm extends FormValidator
             $global_weight = $cat[0]->get_weight();                
             $weight_mask = $global_weight*$this->evaluation_object->get_weight()/$parent_cat[0]->get_weight() ;
         }
+        $weight_mask = $this->evaluation_object->get_weight();
             
 		$this->setDefaults(array (	'hid_id'            => $this->evaluation_object->get_id(), 
 									'name'              => $this->evaluation_object->get_name(), 
@@ -419,13 +422,13 @@ class EvalForm extends FormValidator
 
 		$this->addElement('header', $form_title);
 		$this->addElement('hidden', 'zero', 0);
-		$this->addElement('hidden', 'hid_user_id');
-		
+		$this->addElement('hidden', 'hid_user_id');		
 		$this->addElement('hidden', 'hid_course_code');
+        
 		$this->add_textfield('name', get_lang('EvaluationName'), true, array (
-			'class' => 'span3',
-			'maxlength' => '50',
-			'id' => 'evaluation_title'
+			'class'         => 'span3',
+			'maxlength'     => '50',
+			'id'            => 'evaluation_title'
 		));
         
         $cat_id = $this->evaluation_object->get_category_id();
@@ -522,7 +525,6 @@ class EvalForm extends FormValidator
 		parent :: setDefaults($defaults);
 	}
 
-
 	private function build_stud_label ($id, $username,$lastname, $firstname) {
 		$opendocurl_start = '';
 		$opendocurl_end = '';

+ 38 - 22
main/gradebook/lib/fe/gradebooktable.class.php

@@ -22,6 +22,7 @@ class GradebookTable extends SortableTable {
 	private $currentcat;
 	private $datagen;
 	private $evals_links;
+    public  $cats;
 
 	/**
 	 * Constructor
@@ -31,7 +32,7 @@ class GradebookTable extends SortableTable {
     	parent :: __construct ('gradebooklist', null, null, (api_is_allowed_to_edit()?1:0));
 		$this->evals_links = array_merge($evals, $links);
 		$this->currentcat = $currentcat;
-		
+        $this->cats = $cats;		
 		$this->datagen = new GradebookDataGenerator($cats, $evals, $links);								
         
 		if (isset($addparams)) {
@@ -53,6 +54,10 @@ class GradebookTable extends SortableTable {
 		} else {
 			$this->set_header($column++, get_lang('Weight'), false);
 			$this->set_header($column++, get_lang('Result'), false);
+                        
+            if (!empty($cats)) {
+                $this->set_header($column++, get_lang('Actions'), false);
+            }            
 		}
 		
 		/*if (api_is_allowed_to_edit(null, true)) {
@@ -138,24 +143,25 @@ class GradebookTable extends SortableTable {
         $session_id     = api_get_session_id();
 		$status_user    = api_get_status_of_user_in_course($user_id, $course_code);
         
-		$data_array  = $this->datagen->get_data($sorting, $from, $this->per_page);		
+		$data_array     = $this->datagen->get_data($sorting, $from, $this->per_page);		
 
 		// generate the data to display
 		$sortable_data = array();
 		$weight_total_links = 0;
         
-        $main_categories = array();
+        $main_categories = array();        
+        $main_cat =  Category :: load(null, null, $course_code, null, null, $session_id, false);
         
-        $main_cat =  Category :: load(null, null, $course_code, null, null, $session_id, false);        		
+        $total_categories_weight = 0;        
+        $scoredisplay = ScoreDisplay :: instance();
         
-        $total_categories_weight = 0;
+        //Categories
         
-        //Looping categories
 		foreach ($data_array as $data) {
 			
             // list of items inside the gradebook (exercises, lps, forums, etc)
 			$row  = array();
-			$item = $data[0];
+			$item = $item_category = $data[0];
 			
 			$id   = $item->get_id();							
 						
@@ -188,8 +194,7 @@ class GradebookTable extends SortableTable {
 			//Weight
 			//$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close;		
             //$average = $data['3']/$this->currentcat->get_weight()*100;
-            
-            $scoredisplay = ScoreDisplay :: instance();            
+                    
             $average = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_PERCENT, SCORE_BOTH, true);
             
             if (api_is_allowed_to_edit(null, true)) {
@@ -204,9 +209,8 @@ class GradebookTable extends SortableTable {
 				$weight_total_links += $data[3];
 			} else {
 				$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'), '.', ' ');                
+                $scoretotal = $cattotal[0]->calc_score(api_get_user_id());                
+                $item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
 			}
 						
 			//Date
@@ -230,12 +234,18 @@ class GradebookTable extends SortableTable {
                     }
 				} 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();
+                    if (!empty($score[1])) {
+                        $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
+                        $score = $score[0]/$score[1]*$item->get_weight();                    
+                        $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE);
+                        $row[] = Display::tip($score, $complete_score);
+                    } else {
+                        $row[] = '-';
+                    }
                     
-                    $row[] = $score.' '.$this->build_edit_column($item);
+                    if (!empty($this->cats)) {
+                        $row[] = $this->build_edit_column($item);
+                    }
                 }
 			}
             
@@ -262,6 +272,8 @@ class GradebookTable extends SortableTable {
                 
 				$total_weight = 0;
                 
+                //Links
+                
 				foreach ($data_array as $data) {
 					$row  = array();
 					$item = $data[0];
@@ -277,6 +289,7 @@ class GradebookTable extends SortableTable {
 					if (api_is_allowed_to_edit(null, true)) {
 						$row[] = $this->build_id_column($item);
 					}
+                    
 					$row[] = $this->build_type_column($item);
 					
 					//Name
@@ -303,8 +316,7 @@ class GradebookTable extends SortableTable {
 					} else {
 						$cattotal   = Category :: load($_GET['selectcat']);
 		                $scoretotal = $cattotal[0]->calc_score(api_get_user_id());                    
-		                $item_value = $scoretotal[0];
-		                $item_value = number_format($item_value, 2, '.', ' ');                        					   				  			   	
+		                $item_value = $scoretotal[0];		                
 					}
 					
 					//Date
@@ -314,7 +326,7 @@ class GradebookTable extends SortableTable {
 					if (api_is_allowed_to_edit(null, true)) {
 						$cat = new Category();
 						$show_message = $cat->show_message_resource_delete($item->get_course_code());
-						if ($show_message===false) {
+						if ($show_message === false) {
 							$row[] = $this->build_edit_column($item); 
 						}
 					} else {
@@ -323,11 +335,15 @@ 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;
+                                $new_score = $data[3]* $score[0] / $score[1];                                                                
+                                $row[] = Display::tip($new_score, $data[4]);
 							}
 						}
+                        if (!empty($cats)) {
+                            $row[] = null;
+                        }
 					}
                     $row['child_of'] = $parent_id;
                     

+ 5 - 12
main/gradebook/lib/fe/linkaddeditform.class.php

@@ -118,20 +118,13 @@ class LinkAddEditForm extends FormValidator
                 $values['weight'] = $link->get_weight();                
             } else {
                 $cat = Category :: load($parent_cat[0]->get_parent_id());
-                $global_weight = $cat[0]->get_weight();
-                $values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
-                /* 
-                 * 33 -> 100 
-                 * x -> 25
-                 */
-                //100 33 25
+                //$global_weight = $cat[0]->get_weight();
+                //$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
                 //var_dump($global_weight, $link->get_weight(), $parent_cat[0]->get_weight());
-                $weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight;
+                //$weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight;
                 //$values['weight'] = $weight;
-                $values['weight'] = $link->get_weight() ;
-                
-            }
-			
+                $values['weight'] = $link->get_weight() ;                
+            }			
             $defaults['weight_mask'] = $values['weight'] ;   
             $defaults['select_gradebook'] = $link->get_category_id();
             

+ 22 - 19
main/gradebook/lib/flatview_data_generator.class.php

@@ -124,8 +124,7 @@ class FlatViewDataGenerator
             if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
                 for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
                     $item = $this->evals_links[$count + $items_start];                    
-                    $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
-                    //$weight = round($item->get_weight()/($sub_cat_percentage)*$sub_cat_percentage/$this->category->get_weight() *100, 2);
+                    $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];                    
                     $weight = 100*$item->get_weight()/$main_weight;                    
                     $headers[] = $item->get_name().' '.$weight.' % ';                
                 }
@@ -307,13 +306,14 @@ class FlatViewDataGenerator
                                 
                 foreach ($allcat as $sub_cat) {
                     $score 			= $sub_cat->calc_score($user_id);
+                    $real_score     = $score;
                     $divide			= ( ($score[1])==0 ) ? 1 : $score[1];      
                     
                     $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
-                    $item_value     = round($score[0]/$divide,2) * $main_weight;
+                    $item_value     = $score[0]/$divide*$main_weight;
 
                     //Fixing total when using one or multiple gradebooks                    
-                    $percentage     = round($sub_cat->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight(), 2);
+                    $percentage     = $sub_cat->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight();
                     $item_value     = $percentage*$item_value;                    
                     $item_total		+= $sub_cat->get_weight();
                     
@@ -323,8 +323,9 @@ class FlatViewDataGenerator
                         $score[1] = $main_weight ;
                     }
                     
-                    //$temp_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);                    
+                    $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);                    
                     $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
+                    $temp_score = Display::tip($temp_score, $real_score);
                     
                     if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
                         if (!$show_all) {
@@ -347,11 +348,11 @@ class FlatViewDataGenerator
                     //sub cat weight
                     $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
 
-                    $item_value     = round($score[0]/$divide, 2);
+                    $item_value     = $score[0]/$divide;
                     
                     //Fixing total when using one or multiple gradebooks 
                     if ($this->category->get_parent_id() == 0 ) {                        
-                        $item_value     =round($score[0]/$divide*$item->get_weight(),2);                    
+                        $item_value     = $score[0]/$divide*$item->get_weight();
                     } else {
                         $item_value     = $item_value*$item->get_weight(); 
                         //var_dump($item_value.' - '.$item->get_weight());
@@ -360,9 +361,13 @@ class FlatViewDataGenerator
                     }
                     
                     $item_total		+= $item->get_weight();                    
-                    //$temp_score     = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
+                    $complete_score     = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
                     //$temp_score     = $item_value.' - '.$scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
-                    $temp_score     = $item_value;                    
+                    //$temp_score     = $item_value;
+                    $temp_score     = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);
+                    
+                    $temp_score = Display::tip($temp_score, $complete_score);
+                    
                     
                     if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
                         if (!$show_all) {                            
@@ -383,9 +388,7 @@ class FlatViewDataGenerator
                     $item_value_total +=$item_value;
                 }
                 $item_total = $main_weight;
-            }
-            
-            $item_total = round($item_total);
+            }            
 			$total_score = array($item_value_total, $item_total);            
             
 			if (!$show_all) {
@@ -425,7 +428,7 @@ class FlatViewDataGenerator
 			for ($count=0;$count < count($this->evals_links); $count++) {
 				$item = $this->evals_links [$count];
 				$score = $item->calc_score($user[0]);				
-				$porcent_score = isset($score[1]) &&  $score[1] > 0 ? round(($score[0]*100)/$score[1]):0;
+				$porcent_score = isset($score[1]) &&  $score[1] > 0 ? ($score[0]*100)/$score[1] :0;
 				$row[$item->get_name()] = $porcent_score;
 			}
 			$data[$user[0]] = $row;
@@ -481,16 +484,16 @@ class FlatViewDataGenerator
 				$score = $item->calc_score($user[0]);
 			
 				$divide =( ($score[1])==0 ) ? 1 : $score[1];
-                $item_value += round($score[0]/$divide*$item->get_weight(),2);
+                $item_value += $score[0]/$divide*$item->get_weight();
 				$item_total += $item->get_weight();
 				
 				
 				$score_denom = ($score[1]==0) ? 1 : $score[1];
-				$score_final = round(($score[0] / $score_denom) * 100,2);
+				$score_final = ($score[0] / $score_denom) * 100;
 				$row[] = $score_final;
 			}
 			$total_score = array($item_value, $item_total);
-			$score_final = round(($item_value / $item_total) * 100,2);
+			$score_final = ($item_value / $item_total) * 100;
 			
 			$row[] = $score_final;
 			$data[] = $row;
@@ -522,15 +525,15 @@ class FlatViewDataGenerator
 				$item = $this->evals_links [$count];
 				$score = $item->calc_score($user[0]);
 				$divide=( ($score[1])==0 ) ? 1 : $score[1];
-				$item_value+=round($score[0]/$divide*$item->get_weight(),2);
+				$item_value+= $score[0]/$divide*$item->get_weight();
 				$item_total+=$item->get_weight();
 				$score_denom=($score[1]==0) ? 1 : $score[1];
-				$score_final = round(($score[0] / $score_denom) * 100,2);
+				$score_final = ($score[0] / $score_denom) * 100;
 				$row[] = array ($score_final, trim($scoredisplay->display_score($score, SCORE_CUSTOM,null, true)));
 
 			}
 			$total_score=array($item_value,$item_total);
-			$score_final = round(($item_value / $item_total) * 100,2);
+			$score_final = ($item_value / $item_total) * 100;
 			$row[] =array ($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
 
 			$data[] = $row;

+ 1 - 0
main/gradebook/lib/gradebook_data_generator.class.php

@@ -89,6 +89,7 @@ class GradebookDataGenerator
 	    $user_id      = api_get_user_id();
 		$course_code  = api_get_course_id();
 		$status_user  = api_get_status_of_user_in_course($user_id, $course_code);
+        
 		// generate the data to display
 		$data = array();
         

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

@@ -14,8 +14,8 @@ define('SCORE_PERCENT',                  2);    // XX %
 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
+define('SCORE_SIMPLE',                   7);    // X
 
 //@todo where is number 6?
 
@@ -25,7 +25,7 @@ define('SCORE_DIV_PERCENT_WITH_CUSTOM',  9);    // X / Y (XX %) - Good!
 define('SCORE_CUSTOM',                  10);    // Good!
 define('SCORE_DIV_SIMPLE_WITH_CUSTOM',  11);    // X - Good!
 
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS',  12);    // X (ex) - Good!
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS',  12);    // X - Good!
 
 define('SCORE_BOTH',1);
 define('SCORE_ONLY_DEFAULT',2);
@@ -246,6 +246,24 @@ class ScoreDisplay
 		}
 		Database::query($sql);
 	}
+    
+    public function get_number_decimals() {
+        $number_decimals = api_get_setting('gradebook_number_decimals');        
+        if (!isset($number_decimals)) {
+            $number_decimals = 0;
+        }        
+        return $number_decimals;
+    }
+    
+    /**
+     * Formats a number depending of the number of decimals
+     * 
+     * @param float a score
+     * @return float the score formatted
+     */
+    public function format_score($score) {        
+        return floatval(number_format($score, $this->get_number_decimals()));
+    }
 
 	/**
 	 * Display a score according to the current settings
@@ -256,12 +274,18 @@ 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 ($type == SCORE_SIMPLE) {   
+            $simple_score = $this->format_score($my_score[0]);
+            return $simple_score;
+        }
+        
 		if ($this->custom_enabled && isset($this->custom_display_conv)) {		    
 	        $display = $this->display_default($my_score, $type);	        
 		} else {
@@ -325,7 +349,7 @@ class ScoreDisplay
 	
 	private function display_simple_score($score) {
 	    if (isset($score[0])) {
-	        return $score[0];
+	        return $this->format_score($score[0]);
 	    }
 	    return '';
 	}
@@ -335,15 +359,15 @@ class ScoreDisplay
      */
 	private function display_as_decimal($score) {
 		$score_denom = ($score[1]==0) ? 1 : $score[1];
-		return round(($score[0]/ $score_denom),2);
+		return $this->format_score($score[0]/$score_denom);
 	}
 	
 	/**
 	 * Returns "100 %" for array("100", "100");
 	 */
 	private function display_as_percent($score) {        
-		$score_denom=($score[1]==0) ? 1 : $score[1];        
-		return round(($score[0] / $score_denom) * 100,2) . ' %';
+		$score_denom = ($score[1]==0) ? 1 : $score[1];        
+		return $this->format_score($score[0]/$score_denom*100) . ' %';
 	}
 	
     /**
@@ -355,16 +379,19 @@ class ScoreDisplay
 		if ($score == 1) {
 			return '0/0';
 		} else {
+            $score[0] =$this->format_score($score[0]);
+            $score[1] =$this->format_score($score[1]);
 			return  $score[0] . ' / ' . $score[1];
 		}
 	}
+    
     /**
      * 
      * Depends in the user selections [0 50] Bad  [50:100] Good 
      * @param array $score
      */	
 	private function display_custom ($score) {
-		$my_score_denom= ($score[1]==0)?1:$score[1];
+		$my_score_denom= ($score[1]==0) ? 1 : $score[1];
 		$scaledscore = $score[0] / $my_score_denom;
 		if ($this->upperlimit_included) {
 			foreach ($this->custom_display_conv as $displayitem) {

+ 11 - 2
main/inc/lib/display.lib.php

@@ -1505,7 +1505,16 @@ class Display {
             }        
             $html .= '</ul></div>';
         }
-        return $html;
-        
+        return $html;        
+    }
+    
+    /**
+     * Prints a tooltip
+     */
+    function tip($text, $tip)  {
+        if (empty($tip)) {
+            return $text;
+        }
+        return self::span($text, array('class' => 'boot-tooltip', 'title' => $tip));
     }
 } //end class Display

+ 6 - 0
main/template/default/layout/footer.tpl

@@ -72,6 +72,12 @@ $(document).ready( function() {
             $(this).parentsUntil("tr").parent().removeClass("row_selected");
         }    
     });
+
+    var tip_options = {
+            placement : 'right',
+    }
+
+    $('.boot-tooltip').tooltip(tip_options);
 });
 </script>
 {% endraw %}