feat: include bonus
This commit is contained in:
16 files changed
+773
-83
No files matched your search
+37
-6
@@ -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
|
||||
|
||||
@@ -196,8 +196,26 @@ pub fn student_value(diagnostic: &StudentDiagnostic, config: &RenderConfig) -> V
|
||||
let mut score = Value::dict();
|
||||
score.insert("points", Value::Float(diagnostic.score.points));
|
||||
score.insert("possible", Value::Float(diagnostic.score.points_possible));
|
||||
score.insert("total", Value::Float(diagnostic.score.total_points));
|
||||
score.insert("percent", Value::Float(diagnostic.score.percent));
|
||||
score.insert("bonus", Value::Float(diagnostic.score.bonus_points));
|
||||
score.insert("curve", Value::Float(diagnostic.score.curve_points));
|
||||
score.insert(
|
||||
"bonus-questions",
|
||||
Value::Array(
|
||||
diagnostic
|
||||
.score
|
||||
.bonus_questions
|
||||
.iter()
|
||||
.map(|question| {
|
||||
let mut value = Value::dict();
|
||||
value.insert("number", Value::Int(question.number as i64));
|
||||
value.insert("points", Value::Float(question.points));
|
||||
value
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
);
|
||||
score.insert("correct", Value::Int(diagnostic.score.correct as i64));
|
||||
score.insert("items", Value::Int(diagnostic.score.n_items as i64));
|
||||
out.insert("score", score);
|
||||
@@ -546,6 +564,8 @@ pub fn cohort_value(diagnostic: &CohortDiagnostic, config: &RenderConfig) -> Val
|
||||
Value::Array(diagnostic.distribution.bins.iter().map(bin_value).collect()),
|
||||
);
|
||||
out.insert("distribution", distribution);
|
||||
out.insert("mean-bonus", Value::Float(diagnostic.mean_bonus));
|
||||
out.insert("mean-curve", Value::Float(diagnostic.mean_curve));
|
||||
|
||||
let mut reliability = Value::dict();
|
||||
reliability.insert_some("alpha", diagnostic.reliability.alpha.map(Value::Float));
|
||||
@@ -1246,6 +1266,8 @@ mod tests {
|
||||
|
||||
fn empty_cohort() -> CohortDiagnostic {
|
||||
CohortDiagnostic {
|
||||
mean_bonus: 0.0,
|
||||
mean_curve: 0.0,
|
||||
n_students: 24,
|
||||
n_items: 36,
|
||||
distribution: Distribution {
|
||||
|
||||
@@ -467,6 +467,19 @@
|
||||
#pad(right: prose-pad)[#text(size: size-lead, fill: luma(90))[#rel.interpretation]]
|
||||
]
|
||||
|
||||
#let mean-bonus = cb-data.at("mean-bonus", default: 0.0)
|
||||
#let mean-curve = cb-data.at("mean-curve", default: 0.0)
|
||||
|
||||
#if mean-bonus != 0.0 or mean-curve != 0.0 [
|
||||
#block(above: entry-gap)[
|
||||
#pad(right: prose-pad)[#text(size: size-lead, fill: luma(90))[
|
||||
These percentages match the gradebook, so they include an average of
|
||||
#num(mean-bonus, digits: 2) bonus and #num(mean-curve, digits: 2) curve
|
||||
points per student. Reliability and the item statistics do not.
|
||||
]]
|
||||
]
|
||||
]
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Where the class landed
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -57,7 +57,17 @@
|
||||
name: "Sample Student",
|
||||
email: "sample@example.edu",
|
||||
form: "A",
|
||||
score: (points: 27.0, possible: 36.0, percent: 75.0, bonus: 1.0, correct: 27, items: 36),
|
||||
score: (
|
||||
points: 27.0,
|
||||
possible: 36.0,
|
||||
total: 31.6,
|
||||
percent: 87.8,
|
||||
bonus: 1.0,
|
||||
curve: 3.6,
|
||||
bonus-questions: ((number: 37, points: 1.0), (number: 38, points: 0.0)),
|
||||
correct: 27,
|
||||
items: 36,
|
||||
),
|
||||
standing: (class-mean: 71.2, class-sd: 11.4, band: "upper half"),
|
||||
levels: (
|
||||
(
|
||||
@@ -132,10 +142,12 @@
|
||||
number: 2,
|
||||
level: 3,
|
||||
targets: ("t-sample-gap",),
|
||||
measured: ((
|
||||
objective: [A sample objective to work on.],
|
||||
target: [A sample learning target under it.],
|
||||
),),
|
||||
measured: (
|
||||
(
|
||||
objective: [A sample objective to work on.],
|
||||
target: [A sample learning target under it.],
|
||||
),
|
||||
),
|
||||
correct: false,
|
||||
credit: 0.0,
|
||||
bonus: false,
|
||||
@@ -146,6 +158,30 @@
|
||||
taught-in: ("Enthalpy (L1.1), slides 12, 13",),
|
||||
review: ((citation: "KKW §6.2", title: "Molecules and Medicine", url: "https://example.edu/6/2"),),
|
||||
),
|
||||
(
|
||||
number: 37,
|
||||
level: 1,
|
||||
targets: (),
|
||||
measured: (),
|
||||
correct: true,
|
||||
credit: 1.0,
|
||||
bonus: true,
|
||||
blank: false,
|
||||
taught-in: (),
|
||||
review: (),
|
||||
),
|
||||
(
|
||||
number: 38,
|
||||
level: 1,
|
||||
targets: (),
|
||||
measured: (),
|
||||
correct: false,
|
||||
credit: 0.0,
|
||||
bonus: true,
|
||||
blank: false,
|
||||
taught-in: (),
|
||||
review: (),
|
||||
),
|
||||
),
|
||||
dropped-questions: ((number: 35, full-credit: true),),
|
||||
review-lectures: (
|
||||
@@ -275,7 +311,8 @@
|
||||
// A rate is a fraction in 0..1; a percent is already out of 100. Keeping the two
|
||||
// straight is the only arithmetic this template does.
|
||||
#let pct(rate) = str(calc.round(rate * 100)) + "%"
|
||||
#let pct1(value) = str(calc.round(value, digits: 0)) + "%"
|
||||
#let pct1(value) = str(calc.round(value, digits: 1)) + "%"
|
||||
#let pts(value) = str(calc.round(value, digits: 2))
|
||||
|
||||
#let plural(n, one, many) = if n == 1 { one } else { many }
|
||||
|
||||
@@ -410,9 +447,12 @@
|
||||
)[
|
||||
#pad(right: prose-pad - 1.1cm)[
|
||||
#text(size: size-lead)[
|
||||
This map explains what the exam covered and what your results mean, so you can use the information. Your score appears first because that's what you probably want to see. After that, you'll find more helpful details: which types of questions you did well on, which topics you might want to review, and what to read for each area. The last two sections are the most practical, so if you only read part of this, focus on those.
|
||||
This map explains what the exam covered and what your results mean, so you can use the information.
|
||||
Your score appears first because you probably want to see it.
|
||||
After that, you'll find helpful details: which question types you did well on, which topics to review, and what to read for each area.
|
||||
The last two sections are the most practical, so if you read only part of this, focus on those.
|
||||
|
||||
This report does not judge your abilities, and one question alone does not say much. If a score is based on just one or two questions, the report will point that out so you don't read too much into it.
|
||||
This report doesn't judge your abilities, and one question alone doesn't say much.
|
||||
]
|
||||
]
|
||||
]
|
||||
@@ -431,11 +471,7 @@
|
||||
stat-card(
|
||||
"your score",
|
||||
pct1(score.percent),
|
||||
note: str(score.points)
|
||||
+ " of "
|
||||
+ str(score.possible)
|
||||
+ " points"
|
||||
+ (if score.at("bonus", default: 0.0) > 0.0 { " (+" + str(score.bonus) + " bonus)" } else { "" }),
|
||||
note: pts(score.at("total", default: score.points)) + " of " + pts(score.possible) + " points",
|
||||
),
|
||||
stat-card(
|
||||
"questions right",
|
||||
@@ -457,6 +493,37 @@
|
||||
},
|
||||
)
|
||||
|
||||
// The arithmetic behind the score, so it can be checked against the gradebook.
|
||||
// Bonus and curve points are worth zero on the platform: they raise the total and
|
||||
// leave the denominator alone, which is why a score can pass 100%.
|
||||
#let bonus-questions = score.at("bonus-questions", default: ())
|
||||
#let curve-points = score.at("curve", default: 0.0)
|
||||
|
||||
#if bonus-questions.len() > 0 or curve-points != 0.0 [
|
||||
#block(above: entry-gap)[
|
||||
#table(
|
||||
columns: (1fr, auto),
|
||||
stroke: none,
|
||||
inset: (x: 0pt, y: 3pt),
|
||||
align: (left, right),
|
||||
[Questions], [#pts(score.points) of #pts(score.possible)],
|
||||
..if bonus-questions.len() > 0 {
|
||||
(
|
||||
[Bonus #plural(bonus-questions.len(), "question", "questions")
|
||||
#bonus-questions.map(q => str(q.number)).join(", ")],
|
||||
[+#pts(score.at("bonus", default: 0.0))],
|
||||
)
|
||||
} else { () },
|
||||
..if curve-points != 0.0 {
|
||||
([Curve], [#if curve-points > 0.0 [+]#pts(curve-points)])
|
||||
} else { () },
|
||||
table.hline(stroke: 0.5pt + luma(180)),
|
||||
[*Final score*],
|
||||
[*#pts(score.at("total", default: score.points)) of #pts(score.possible) (#pct1(score.percent))*],
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
#let dropped-questions = cb-data.at("dropped-questions", default: ())
|
||||
|
||||
#if dropped-questions.len() > 0 [
|
||||
@@ -473,7 +540,7 @@
|
||||
|
||||
if credited.len() > 0 [
|
||||
#plural(credited.len(), "Question", "Questions") #numbers(credited)
|
||||
#plural(credited.len(), "was", "were") thrown out after the exam.
|
||||
#plural(credited.len(), "was", "were") dropped after the exam.
|
||||
Everyone received full credit for
|
||||
#plural(credited.len(), "it", "them"), so
|
||||
#plural(credited.len(), "it is", "they are") still counted in the
|
||||
@@ -796,11 +863,19 @@
|
||||
|
||||
#let question-box(q) = {
|
||||
let dropped = q.at("dropped", default: false)
|
||||
let color = if dropped { luma(130) } else if q.at("blank", default: false) {
|
||||
let bonus = q.at("bonus", default: false)
|
||||
let credit = q.at("credit", default: 0.0)
|
||||
// A bonus question can only add points, so one that earned nothing is not
|
||||
// marked as an error, and its color follows the points it actually earned.
|
||||
let color = if dropped { luma(130) } else if bonus and credit <= 0.0 {
|
||||
luma(160)
|
||||
} else if q.at("correct", default: false) == true {
|
||||
} else if q.at("blank", default: false) {
|
||||
luma(160)
|
||||
} else if bonus and credit >= 0.999 {
|
||||
ok-color
|
||||
} else if q.at("credit", default: 0.0) > 0.0 { mid-color } else { bad-color }
|
||||
} else if not bonus and q.at("correct", default: false) == true {
|
||||
ok-color
|
||||
} else if credit > 0.0 { mid-color } else { bad-color }
|
||||
box(
|
||||
width: 100%,
|
||||
fill: color.lighten(85%),
|
||||
@@ -814,6 +889,9 @@
|
||||
if dropped {
|
||||
linebreak()
|
||||
text(size: size-tag, fill: luma(110))[out]
|
||||
} else if bonus {
|
||||
linebreak()
|
||||
text(size: size-tag, fill: luma(110))[bonus]
|
||||
} else {
|
||||
let level = q.at("level", default: none)
|
||||
if level != none {
|
||||
@@ -848,6 +926,9 @@
|
||||
#box(width: 0.7em, height: 0.7em, fill: bad-color.lighten(70%), radius: 2pt) not right ·
|
||||
#box(width: 0.7em, height: 0.7em, fill: luma(210), radius: 2pt) left blank ·
|
||||
#box(width: 0.7em, height: 0.7em, fill: luma(150), radius: 2pt) dropped, not scored
|
||||
#if questions.any(q => q.at("bonus", default: false)) [
|
||||
· a box marked *bonus* can only add points, so a gray one cost you nothing
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user