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

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

2

Activity

Show:

Gnapika Reddy Kudumula October 12, 2017 at 10:22 AM

Tested on https://trunk-mysql.nightly.sakaiproject.org/portal with the updated test plan, its fixed.

Neal Caidin October 12, 2017 at 10:16 AM

I changed the formula in the Test Plan from {x}/3 = ans to  {x}/3 = {{w}} . It seems like Calculated question needs a formula option in double brackets. I tested that this is the case in 11.x as well. 

David Bauer October 2, 2017 at 9:20 AM

I've added the simplest steps to reproduce the bug that I could think of. Please let me know if you would like any more information.

chaitanya September 28, 2017 at 3:15 PM

Can you please provide the test plan to recreate the issue?

 

Fixed

Details

Priority

Affects versions

Components

Assignee

Reporter

Created September 25, 2017 at 10:55 AM
Updated April 17, 2018 at 8:26 AM
Resolved September 26, 2017 at 10:06 AM