Skip to content

Commit

Permalink
Merge pull request #491 from softwareconstruction240/fix-ontime-submi…
Browse files Browse the repository at this point in the history
…ssion-notes

Fix late penalty notes
  • Loading branch information
19mdavenport authored Nov 26, 2024
2 parents 16eec28 + 5a75812 commit dd90965
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 @@ -431,11 +431,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 @@ -467,6 +463,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 dd90965

Please sign in to comment.