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

Prevents play score percentages over 100 #1584

Conversation

clpetersonucf
Copy link
Member

@clpetersonucf clpetersonucf commented May 8, 2024

Resolves #1392

This is a single-line addition to the Session_Play class to ensure the $percent param submitted to set_complete is never allowed to be over 100. While the database will happily accept values over 100, certain places downstream will have major issues with play percentages that are out of bounds.


@cayb0rg
Copy link
Contributor

cayb0rg commented May 15, 2024

This does a good job of preventing scores from being over 100 for new scores. It's outside the scope of this PR, but I wonder if it'd be possible to also add a validation check for existing log_play percentages. For existing ones > 100%, I get this error (after merging in dev/10.2.0 - before, the page would just crash):

image

I believe it has to do with get_widget_score_distribution putting scores > 100% in their own bracket above 9, which causes apiGetScoreSummary to error.

Also, on the scorescreen, before the single-line addition, scores would show as > 100% in the previous scores. Now they're 100%, as expected. However, it will still show as > 100% in the overview table:

image

Just leaving this as a comment as these issues aren't exactly what the PR is addressing.

@clpetersonucf
Copy link
Member Author

Also, on the scorescreen, before the single-line addition, scores would show as > 100% in the previous scores. Now they're 100%, as expected. However, it will still show as > 100% in the overview table

Ideally this will never happen with new score screens, because the percentage saved to the DB will always be 100 or less. Fixing existing records in the log_play table with perc values over 100 isn't within the bounds of this PR though.

Added additional check to the get_widget_score_distribution endpoint to ensure the provided distribution doesn't include brackets outside the intended 0-9 range. This prevents the score summary graph from erroring out in cases where a 200% score may be present.

Copy link
Contributor

@cayb0rg cayb0rg left a comment

Choose a reason for hiding this comment

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

Ideally this will never happen with new score screens, because the percentage saved to the DB will always be 100 or less. Fixing existing records in the log_play table with perc values over 100 isn't within the bounds of this PR though.

Understandable. May be possible to include a >100 check on the front-end, but also wouldn't make much sense since users who have >100 scores have already seen them lol

Nice, efficient fix to the score distribution view. This is looking good to me 👍🏻

@clpetersonucf clpetersonucf merged commit dae8413 into ucfopen:dev/10.2.0 Jun 17, 2024
2 checks passed
@clpetersonucf clpetersonucf deleted the issue/1392-prevent-percent-values-over-100 branch June 17, 2024 18:22
@clpetersonucf clpetersonucf mentioned this pull request Jun 18, 2024
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.

None yet

2 participants