From 57c9c63ed25d56b73a0f5f5bfd61051f89619c8b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Oct 2024 21:11:27 -0400 Subject: [PATCH] [Feature: RainbowGrades] Added logic for late penalties and automatic 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. --- table.cpp | 18 ++++++++++++------ table.h | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/table.cpp b/table.cpp index c7d83b7..6c9808a 100644 --- a/table.cpp +++ b/table.cpp @@ -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) { @@ -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 + "\" "; } + } } diff --git a/table.h b/table.h index 95de4e2..33b55d1 100644 --- a/table.h +++ b/table.h @@ -100,4 +100,4 @@ class Table { private: std::vector> cells; -}; +}; \ No newline at end of file