Skip to content

Commit

Permalink
fix late penalty notes
Browse files Browse the repository at this point in the history
  • Loading branch information
19mdavenport committed Nov 26, 2024
1 parent 16b3b67 commit 040af87
Showing 1 changed file with 20 additions and 5 deletions.
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) + "% ";
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) {
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

0 comments on commit 040af87

Please sign in to comment.