Skip to content

Commit

Permalink
[Feature: RainbowGrades] Added logic for late penalties and automatic…
Browse files Browse the repository at this point in the history
… zeros with dynamic hover text. Introduced variables 'penalty_per_day' and 'automatic_zero' to calculate scores based on late submissions and generate informative hover text. The hover text now displays details like original score, late days used, and penalty percentage, enhancing clarity for students.
  • Loading branch information
chloe-crews committed Oct 4, 2024
1 parent 20c5002 commit 57c9c63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,16 @@ TableCell::TableCell(float d, const std::string& c, int precision, const std::st
float original_score = d;

// Apply penalty if not an automatic zero
if (automatic_zero) {
d = 0; // Set final score to 0 if automatic zero
} else if (late_days_used > 0) {
// Apply penalty if not an automatic zero
if (automatic_zero) {
d = 0; // Set final score to 0 if automatic zero
} else if (late_days_used > 0) {
d = d * (1.0f - penalty_per_day * late_days_used); // Apply percentage deduction for late days
}
}

// Ensure numeric precision
if (fabs(d) > 0.0001) {
Expand Down Expand Up @@ -120,14 +125,15 @@ TableCell::TableCell(float d, const std::string& c, int precision, const std::st
bad_status = true;
override = inquiry = extension = version_conflict = cancelled = false;
if (automatic_zero) {
hoverText = "class=\"hoverable-cell\" data-hover-text=\"" + CSVSanitizeString(userName) +
" received an automatic zero due to late submission.\" ";
hoverText = "class=\"hoverable-cell\" data-hover-text=\"" + CSVSanitizeString(userName) +
" received an automatic zero due to late submission.\" ";
} else {
hoverText = "class=\"hoverable-cell\" data-hover-text=\"" + CSVSanitizeString(userName) +
" received a bad status on " + CSVSanitizeString(gID) + ". Original score: " +
std::to_string(original_score) + ", Final score after " + std::to_string(late_days_used) +
" late days and a penalty of " + std::to_string(penalty_per_day * 100) + "% per day: " + data + "\" ";
hoverText = "class=\"hoverable-cell\" data-hover-text=\"" + CSVSanitizeString(userName) +
" received a bad status on " + CSVSanitizeString(gID) + ". Original score: " +
std::to_string(original_score) + ", Final score after " + std::to_string(late_days_used) +
" late days and a penalty of " + std::to_string(penalty_per_day * 100) + "% per day: " + data + "\" ";
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion table.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ class Table {

private:
std::vector<std::vector<TableCell>> cells;
};
};

0 comments on commit 57c9c63

Please sign in to comment.