Skip to content

fix: Penalty logic#250

Merged
ArthurCRodrigues merged 2 commits intomainfrom
249-fix-penalty-points
Mar 27, 2026
Merged

fix: Penalty logic#250
ArthurCRodrigues merged 2 commits intomainfrom
249-fix-penalty-points

Conversation

@matheusmra
Copy link
Copy Markdown
Member

@matheusmra matheusmra commented Mar 27, 2026

Fixed a critical logic error in how penalty points were calculated and applied to the final grade. The previous implementation incorrectly subtracted points even when penalty-marked tests passed, or used an inverted logic that led to inconsistent grading.

Technical Changes
autograder/models/result_tree.py
Modified RootResultNode.calculate_score() to correctly handle the PENALTY category.

Old Logic: The calculation was not properly reflecting the "deduction" nature of the penalty, often leading to inconsistent final scores when penalty tests were present.

New Logic: The impact of penalties is now calculated as the inverse of the penalty group's score.

A penalty score of 100% (no violations) results in 0 deduction points.
A penalty score of 0% (full violation) results in the full penalty weight being subtracted from the final grade.
Formula implemented: penalty_points = ((100.0 - penalty_score) / 100.0) * self.penalty.weight

Fixed: NameError in FocusStep caused by a missing import, which was previously interrupting the pipeline. Also corrected the test impact logic in FocusService to properly account for category weights (bonus/penalty).

@matheusmra matheusmra linked an issue Mar 27, 2026 that may be closed by this pull request
@matheusmra matheusmra requested review from ArthurCRodrigues and removed request for ArthurCRodrigues March 27, 2026 12:37
@matheusmra
Copy link
Copy Markdown
Member Author

@ArthurCRodrigues ready for review :D

@ArthurCRodrigues
Copy link
Copy Markdown
Member

@matheusmra reviewing

@ArthurCRodrigues ArthurCRodrigues merged commit 48821e7 into main Mar 27, 2026
2 checks passed
@ArthurCRodrigues ArthurCRodrigues deleted the 249-fix-penalty-points branch March 27, 2026 19:12
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.

[FIX] Penalty points

2 participants