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

Edge case missing from Calculated qtype

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4, 2.1.1, 2.2
    • Fix Version/s: 2.0.5, 2.1.2
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide

      1. Start creating a new calculated question with all defaults, except:
      Name: <whatever>
      Answer Formula:

      {x}

      *1E-12
      Answer Grade: 100%
      Format: Significant Figures

      2. Click Save changes then Next page

      3. On this page set
      Range of Values: 1.0-1.1
      Decimal places: 1
      Then Add 30 new set(s) of wild card(s) values

      4. Verify that there are no errors like "ERROR Correct answer : 100e-13 outside limits of true value 1.0E-12"

      Show
      1. Start creating a new calculated question with all defaults, except: Name: <whatever> Answer Formula: {x} *1E-12 Answer Grade: 100% Format: Significant Figures 2. Click Save changes then Next page 3. On this page set Range of Values: 1.0-1.1 Decimal places: 1 Then Add 30 new set(s) of wild card(s) values 4. Verify that there are no errors like "ERROR Correct answer : 100e-13 outside limits of true value 1.0E-12"
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      When using the significant figures calculation mode, an edge case is not properly handled in the function 'qtype_calculated_calculate_answer', causing the calculated answer to be incorrect.

      The function works to ensure the answer is expressed as a string of the format "0.[1-9][0-9]*", but subsequently calls the round() function. In some cases, round will round up to 1.0- which is no longer in the assumed format. This causes an answer to be produced which is exactly 10x larger than the correct answer.

      A special case should be added to compensate, as in the attached patch.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Oct/11