Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a rounding error with SingleProblemGrader point values. #2613

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

somiaj
Copy link
Contributor

@somiaj somiaj commented Nov 1, 2024

When computing the point value in the SingleProblemGrader, the database saves 6 decimal digits in the status field, while the single problem grader only saved 2. This difference in rounding can cause the computation of the point value with a stepSize of 0.25 to get get different values between the computed score and the score saved in the database, causing the "Use points from last check" button to show up and present a different rounded value.

This fixes the issue by saving the current score in a $rawCurrnetScore variable that isn't rounded and using that for the point computation. Note, $rawCurrentScore can have more than the 6 decimal digits in the saved database score, but rounding this to match the database won't improve the accuracy of the point value rounded to the nearest stepSize.

Note I noticed this issue with questions with multiple parts with 12-14 points causing a 0.25 stepSize.

When computing the point value in the SingleProblemGrader, the
database saves 6 decimal digits in the status field, while the
single problem grader only saved 2. This difference in rounding can
cause the computation of the point value with a stepSize of 0.25
to get get different values between the computed score and the
score saved in the database, causing the "Use points from last check"
button to show up and present a different rounded value.

This fixes the issue by saving the current score in a `$rawCurrnetScore`
variable that isn't rounded and using that for the point computation.
Note, `$rawCurrentScore` can have more than the 6 decimal digits in the
saved database score, but rounding this to match the database won't
improve the accuracy of the point value rounded to the nearest stepSize.
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.

@Alex-Jordan Alex-Jordan merged commit 16d8d13 into openwebwork:develop Nov 13, 2024
2 checks passed
@somiaj somiaj deleted the fix-rounding-error-spg branch November 24, 2024 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants