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

XMLWordPrintable

Details

• Type: Bug
• Status: CLOSED
• Priority: Major
• Resolution: Fixed
• Affects Version/s: 12.0
• Fix Version/s:
• Component/s:
• Labels:
None
• 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.

Attachments

1. Selection_001.jpg
30 kB
2. Selection_002.jpg
11 kB

People

• Assignee:
David P. Bauer
Reporter:
David P. Bauer