### Eclipse Workspace Patch 1.0
#P moodle
Index: enrol/paypal/ipn.php
===================================================================
RCS file: /cvsroot/moodle/moodle/enrol/paypal/ipn.php,v
retrieving revision 1.19
diff -u -r1.19 ipn.php
--- enrol/paypal/ipn.php	28 Feb 2007 06:25:27 -0000	1.19
+++ enrol/paypal/ipn.php	10 Aug 2007 08:28:51 -0000
@@ -147,9 +147,9 @@
             } else {
                 $cost = (float) $course->cost;
             }
-            $cost = format_float($cost, 2);
 
             if ($data->payment_gross < $cost) {
+                $cost = format_float($cost, 2);
                 email_paypal_error_to_admin("Amount paid is not enough ($data->payment_gross < $cost))", $data);
                 die;
 
Index: enrol/paypal/enrol.php
===================================================================
RCS file: /cvsroot/moodle/moodle/enrol/paypal/enrol.php,v
retrieving revision 1.26
diff -u -r1.26 enrol.php
--- enrol/paypal/enrol.php	18 Dec 2006 19:21:11 -0000	1.26
+++ enrol/paypal/enrol.php	10 Aug 2007 08:28:51 -0000
@@ -22,8 +22,6 @@
     } else {
         $cost = (float) $course->cost;
     }
-    $cost = format_float($cost, 2);
-
 
     if (abs($cost) < 0.01) { // no cost, default to base class entry to course
 
Index: mod/lesson/report.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/lesson/report.php,v
retrieving revision 1.36
diff -u -r1.36 report.php
--- mod/lesson/report.php	11 Jun 2007 11:25:26 -0000	1.36
+++ mod/lesson/report.php	10 Aug 2007 08:29:04 -0000
@@ -266,12 +266,12 @@
         if ($numofattempts == 0) {
             $avescore = get_string("notcompleted", "lesson");
         } else {
-            $avescore = format_float($avescore/$numofattempts, 2, ".", ",");
+            $avescore = format_float($avescore/$numofattempts, 2);
         }
         if ($avetime == NULL) {
             $avetime = get_string("notcompleted", "lesson");
         } else {
-            $avetime = format_float($avetime/$numofattempts, 0, ".", ",");
+            $avetime = format_float($avetime/$numofattempts, 0);
             $avetime = format_time($avetime);
         }
         if ($hightime == NULL) {
Index: grade/edit/tree/item.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/edit/tree/item.php,v
retrieving revision 1.9
diff -u -r1.9 item.php
--- grade/edit/tree/item.php	9 Aug 2007 16:19:06 -0000	1.9
+++ grade/edit/tree/item.php	10 Aug 2007 08:28:52 -0000
@@ -32,24 +32,41 @@
         $url = $CFG->wwwroot.'/grade/edit/tree/outcomeitem.php?id='.$id.'&amp;courseid='.$courseid;
         redirect($gpr->add_url_params($url));
     }
+    // Get Item preferences
+    $item->pref_gradedisplaytype = grade_report::get_pref('gradedisplaytype', $item->id);
+    $item->pref_decimalpoints    = grade_report::get_pref('decimalpoints', $item->id);
 
-    if ($item->hidden > 1) {
-        $item->hiddenuntil = $item->hidden;
-        $item->hidden = 0;
-    } else {
-        $item->hiddenuntil = 0;
-    }
+    $item->calculation = grade_item::denormalize_formula($item->calculation, $course->id);
 
-    $item->locked = !empty($item->locked);
+    $decimalpoints = grade_report::get_pref('decimalpoints', $item->id);
 
+} else {
+    $item = new grade_item(array('courseid'=>$courseid, 'itemtype'=>'manual'));
     // Get Item preferences
-    $item->pref_gradedisplaytype = grade_report::get_pref('gradedisplaytype', $id);
-    $item->pref_decimalpoints    = grade_report::get_pref('decimalpoints', $id);
+    $item->pref_gradedisplaytype = grade_report::get_pref('gradedisplaytype');
+    $item->pref_decimalpoints    = grade_report::get_pref('decimalpoints');
 
-    $item->calculation = grade_item::denormalize_formula($item->calculation, $course->id);
-    $mform->set_data($item);
+    $decimalpoints = grade_report::get_pref('decimalpoints');
+}
+
+if ($item->hidden > 1) {
+    $item->hiddenuntil = $item->hidden;
+    $item->hidden = 0;
+} else {
+    $item->hiddenuntil = 0;
 }
 
+$item->locked = !empty($item->locked);
+
+$item->grademax        = format_float($item->grademax, $decimalpoints);
+$item->grademin        = format_float($item->grademin, $decimalpoints);
+$item->gradepass       = format_float($item->gradepass, $decimalpoints);
+$item->multfactor      = format_float($item->multfactor, 4);
+$item->plusfactor      = format_float($item->plusfactor, 4);
+$item->aggregationcoef = format_float($item->aggregationcoef, 4);
+
+$mform->set_data($item);
+
 if ($data = $mform->get_data(false)) {
     if (array_key_exists('calculation', $data)) {
         $data->calculation = grade_item::normalize_formula($data->calculation, $course->id);
@@ -65,6 +82,13 @@
     unset($data->locked);
     unset($data->locktime);
 
+    $convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef');
+    foreach ($convert as $param) {
+        if (array_key_exists($param, $data)) {
+            $data->$param = unformat_float($data->$param);
+        }
+    }
+
     $grade_item = new grade_item(array('id'=>$id, 'courseid'=>$courseid));
     grade_item::set_properties($grade_item, $data);
 
Index: grade/edit/tree/grade_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/edit/tree/grade_form.php,v
retrieving revision 1.8
diff -u -r1.8 grade_form.php
--- grade/edit/tree/grade_form.php	9 Aug 2007 16:19:08 -0000	1.8
+++ grade/edit/tree/grade_form.php	10 Aug 2007 08:28:52 -0000
@@ -78,6 +78,8 @@
         $mform->setHelpButton('feedbackformat', array('textformat', get_string('helpformatting')));
 
         // hidden params
+        $mform->addElement('hidden', 'oldgrade');
+
         $mform->addElement('hidden', 'id', 0);
         $mform->setType('id', PARAM_INT);
 
Index: grade/edit/tree/grade.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/edit/tree/grade.php,v
retrieving revision 1.10
diff -u -r1.10 grade.php
--- grade/edit/tree/grade.php	9 Aug 2007 16:19:07 -0000	1.10
+++ grade/edit/tree/grade.php	10 Aug 2007 08:28:52 -0000
@@ -2,6 +2,7 @@
 
 require_once '../../../config.php';
 require_once $CFG->dirroot.'/grade/lib.php';
+require_once $CFG->dirroot.'/grade/report/lib.php';
 require_once 'grade_form.php';
 
 $courseid = required_param('courseid', PARAM_INT);
@@ -103,6 +104,20 @@
         $grade->locked = 1;
     }
 
+    // normalize the final grade value
+    if ($grade_item->gradetype == GRADE_TYPE_SCALE) {
+        if (empty($grade->finalgrade)) {
+            $grade->finalgrade = -1;
+        } else {
+            $grade->finalgrade = (int)$grade->finalgrade;
+        }
+    } else if ($grade_item->gradetype == GRADE_TYPE_VALUE) {
+        $decimalpoints = grade_report::get_pref('decimalpoints', $grade_item->id);
+        $grade->finalgrade = format_float($grade->finalgrade, $decimalpoints);
+    }
+
+    $grade->oldgrade = $grade->finalgrade;
+
     $mform->set_data($grade);
 
 } else {
@@ -117,11 +132,14 @@
     $old_grade_grade = new grade_grade(array('userid'=>$data->userid, 'itemid'=>$grade_item->id), true); //might not exist yet
 
     // fix no grade for scales
-    if (!isset($data->finalgrade)) {
+    if (!isset($data->finalgrade) or $data->finalgrade == $data->oldgrade) {
         $data->finalgrade = $old_grade_grade->finalgrade;
 
     } else if ($grade_item->gradetype == GRADE_TYPE_SCALE and $data->finalgrade < 1) {
         $data->finalgrade = NULL;
+
+    } else if ($grade_item->gradetype == GRADE_TYPE_VALUE) {
+        $data->finalgrade = unformat_float($data->finalgrade);
     }
 
     if (!isset($data->feedback)) {
Index: grade/edit/tree/item_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/edit/tree/item_form.php,v
retrieving revision 1.10
diff -u -r1.10 item_form.php
--- grade/edit/tree/item_form.php	9 Aug 2007 16:19:07 -0000	1.10
+++ grade/edit/tree/item_form.php	10 Aug 2007 08:28:52 -0000
@@ -49,39 +49,33 @@
         $mform->setHelpButton('grademax', array(false, get_string('grademax', 'grades'),
                 false, true, false, get_string('grademaxhelp', 'grades')));
         $mform->disabledIf('grademax', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
-        $mform->setDefault('grademax', 100.0);
 
         $mform->addElement('text', 'grademin', get_string('grademin', 'grades'));
         $mform->setHelpButton('grademin', array(false, get_string('grademin', 'grades'),
                 false, true, false, get_string('grademinhelp', 'grades')));
         $mform->disabledIf('grademin', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
-        $mform->setDefault('grademin', 0.0);
 
         $mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
         $mform->setHelpButton('gradepass', array(false, get_string('gradepass', 'grades'),
                 false, true, false, get_string('gradepasshelp', 'grades')));
         $mform->disabledIf('gradepass', 'gradetype', 'eq', GRADE_TYPE_NONE);
         $mform->disabledIf('gradepass', 'gradetype', 'eq', GRADE_TYPE_TEXT);
-        $mform->setDefault('gradepass', 0.0);
 
         $mform->addElement('text', 'multfactor', get_string('multfactor', 'grades'));
         $mform->setHelpButton('multfactor', array(false, get_string('multfactor', 'grades'),
                 false, true, false, get_string('multfactorhelp', 'grades')));
         $mform->disabledIf('multfactor', 'gradetype', 'eq', GRADE_TYPE_NONE);
         $mform->disabledIf('multfactor', 'gradetype', 'eq', GRADE_TYPE_TEXT);
-        $mform->setDefault('multfactor', 1.0);
 
         $mform->addElement('text', 'plusfactor', get_string('plusfactor', 'grades'));
         $mform->setHelpButton('plusfactor', array(false, get_string('plusfactor', 'grades'),
                 false, true, false, get_string('plusfactorhelp', 'grades')));
         $mform->disabledIf('plusfactor', 'gradetype', 'eq', GRADE_TYPE_NONE);
         $mform->disabledIf('plusfactor', 'gradetype', 'eq', GRADE_TYPE_TEXT);
-        $mform->setDefault('plusfactor', 0.0);
 
         $mform->addElement('text', 'aggregationcoef', get_string('aggregationcoef', 'grades'));
         $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoef', 'grades'),
                 false, true, false, get_string('aggregationcoefhelp', 'grades')));
-        $mform->setDefault('aggregationcoef', 0.0);
 
         /// hiding
         /// advcheckbox is not compatible with disabledIf !!
Index: grade/edit/tree/calculation.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/edit/tree/calculation.php,v
retrieving revision 1.5
diff -u -r1.5 calculation.php
--- grade/edit/tree/calculation.php	3 Aug 2007 08:12:09 -0000	1.5
+++ grade/edit/tree/calculation.php	10 Aug 2007 08:28:51 -0000
@@ -2,6 +2,7 @@
 
 require_once '../../../config.php';
 require_once $CFG->dirroot.'/grade/lib.php';
+require_once $CFG->libdir.'/mathslib.php';
 require_once 'calculation_form.php';
 
 $courseid = required_param('courseid', PARAM_INT);
@@ -36,11 +37,13 @@
 
 }
 
-$calculation = grade_item::denormalize_formula($grade_item->calculation, $grade_item->courseid);
+$calculation = calc_formula::localize($grade_item->calculation);
+$calculation = grade_item::denormalize_formula($calculation, $grade_item->courseid);
 $mform->set_data(array('courseid'=>$grade_item->courseid, 'calculation'=>$calculation, 'id'=>$grade_item->id, 'itemname'=>$grade_item->itemname));
 
 if ($data = $mform->get_data(false)) {
-    $grade_item->set_calculation($data->calculation);
+    $calculation = calc_formula::unlocalize($data->calculation);
+    $grade_item->set_calculation($calculation);
     redirect($returnurl);
 }
 
Index: grade/edit/tree/calculation_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/edit/tree/calculation_form.php,v
retrieving revision 1.3
diff -u -r1.3 calculation_form.php
--- grade/edit/tree/calculation_form.php	2 Aug 2007 11:07:49 -0000	1.3
+++ grade/edit/tree/calculation_form.php	10 Aug 2007 08:28:51 -0000
@@ -130,7 +130,8 @@
         // check the calculation formula
         if ($data['calculation'] != '') {
             $grade_item = grade_item::fetch(array('id'=>$data['id'], 'courseid'=>$data['courseid']));
-            $result = $grade_item->validate_formula(stripslashes($data['calculation']));
+            $calculation = calc_formula::unlocalize(stripslashes($data['calculation']));
+            $result = $grade_item->validate_formula($calculation);
             if ($result !== true) {
                 $errors['calculation'] = $result;
             }
Index: grade/edit/tree/outcomeitem_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/edit/tree/outcomeitem_form.php,v
retrieving revision 1.10
diff -u -r1.10 outcomeitem_form.php
--- grade/edit/tree/outcomeitem_form.php	9 Aug 2007 16:19:07 -0000	1.10
+++ grade/edit/tree/outcomeitem_form.php	10 Aug 2007 08:28:53 -0000
@@ -48,8 +48,13 @@
 
         //$mform->addElement('text', 'calculation', get_string('calculation', 'grades'));
 
+        /*$mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
+        $mform->setHelpButton('gradepass', array(false, get_string('gradepass', 'grades'),
+                false, true, false, get_string('gradepasshelp', 'grades')));*/
+
         $mform->addElement('text', 'aggregationcoef', get_string('aggregationcoef', 'grades'));
-        $mform->setDefault('aggregationcoef', 0.0);
+        $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoef', 'grades'),
+                false, true, false, get_string('aggregationcoefhelp', 'grades')));
 
         /// hiding
         /// advcheckbox is not compatible with disabledIf !!
Index: grade/edit/tree/outcomeitem.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/edit/tree/outcomeitem.php,v
retrieving revision 1.10
diff -u -r1.10 outcomeitem.php
--- grade/edit/tree/outcomeitem.php	9 Aug 2007 16:19:07 -0000	1.10
+++ grade/edit/tree/outcomeitem.php	10 Aug 2007 08:28:53 -0000
@@ -33,18 +33,14 @@
         $url = $CFG->wwwroot.'/grade/edit/tree/item.php?id='.$id.'&amp;courseid='.$courseid;
         redirect($gpr->add_url_params($url));
     }
-
-    if ($item->hidden > 1) {
-        $item->hiddenuntil = $item->hidden;
-        $item->hidden = 0;
-    } else {
-        $item->hiddenuntil = 0;
-    }
-
-    $item->locked = !empty($item->locked);
+    // Get Item preferences
+    $item->pref_gradedisplaytype = grade_report::get_pref('gradedisplaytype', $item->id);
+    $item->pref_decimalpoints    = grade_report::get_pref('decimalpoints', $item->id);
 
     $item->calculation = grade_item::denormalize_formula($item->calculation, $course->id);
 
+    $decimalpoints = grade_report::get_pref('decimalpoints', $item->id);
+
     if ($item->itemtype == 'mod') {
         $cm = get_coursemodule_from_instance($item->itemmodule, $item->iteminstance, $item->courseid);
         $item->cmid = $cm->id;
@@ -52,9 +48,32 @@
         $item->cmid = 0;
     }
 
-    $mform->set_data($item);
+} else {
+    $item = new grade_item(array('courseid'=>$courseid, 'itemtype'=>'manual'));
+    // Get Item preferences
+    $item->pref_gradedisplaytype = grade_report::get_pref('gradedisplaytype');
+    $item->pref_decimalpoints    = grade_report::get_pref('decimalpoints');
+
+    $decimalpoints = grade_report::get_pref('decimalpoints');
+
+    $item->cmid = 0;
+}
+
+if ($item->hidden > 1) {
+    $item->hiddenuntil = $item->hidden;
+    $item->hidden = 0;
+} else {
+    $item->hiddenuntil = 0;
 }
 
+$item->locked = !empty($item->locked);
+
+$item->gradepass       = format_float($item->gradepass, $decimalpoints);
+$item->aggregationcoef = format_float($item->aggregationcoef, 4);
+
+$mform->set_data($item);
+
+
 if ($data = $mform->get_data(false)) {
     if (array_key_exists('calculation', $data)) {
         $data->calculation = grade_item::normalize_formula($data->calculation, $course->id);
@@ -70,6 +89,13 @@
     unset($data->locked);
     unset($data->locktime);
 
+    $convert = array('gradepass', 'aggregationcoef');
+    foreach ($convert as $param) {
+        if (array_key_exists($param, $data)) {
+            $data->$param = unformat_float($data->$param);
+        }
+    }
+
     $grade_item = new grade_item(array('id'=>$id, 'courseid'=>$courseid));
     grade_item::set_properties($grade_item, $data);
 
Index: enrol/authorize/locallib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/enrol/authorize/locallib.php,v
retrieving revision 1.53
diff -u -r1.53 locallib.php
--- enrol/authorize/locallib.php	1 Mar 2007 06:57:11 -0000	1.53
+++ enrol/authorize/locallib.php	10 Aug 2007 08:28:51 -0000
@@ -315,12 +315,12 @@
         if ($refund = get_record_sql($sql)) {
             $extra->sum = floatval($refund->refunded);
         }
-        $upto = format_float($order->amount - $extra->sum, 2);
+        $upto = round($order->amount - $extra->sum, 2);
         if ($upto <= 0) {
             error("Refunded to original amount.");
         }
         else {
-            $amount = format_float(optional_param('amount', $upto), 2);
+            $amount = round(optional_param('amount', $upto), 2);
             if (($amount > $upto) or empty($confirm)) {
                 $a = new stdClass;
                 $a->upto = $upto;
Index: enrol/authorize/config_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/enrol/authorize/config_form.php,v
retrieving revision 1.3
diff -u -r1.3 config_form.php
--- enrol/authorize/config_form.php	9 Feb 2007 07:47:14 -0000	1.3
+++ enrol/authorize/config_form.php	10 Aug 2007 08:28:50 -0000
@@ -26,7 +26,7 @@
     $frm->an_cutoff_hour = $hrs; $frm->an_cutoff_min = $mins;
 }
 if (!isset($frm->an_cutoff_hour)) {
-    $timezone = format_float(get_user_timezone_offset(), 1);
+    $timezone = round(get_user_timezone_offset(), 1);
     $frm->an_cutoff_hour = intval($timezone);
     $frm->an_cutoff_min = (intval(round($timezone)) != intval($timezone)) ? 35 : 5;
 }
Index: grade/report/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/report/lib.php,v
retrieving revision 1.20
diff -u -r1.20 lib.php
--- grade/report/lib.php	6 Aug 2007 08:10:37 -0000	1.20
+++ grade/report/lib.php	10 Aug 2007 08:28:53 -0000
@@ -201,60 +201,6 @@
     }
 
     /**
-     * format grade using lang specific decimal point and thousand separator
-     * the result is suitable for printing on html page
-     * @static
-     * @param float $gradeval raw grade value pulled from db
-     * @param int $decimalpoints Optional integers to override global decimalpoints preference
-     * @return string $gradeval formatted grade value
-     */
-    function get_grade_clean($gradeval, $decimalpoints=null) {
-        global $CFG;
-
-        if (is_null($gradeval)) {
-            $gradeval = '';
-        } else {
-            // decimal points as specified by user
-            if (is_null($decimalpoints)) {
-                $decimalpoints = $this->get_pref('decimalpoints');
-            }
-            $gradeval = number_format($gradeval, $decimalpoints, $this->get_lang_string('decpoint', 'langconfig'),
-                                      $this->get_lang_string('thousandsep', 'langconfig'));
-        }
-
-        return $gradeval;
-
-        /*
-        // commenting this out, if this is added, we also need to find the number of decimal place preserved
-        // so it can go into number_format
-        if ($gradeval != 0) {
-            $gradeval = rtrim(trim($gradeval, "0"), ".");
-        } else {
-            $gradeval = 0;
-        }
-        */
-
-    }
-
-    /**
-     * Given a user input grade, format it to standard format i.e. no thousand separator, and . as decimal point
-     * @static
-     * @param string $gradeval grade value from user input, language specific format
-     * @return string - grade value for storage, en format
-     */
-    function format_grade($gradeval) {
-
-        $decimalpt = $this->get_lang_string('decpoint', 'langconfig');
-        $thousandsep = $this->get_lang_string('thousandsep', 'langconfig');
-        // replace decimal point with '.';
-        $gradeval = str_replace($decimalpt, '.', $gradeval);
-        // thousand separator is not useful
-        $gradeval = str_replace($thousandsep, '', $gradeval);
-
-        return clean_param($gradeval, PARAM_NUMBER);
-    }
-
-    /**
      * First checks the cached language strings, then returns match if found, or uses get_string()
      * to get it from the DB, caches it then returns it.
      * @param string $strcode
Index: lib/moodlelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v
retrieving revision 1.916
diff -u -r1.916 moodlelib.php
--- lib/moodlelib.php	9 Aug 2007 21:51:06 -0000	1.916
+++ lib/moodlelib.php	10 Aug 2007 08:29:03 -0000
@@ -4442,7 +4442,7 @@
     global $CFG;
 
 /// originally these special strings were stored in moodle.php now we are only in langconfig.php
-    $langconfigstrs = array('alphabet', 'backupnameformat', 'firstdayofweek', 'locale',
+    $langconfigstrs = array('alphabet', 'backupnameformat', 'decsep', 'firstdayofweek', 'listsep', 'locale',
                             'localewin', 'localewincharset', 'oldcharset',
                             'parentlanguage', 'strftimedate', 'strftimedateshort', 'strftimedatetime',
                             'strftimedaydate', 'strftimedaydatetime', 'strftimedayshort', 'strftimedaytime',
@@ -5909,14 +5909,36 @@
 }
 
 /**
- * Given a float, prints it nicely
+ * Given a float, prints it nicely.
+ * Do NOT use the result in any calculation later!
  *
- * @param float $num The float to print
+ * @param float $flaot The float to print
  * @param int $places The number of decimal places to print.
- * @return string
+ * @return string locale float
+ */
+function format_float($float, $decimalpoints=1) {
+    if (is_null($float)) {
+        return '';
+    }
+    return number_format($float, $decimalpoints, get_string('decsep'), '');
+}
+
+/**
+ * Convers locale specific floating point/comma number back to standard PHP float value
+ * Do NOT try to do any math operations before this conversion on any user submitted floats!
+ *
+ * @param  string $locale_float locale aware flaot represenation
  */
-function format_float($num, $places=1) {
-    return sprintf("%.$places"."f", $num);
+function unformat_float($locale_float) {
+    $locale_float = trim($locale_float);
+
+    if ($locale_float == '') {
+        return null;
+    }
+
+    $locale_float = str_replace(' ', '', $locale_float); // no spaces - those might be used as thousand separators
+
+    return (float)str_replace(get_string('decsep'), '.', $locale_float);
 }
 
 /**
Index: lib/mathslib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/mathslib.php,v
retrieving revision 1.3
diff -u -r1.3 mathslib.php
--- lib/mathslib.php	26 May 2007 13:11:54 -0000	1.3
+++ lib/mathslib.php	10 Aug 2007 08:28:58 -0000
@@ -82,6 +82,31 @@
     function get_error() {
         return $this->_error;
     }
+
+    /**
+     * Similar to format_float, formats the numbers and list separators
+     * according to locale specifics.
+     * @param string $formula
+     * @return string localised formula
+     */
+    function localize($formula) {
+        $formula = str_replace('.', '$', $formula); // temp placeholder
+        $formula = str_replace(',', get_string('listsep'), $formula);
+        $formula = str_replace('$', get_string('decsep'), $formula);
+        return $formula;
+    }
+
+    /**
+     * Similar to unformat_float, converts floats and lists to PHP standards.
+     * @param string $formula localised formula
+     * @return string 
+     */
+    function unlocalize($formula) {
+        $formula = str_replace(get_string('decsep'), '$', $formula);
+        $formula = str_replace(get_string('listsep'), ',', $formula);
+        $formula = str_replace('$', '.', $formula); // temp placeholder
+        return $formula;
+    }
 }
 
 ?>
\ No newline at end of file
Index: lib/adminlib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/adminlib.php,v
retrieving revision 1.146
diff -u -r1.146 adminlib.php
--- lib/adminlib.php	7 Aug 2007 07:34:21 -0000	1.146
+++ lib/adminlib.php	10 Aug 2007 08:28:58 -0000
@@ -480,7 +480,7 @@
     if ($done && (($now - $lasttime) >= $updatetime)) {
         $elapsedtime = $now - $starttime;
         $projectedtime = (int)(((float)$total / (float)$done) * $elapsedtime) - $elapsedtime;
-        $percentage = format_float((float)$done / (float)$total, 2);
+        $percentage = round((float)$done / (float)$total, 2);
         $width = (int)(500 * $percentage);
 
         if ($projectedtime > 10) {
Index: grade/report/user/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/report/user/lib.php,v
retrieving revision 1.6
diff -u -r1.6 lib.php
--- grade/report/user/lib.php	25 Jul 2007 19:57:47 -0000	1.6
+++ grade/report/user/lib.php	10 Aug 2007 08:28:54 -0000
@@ -158,7 +158,7 @@
                     }
                 } else {
                     // normal grade, or text, just display
-                    $data[] = $excluded.$this->get_grade_clean($grade_grade->finalgrade);
+                    $data[] = $excluded.format_float($grade_grade->finalgrade);
                 }
 
                 /// prints percentage
@@ -166,7 +166,7 @@
                 if ($grade_item->gradetype == GRADE_TYPE_VALUE) {
                     // processing numeric grade
                     if ($grade_grade->finalgrade) {
-                        $percentage = $this->get_grade_clean(($grade_grade->finalgrade / $grade_item->grademax) * 100).'%';
+                        $percentage = format_float(($grade_grade->finalgrade / $grade_item->grademax) * 100).'%';
                     } else {
                         $percentage = '-';
                     }
@@ -175,7 +175,7 @@
                     // processing scale grade
                     $scale = get_record('scale', 'id', $grade_item->scaleid);
                     $scalevals = explode(",", $scale->scale);
-                    $percentage = $this->get_grade_clean(($grade_grade->finalgrade) / count($scalevals) * 100).'%';
+                    $percentage = format_float(($grade_grade->finalgrade) / count($scalevals) * 100).'%';
 
                 } else {
                     // text grade
Index: lang/en_utf8/langconfig.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/langconfig.php,v
retrieving revision 1.6
diff -u -r1.6 langconfig.php
--- lang/en_utf8/langconfig.php	10 Jul 2007 09:01:19 -0000	1.6
+++ lang/en_utf8/langconfig.php	10 Aug 2007 08:28:54 -0000
@@ -4,8 +4,9 @@
 
 $string['alphabet'] = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z';
 $string['backupnameformat'] = '%%Y%%m%%d-%%H%%M';
-$string['decpoint'] = '.'; // decimal point, for some languages it is ',' if this is changed, must set thousandsep
+$string['decsep'] = '.'; // decimal point separator, for some languages it is ','
 $string['firstdayofweek'] = '0';
+$string['listsep'] = ','; // if decsep is ',', then usually ';' is used instead here; these two can not be the same
 $string['locale'] = 'en_AU.UTF-8';
 $string['localewin'] = 'English_Australia.1252';
 $string['localewincharset'] = '';
@@ -24,6 +25,5 @@
 $string['thischarset'] = 'UTF-8';
 $string['thisdirection'] = 'ltr';
 $string['thislanguage'] = 'English';
-$string['thousandsep'] = ','; // thousand separator, set to '' if none, if this is set, must set decpoint
 
 ?>
Index: grade/report/grader/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/report/grader/lib.php,v
retrieving revision 1.58
diff -u -r1.58 lib.php
--- grade/report/grader/lib.php	9 Aug 2007 16:41:40 -0000	1.58
+++ grade/report/grader/lib.php	10 Aug 2007 08:28:54 -0000
@@ -154,12 +154,7 @@
                         $finalgrade = $postedvalue;
                     }
                 } else {
-                    $trimmed = trim($postedvalue);
-                    if (empty($trimmed)) { // empty string means no grade
-                        $finalgrade = null;
-                    } else {
-                        $finalgrade = $this->format_grade($postedvalue);
-                    }
+                    $finalgrade = unformat_float($postedvalue);
                 }
 
             } else if ($data_type == 'feedback') {
@@ -654,13 +649,13 @@
 
                     } else if ($item->gradetype != GRADE_TYPE_TEXT) { // Value type
                         if ($this->get_pref('quickgrading') and $grade->is_editable()) {
-                            $value = $this->get_grade_clean($gradeval, $decimalpoints);
+                            $value = format_float($gradeval, $decimalpoints);
                             $studentshtml .= '<input type="hidden" name="oldgrade_'.$userid.'_'.$item->id.'" value="'.$value.'" />';
                             $studentshtml .= '<input size="6" tabindex="' . $tabindices[$item->id]['grade']
                                           . '" type="text" title="'. $strgrade .'" name="grade_'
                                           .$userid.'_' .$item->id.'" value="'.$value.'" />';
                         } else {
-                            $studentshtml .= $this->get_grade_clean($gradeval, $decimalpoints);
+                            $studentshtml .= format_float($gradeval, $decimalpoints);
                         }
                     }
 
@@ -726,7 +721,7 @@
                         if (is_null($gradeval)) {
                             $studentshtml .= '-';
                         } else {
-                            $studentshtml .=  $this->get_grade_clean($gradeval, $decimalpoints). $percentsign;
+                            $studentshtml .=  format_float($gradeval, $decimalpoints). $percentsign;
                         }
                     }
                     if (!empty($grade->feedback)) {
@@ -851,12 +846,12 @@
                             $finalavg = $sum/$count_array[$item->id];
                         }
 
-                        $scaleval = round($this->get_grade_clean($finalavg, $decimalpoints));
+                        $scaleval = round($finalavg);
                         $scale_object = new grade_scale(array('id' => $item->scaleid), false);
                         $gradehtml = $scale_object->get_nearest_item($scaleval);
                         $rawvalue = $scaleval;
                     } else {
-                        $gradeval = $this->get_grade_clean($sum/$count_array[$item->id], $decimalpoints);
+                        $gradeval = format_float($sum/$count_array[$item->id], $decimalpoints);
 
                         $gradehtml = round($gradeval, $decimalpoints);
                         $rawvalue = $gradeval;
@@ -909,8 +904,8 @@
                 }
 
                 if ($displaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL) {
-                    $grademin = $this->get_grade_clean($item->grademin, $decimalpoints);
-                    $grademax = $this->get_grade_clean($item->grademax, $decimalpoints);
+                    $grademin = format_float($item->grademin, $decimalpoints);
+                    $grademax = format_float($item->grademax, $decimalpoints);
                 } elseif ($displaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) {
                     $grademin = 0;
                     $grademax = 100;
