numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
207 stars 122 forks source link

Floating point error accumulates in MCQ part and gapfills #585

Closed christianp closed 5 years ago

christianp commented 5 years ago

A 'match choices with answers' part with 6 marks available will only ever get the 'partially correct' feedback message, because the floating point representation of 1/6 is slightly lower than 1/6.

Should credit be considered as a rational number? I can't see a reason for irrational amounts of credit. We could run Numbas.math.rationalApproximation on amounts of credit, and store the credit as a rational number. This would mean we can still use floats to specify amounts of credit to award, but don't lose accuracy.

christianp commented 5 years ago

This applies to gapfills, too: if there are 6 gaps, each worth 1 mark, the credit from each one will contribute 1/6 of the credit available for the parent.