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 late penalty notes #491

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/main/java/edu/byu/cs/autograder/score/Scorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,7 @@ public Submission generateSubmissionObject(Rubric rubric, CommitVerificationResu

Integer maxLateDays = DaoService.getConfigurationDao().getConfiguration(ConfigurationDao.Configuration.MAX_LATE_DAYS_TO_PENALIZE, Integer.class);

if (numDaysLate >= maxLateDays)
notes += " Late penalty maxed out at " + numDaysLate + " days late: -";
else if (numDaysLate > 0)
notes += " " + numDaysLate + " days late: -";
notes += (int)(numDaysLate * PER_DAY_LATE_PENALTY * 100) + "% ";
Copy link
Contributor

Choose a reason for hiding this comment

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

what silly goose wrote this code?

notes = makeLatePenaltyNotes(numDaysLate, maxLateDays, notes);

ZonedDateTime handInDate = ScorerHelper.getHandInDateZoned(netId);
Submission.VerifiedStatus verifiedStatus;
Expand Down Expand Up @@ -465,6 +461,25 @@ else if (numDaysLate > 0)
);
}

private String makeLatePenaltyNotes(int numDaysLate, int maxLateDays, String origNotes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that its a separate function now, makes it more clear

if (numDaysLate <= 0) {
return origNotes;
}

String penaltyPercentage = String.format("-%d%%", (int)(numDaysLate * PER_DAY_LATE_PENALTY * 100));
String lateNotes;
if (numDaysLate >= maxLateDays) {
lateNotes = "Late penalty maxed out: " + penaltyPercentage;
} else {
lateNotes = String.format("%d days late: %s", numDaysLate, penaltyPercentage);
}

if (origNotes == null || origNotes.isBlank()) {
return lateNotes;
}
return String.format("%s\n%s", origNotes, lateNotes);
}

private void sendToCanvas(int userId, int assignmentNum, CanvasRubricAssessment assessment, String notes)
throws GradingException {
sendToCanvas(userId, assignmentNum, assessment, notes, gradingContext.netId());
Expand Down