feat: include bonus
Pipeline / check (pull_request) Successful in 12m11s
Pipeline / docs (pull_request) Skipped
Pipeline / nightly (pull_request) Skipped
Pipeline / release (pull_request) Skipped

This commit is contained in:
alexm committed 2026-11-02 08:22:07 -05:00
1 parent c8d6f4a5dd
commit 15175f64fd
16 files changed
+773 -83

No files matched your search

+37 -6
View File
@@ -100,13 +100,16 @@ pub fn student(
// --- score
out.push_str(&format!(
"You scored **{:.1} of {:.1} points ({:.0}%)**",
summary.points, summary.points_possible, summary.percent
"You scored **{} of {} points ({:.1}%)**",
points(summary.total_points),
points(summary.points_possible),
summary.percent
));
let mut extras = Vec::new();
if summary.bonus_points > 0.0 {
out.push_str(&format!(
", plus {:.1} bonus point{}",
summary.bonus_points,
extras.push(format!(
"{} bonus point{}",
points(summary.bonus_points),
if (summary.bonus_points - 1.0).abs() < 1e-9 {
""
} else {
@@ -114,6 +117,20 @@ pub fn student(
}
));
}
if summary.curve_points != 0.0 {
extras.push(format!(
"{} curve point{}",
points(summary.curve_points),
if (summary.curve_points - 1.0).abs() < 1e-9 {
""
} else {
"s"
}
));
}
if !extras.is_empty() {
out.push_str(&format!(" including {}", extras.join(" and ")));
}
out.push_str(&format!(
", answering {} of {} questions correctly.\n\n",
summary.correct, summary.n_items
@@ -121,7 +138,7 @@ pub fn student(
if opts.comparison {
out.push_str(&format!(
"The class averaged {:.0}%. Your score is in the {}.\n\n",
"The class averaged {:.1}%. Your score is in the {}.\n\n",
cohort.mean_percent, summary.band
));
}
@@ -684,6 +701,20 @@ pub fn roster(cohort: &Cohort) -> String {
out
}
/// Formats points the way a gradebook shows them, with no trailing zeros.
///
/// # Arguments
///
/// * `value` - the points.
///
/// # Returns
///
/// The points to at most two decimal places.
fn points(value: f64) -> String {
let text = format!("{value:.2}");
text.trim_end_matches('0').trim_end_matches('.').to_string()
}
/// A small unicode bar for a rate in `0.0..=1.0`.
///
/// # Arguments