Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-33105

Numerical is_complete() could return a false on a good response

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1.6, 2.2.3, 2.3
    • Fix Version/s: None
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide

      The new code allows users to use different numerical formats when creating numerical questions and when answering.
      The format allows to use indifferently , or . as decsep in all language ( i.e. all) where they a used.
      The thousandseps can be the one used in the language setting or space or , or .
      The code is set as follow
      // Dot . is mostly a decimal separator there a few exceptions where it is a thousand separator
      //If a . is present or there are multiple , (i.e. 2,456,789 ) assume
      //is a thousands separator and strip it or else assume it is a decimal
      // separator and change it to . if only one and it is , then change to .

      1.In summary the testing should include creating numerical questions answers with the number formats used in the phpunit test
      as in test_euro_style() as
      -1 000 -1 000 000 -1.000.000 -1,000,000 -1000,100 -1.000,100 -1,000.100 3,14159 .
      Take care that when you create a numerical question either by using edit_numerical_form or as cloze numerical
      the number you write i.e. 10,000.1 WILL BE CONVERTED when saving the question in the STANDARD format i.e. 10000.1
      This flexibility in writing numbers apply for answers and tolerances values of numerical using
      edit_numerical_form or creating numerical using edit_multianswer
      and answering those questions in preview or quiz.

      LOAD THE EXAMPLES from the file
      Set your language to english default
      A. EDIT_NUMERICAL_FORM
      Notice that the answers and tolerance are written as PHP numerical
      Change the values using variants in decsep or thousand sep.
      Save the question and reedit.
      The numerical are converted back to standard PHP.

      Then start a preview of the question and open the reedit so that you can see the answers values and tolerance.

      Preview the question using diffferent response and check if the grading is OK in each case.
      Use the preview "fill the good response " , submit and look at the good response value.

      Verify in the database question_numerical if the tolerance values are stored correctly
      Create a copy and check that everything is OK.

      A. EDIT_MULTIANSWER_FORM

      Modify the values of answers and tolerance and use the
      DECODE AND VERIFY button to check if these values will not set errors.
      Save the variants and preview them using the "fill the good response " to see how these values are stored

      Use different way to write the answers and the tolerance.

      Verify in the database question_numerical if the tolerance values are stored correctly. i.e. 1e2 will be stored as 100

      Verify that the %100%number:tolerance#feedback format could tolerate one space
      between the number:tolerance as

      {1:NUMERICAL:~%100%1,00.1 : 1e2#feedback}

      Create a copy and check that everything is OK

      Testing language.

      Set your language to another where the decsep is , (i.e. français)
      Preview the questions using"fill the good response " , then submit.
      the fill in should ideally replace the decsep by a , in the the good response in the 2 step i.e fill and submit.
      This is true in multianswer but the fill in does not work correctly for numerical with a unit (see the comments below)

      Show
      The new code allows users to use different numerical formats when creating numerical questions and when answering. The format allows to use indifferently , or . as decsep in all language ( i.e. all) where they a used. The thousandseps can be the one used in the language setting or space or , or . The code is set as follow // Dot . is mostly a decimal separator there a few exceptions where it is a thousand separator //If a . is present or there are multiple , (i.e. 2,456,789 ) assume //is a thousands separator and strip it or else assume it is a decimal // separator and change it to . if only one and it is , then change to . 1.In summary the testing should include creating numerical questions answers with the number formats used in the phpunit test as in test_euro_style() as -1 000 -1 000 000 -1.000.000 -1,000,000 -1000,100 -1.000,100 -1,000.100 3,14159 . Take care that when you create a numerical question either by using edit_numerical_form or as cloze numerical the number you write i.e. 10,000.1 WILL BE CONVERTED when saving the question in the STANDARD format i.e. 10000.1 This flexibility in writing numbers apply for answers and tolerances values of numerical using edit_numerical_form or creating numerical using edit_multianswer and answering those questions in preview or quiz. LOAD THE EXAMPLES from the file Set your language to english default A. EDIT_NUMERICAL_FORM Notice that the answers and tolerance are written as PHP numerical Change the values using variants in decsep or thousand sep. Save the question and reedit. The numerical are converted back to standard PHP. Then start a preview of the question and open the reedit so that you can see the answers values and tolerance. Preview the question using diffferent response and check if the grading is OK in each case. Use the preview "fill the good response " , submit and look at the good response value. Verify in the database question_numerical if the tolerance values are stored correctly Create a copy and check that everything is OK. A. EDIT_MULTIANSWER_FORM Modify the values of answers and tolerance and use the DECODE AND VERIFY button to check if these values will not set errors. Save the variants and preview them using the "fill the good response " to see how these values are stored Use different way to write the answers and the tolerance. Verify in the database question_numerical if the tolerance values are stored correctly. i.e. 1e2 will be stored as 100 Verify that the %100%number:tolerance#feedback format could tolerate one space between the number:tolerance as {1:NUMERICAL:~%100%1,00.1 : 1e2#feedback} Create a copy and check that everything is OK Testing language. Set your language to another where the decsep is , (i.e. français) Preview the questions using"fill the good response " , then submit. the fill in should ideally replace the decsep by a , in the the good response in the 2 step i.e fill and submit. This is true in multianswer but the fill in does not work correctly for numerical with a unit (see the comments below)
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      The last step of is_complete_response(array $response) {
      is
      if ($this->ap->contains_thousands_seaparator($response['answer']))

      { return false; }

      This was valid in the first version of the 2,1 new engine apply_units($response, $separateunit = null)
      with its strict syntax analysis.
      However the apply_units() was retrofit to preceeding more error tolerant function() which can handle a , instead of a .
      as decimal point.
      So answering 10,25 for a 10.25 good answer response will generate a incomplete message although on submit and finish the 10,25 will
      grade as 100%.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  6 Vote for this issue
                  Watchers:
                  14 Start watching this issue

                  Dates

                  • Created:
                    Updated: