Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-35864

Bug with using BigDecimal divide without a rounding mode in Calculated Questions

    Details

    • 12 status:
      Resolved
    • 11 status:
      Resolved
    • Previous Issue Keys:
      SAM-3258
    • Test Plan:
      Hide

      1. Create a new assessment in Tests & Quizzes
      2. Add a new Calculated Question
      3. Set a point value
      4. Enter question text "{x}/3=w"
      5. Click on "Extract Variables, Calculations, and Formulas from Question Text"
      6. For the variable 'x', enter min = 1, max = 1 and decimal places 0.
      7. For the formula, enter {x}/3, the rest can be left as default.
      8. Click on "Save"

      If the bug is present, you will see an error "500: Unknown Error :1/3"

      If the bug is fixed, the question will save correctly and you will be taken back to the "Questions" page.

      Show
      1. Create a new assessment in Tests & Quizzes 2. Add a new Calculated Question 3. Set a point value 4. Enter question text "{x}/3= w " 5. Click on "Extract Variables, Calculations, and Formulas from Question Text" 6. For the variable 'x', enter min = 1, max = 1 and decimal places 0. 7. For the formula, enter {x}/3, the rest can be left as default. 8. Click on "Save" If the bug is present, you will see an error "500: Unknown Error :1/3" If the bug is fixed, the question will save correctly and you will be taken back to the "Questions" page.

      Description

      There appears to be a regression caused by the switch to BigDecimal in calculated questions (SAM-3227).

      Calling BigDecimal.divide without a rounding mode specified will throw an ArithmeticException if the result of the division cannot be truly represented without rounding e.g. the answer is a repeating decimal 0.333333....

      Samigo doesn't catch the ArithmeticException so the result is a "500: Unknown Error" when trying to save.

      It looks like simply setting a rounding mode and the number of decimal places needed for the division fixes the issue.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  davidpbauer David P. Bauer
                  Reporter:
                  davidpbauer David P. Bauer
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Git Source Code