Browse Source

Use api_float_val in order to avoid error when converting text with ","

jmontoyaa 8 years ago
parent
commit
c55d0e6ce1

+ 11 - 9
main/gradebook/gradebook_edit_result.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * Script
  * @package chamilo.gradebook
@@ -11,8 +12,8 @@ $select_eval=Security::remove_XSS($_GET['selecteval']);
 if (empty($select_eval)) {
     api_not_allowed();
 }
-$resultedit = Result :: load (null,null,$select_eval);
-$evaluation = Evaluation :: load ($select_eval);
+$resultedit = Result::load(null, null, $select_eval);
+$evaluation = Evaluation::load($select_eval);
 
 $evaluation[0]->check_lock_permissions();
 
@@ -22,25 +23,26 @@ $edit_result_form = new EvalForm(
     $resultedit,
     'edit_result_form',
     null,
-    api_get_self().'?&selecteval='.$select_eval
+    api_get_self().'?selecteval='.$select_eval.'&'.api_get_cidreq()
 );
-$table = $edit_result_form->toHtml();
 if ($edit_result_form->validate()) {
     $values = $edit_result_form->exportValues();
-    $scores = ($values['score']);
+    $scores = $values['score'];
     foreach ($scores as $row) {
         $resultedit = Result:: load(key($scores));
         $row_value = $row;
-        if ($row_value != '' ) {
+        if ($row_value != '') {
             $resultedit[0]->set_score(api_number_format($row_value, api_get_setting('gradebook_number_decimals')));
             $resultedit[0]->save();
         }
-        next($scores);
     }
-    header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&editallresults=&'.api_get_cidreq());
+    Display::addFlash(Display::return_message(get_lang('AllResultsEdited')));
+    header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq());
     exit;
 }
 
+$table = $edit_result_form->toHtml();
+
 $interbreadcrumb[] = array (
     'url' => $_SESSION['gradebook_dest'],
     'name' => get_lang('Gradebook')
@@ -49,7 +51,7 @@ $interbreadcrumb[]= array (
     'url' => 'gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
     'name' => get_lang('ViewResult')
 );
-Display :: display_header(get_lang('EditResult'));
+Display::display_header(get_lang('EditResult'));
 DisplayGradebook::display_header_result($evaluation[0], null, 0, 0);
 echo $table;
 Display :: display_footer();

+ 1 - 1
main/gradebook/lib/GradebookUtils.php

@@ -79,7 +79,7 @@ class GradebookUtils
         if (!empty($link_id)) {
             $link_id = intval($link_id);
             $sql = 'UPDATE ' . Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK) . '
-                    SET weight = ' . "'" . Database::escape_string((float) $weight) . "'" . '
+                    SET weight = ' . "'" . api_float_val($weight) . "'" . '
                     WHERE course_code = "' . $course_code . '" AND id = ' . $link_id;
             Database::query($sql);
         }

+ 3 - 2
main/gradebook/lib/be/forumthreadlink.class.php

@@ -357,11 +357,12 @@ class ForumThreadLink extends AbstractLink
 
 	function save_linked_data()
 	{
-		$weight = (float)$this->get_weight();
+		$weight = api_float_val($this->get_weight());
 		$ref_id = $this->get_ref_id();
 
 		if (!empty($ref_id)) {
-			$sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.'
+			$sql = 'UPDATE '.$this->get_forum_thread_table().' SET 
+			        thread_weight='.$weight.'
                     WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id;
 			Database::query($sql);
 		}

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

@@ -423,7 +423,7 @@ class StudentPublicationLink extends AbstractLink
         }
         $id = $data['id'];
 
-        $weight = (float) $this->get_weight();
+        $weight = api_float_val($this->get_weight());
         if (!empty($id)) {
             //Cleans works
             $sql = 'UPDATE '.$this->get_studpub_table().'