Moodle
  1. Moodle
  2. MDL-3282

Country-specific decimal delimiter in numerical questions (and elsewhere)

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 2.1
    • Component/s: Quiz
    • Labels:
      None
    • Environment:
      All
    • Affected Branches:
      MOODLE_15_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE

      Description

      In numerical questions and when displaying any decimal numbers in quiz results (and actually anywhere in Moodle) it would be nice to have the possibility to use country-specific decimal (and thousands) delimiter so that

      a) teachers can define questions using their local conventions,

      b) students can fill in answers using their local conventions (even more important then the preceding point),

      c) figures displayed in quiz results and elsewhere in Moodle respect local conventions.

      This could ideally be set up sitewide by the administrator.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Martin Dougiamas added a comment -

            From Gustav Delius (gwd2 at york.ac.uk) Tuesday, 31 January 2006, 06:52 AM:

            See also MDL-4595

            From Jeff Forssell (jeff.forssell at cfl.se) Monday, 13 February 2006, 08:35 PM:

            This feature could also simplify international reuse of good questions

            From dialoge dialoge (rh at dialoge.net) Monday, 13 February 2006, 09:10 PM:

            Gustav,

            sorry I can't help you in this point. I'm not a developer and don't know something about php.

            Ralf

            From (miksik at mrakoplas.phil.muni.cz) Thursday, 16 February 2006, 06:14 AM:

            I've done some searching at php.net, and my impression is that PHP has means and functions for country-specific formatting of strings and numbers, but has no internal functions for country-specific decoding of data coming from web forms. However, there are some user-contributed functions of this type, like this one: http://www.php.net/manual/en/function.floatval.php#48163

            Show
            Martin Dougiamas added a comment - From Gustav Delius (gwd2 at york.ac.uk) Tuesday, 31 January 2006, 06:52 AM: See also MDL-4595 From Jeff Forssell (jeff.forssell at cfl.se) Monday, 13 February 2006, 08:35 PM: This feature could also simplify international reuse of good questions From dialoge dialoge (rh at dialoge.net) Monday, 13 February 2006, 09:10 PM: Gustav, sorry I can't help you in this point. I'm not a developer and don't know something about php. Ralf From (miksik at mrakoplas.phil.muni.cz) Thursday, 16 February 2006, 06:14 AM: I've done some searching at php.net, and my impression is that PHP has means and functions for country-specific formatting of strings and numbers, but has no internal functions for country-specific decoding of data coming from web forms. However, there are some user-contributed functions of this type, like this one: http://www.php.net/manual/en/function.floatval.php#48163
            Hide
            N Hansen added a comment -

            This seems to me to be not a quiz-specific feature request, but something that should be taken care of at a Moodle-wide level. Perhaps reassign this as a "language" or "all" issue?

            Show
            N Hansen added a comment - This seems to me to be not a quiz-specific feature request, but something that should be taken care of at a Moodle-wide level. Perhaps reassign this as a "language" or "all" issue?
            Hide
            Nicolas Martignoni added a comment -

            We have now (as of 1.9b4) the string 'decsep' in langconfig.php for the separator, but it is not used for numerical questions.

            Show
            Nicolas Martignoni added a comment - We have now (as of 1.9b4) the string 'decsep' in langconfig.php for the separator, but it is not used for numerical questions.
            Hide
            Pierre Pichet added a comment -

            In the mean time we could at least handle well all cases involving , use as spacer or as decimal position.
            We could replace the code in numerical/questiontype.php by

            // test if a . is present or there are multiple , (i.e. 2,456,789 ) so that we don't need spaces and ,
            $rawresponse = trim($rawresponse) ;
            if ( strpos($rawresponse,'.' ) !== false || substr_count($rawresponse,',') > 1 )

            { $search = array(' ', ','); $replace = array('', ''); }

            else

            { // remove spaces and normalise , to a . . $search = array(' ', ','); $replace = array('', '.'); }

            $rawresponse = str_replace($search, $replace, $rawresponse);
            This will work correctly for
            if the good answer is 2,345,678.9 with a tolerance of 0.3 all the following give 100% grade
            2,345,678.9
            2 345 678.9
            2345678.9
            2345678,9
            2 345 679
            2,345,679
            I will CVS this tomorrow as we are on weekly code review.

            Show
            Pierre Pichet added a comment - In the mean time we could at least handle well all cases involving , use as spacer or as decimal position. We could replace the code in numerical/questiontype.php by // test if a . is present or there are multiple , (i.e. 2,456,789 ) so that we don't need spaces and , $rawresponse = trim($rawresponse) ; if ( strpos($rawresponse,'.' ) !== false || substr_count($rawresponse,',') > 1 ) { $search = array(' ', ','); $replace = array('', ''); } else { // remove spaces and normalise , to a . . $search = array(' ', ','); $replace = array('', '.'); } $rawresponse = str_replace($search, $replace, $rawresponse); This will work correctly for if the good answer is 2,345,678.9 with a tolerance of 0.3 all the following give 100% grade 2,345,678.9 2 345 678.9 2345678.9 2345678,9 2 345 679 2,345,679 I will CVS this tomorrow as we are on weekly code review.
            Hide
            Tim Hunt added a comment -

            My rewritten question engine should solve this.

            Show
            Tim Hunt added a comment - My rewritten question engine should solve this.
            Hide
            Tim Hunt added a comment -

            Moodle 2.1 does, indeed, largely solve this issue. There may well be further refinements made in the future, but they can be tracked by new, more specific, tracker issues.

            Show
            Tim Hunt added a comment - Moodle 2.1 does, indeed, largely solve this issue. There may well be further refinements made in the future, but they can be tracked by new, more specific, tracker issues.
            Hide
            Tim Hunt added a comment -

            If forgot to add, some bits of the original bug report, like using locale-specific decimal separator for grades, has been handled by the format_float function for a long time.

            Show
            Tim Hunt added a comment - If forgot to add, some bits of the original bug report, like using locale-specific decimal separator for grades, has been handled by the format_float function for a long time.

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: