feat: add learning objective targets
Pipeline / check (pull_request) Failing after 3m25s
Pipeline / docs (pull_request) Skipped
Pipeline / nightly (pull_request) Skipped
Pipeline / release (pull_request) Skipped

This commit is contained in:
alexm committed 2026-09-21 14:02:34 -04:00
1 parent 9755417899
commit 8ec48fb185
32 files changed
+2396 -448

No files matched your search

+324 -49
View File
@@ -9,10 +9,13 @@
//! hand. Two copies of the same prose drift within a term; one copy and a build
//! step do not.
//!
//! Three pages come out of here: the lecture's learning objectives, its learning
//! targets grouped under those objectives, and its readings.
//!
//! [`Style::Quarto`] reproduces the definition-list shape a Quarto page wants,
//! with `_(LO 4, 7)_` numbering resolved from [`CourseFile::lecture_objectives`].
//! Those numbers are positional and so cannot be authored: inserting an objective
//! renumbers everything after it. They are computed here and never stored.
//! with `_(T 4, 7)_` numbering resolved from [`numbered_targets`]. Those numbers
//! are positional and so cannot be authored: inserting a target renumbers
//! everything after it. They are computed here and never stored.
//!
//! What this module does not do is invent prose. Everything printed comes from
//! `summary`, `focus`, and `skip` on the reading, in that order, and a reading with
@@ -33,12 +36,131 @@ pub enum Style {
Plain,
}
/// Renders the objectives for one lecture, grouped by level.
/// How a lecture's targets group under its objectives.
///
/// The numbering here and the `_(LO 4, 7)_` lists in [`readings_markdown`] come
/// from the same call to [`CourseFile::lecture_objectives`], so they cannot
/// disagree. Generating one half of the page and hand-writing the other is how you
/// get a note pointing at LO 8 when LO 8 has become LO 9.
/// One function feeds every page, so the printed order and the numbering cannot
/// come apart.
///
/// # Arguments
///
/// * `course` - the loaded course file.
/// * `lecture` - the lecture id.
///
/// # Returns
///
/// The groups as `(objective id, its targets in this lecture)`, and the
/// leftovers: targets whose objective this lecture does not teach, and
/// objectives that have no targets and so stand as their own.
fn target_layout<'a>(
course: &'a CourseFile,
lecture: &str,
) -> (Vec<(&'a str, Vec<&'a str>)>, Vec<&'a str>) {
let targets = course.lecture_targets(lecture);
let mut groups: Vec<(&str, Vec<&str>)> = Vec::new();
for objective in course.lecture_objectives(lecture) {
let mine: Vec<&str> = course
.targets(objective)
.into_iter()
.filter(|t| targets.contains(t))
.collect();
if !mine.is_empty() {
groups.push((objective, mine));
}
}
let grouped: Vec<&str> = groups
.iter()
.flat_map(|(_, ts)| ts.iter().copied())
.collect();
let leftovers: Vec<&str> = targets
.into_iter()
.filter(|t| !grouped.contains(t))
.collect();
(groups, leftovers)
}
/// Whether a lecture's registry entries use the second tier.
///
/// # Arguments
///
/// * `course` - the loaded course file.
/// * `lecture` - the lecture id.
///
/// # Returns
///
/// `true` when any entry the lecture names is a target.
fn is_tiered(course: &CourseFile, lecture: &str) -> bool {
course
.lecture_entries(lecture)
.iter()
.any(|id| course.is_target(id))
}
/// The entries a lecture's pages number, in the order they print.
///
/// Numbering is a property of the *targets* page, because that is the tier a
/// reading serves: a section of a textbook backs a specific performance, not a
/// whole objective. An untiered lecture numbers its objectives instead, since
/// there each objective is its own target.
///
/// # Arguments
///
/// * `course` - the loaded course file.
/// * `lecture` - the lecture id.
///
/// # Returns
///
/// Registry ids in printed order.
fn numbered_targets(course: &CourseFile, lecture: &str) -> Vec<String> {
if !is_tiered(course, lecture) {
// Untiered page: level groups, in the order they print, which is the
// numbering this page has always had.
return by_level(course, &course.lecture_entries(lecture))
.into_iter()
.flat_map(|(_, members)| members)
.map(str::to_string)
.collect();
}
let (groups, leftovers) = target_layout(course, lecture);
groups
.into_iter()
.flat_map(|(_, targets)| targets)
.chain(leftovers)
.map(str::to_string)
.collect()
}
/// Groups ids by the level they are assessed up to, in taxonomy order.
///
/// # Arguments
///
/// * `course` - the loaded course file.
/// * `ids` - the ids to group.
///
/// # Returns
///
/// Non-empty groups, with whatever declares no ceiling last under `None`.
fn by_level<'a>(course: &CourseFile, ids: &[&'a str]) -> Vec<(Option<Level>, Vec<&'a str>)> {
let mut groups: Vec<(Option<Level>, Vec<&str>)> =
Level::ALL.iter().map(|l| (Some(*l), Vec::new())).collect();
groups.push((None, Vec::new()));
for id in ids {
let ceiling = course.effective_level_ceiling(id);
if let Some(slot) = groups.iter_mut().find(|(level, _)| *level == ceiling) {
slot.1.push(id);
}
}
groups.retain(|(_, members)| !members.is_empty());
groups
}
/// Renders the learning objectives for one lecture.
///
/// This is the short page: the four to eight claims the lecture is accountable
/// for, which is what a student reads before class and what an exam report will
/// classify. The performances behind them are [`targets_markdown`].
///
/// On a lecture whose entries are all objectives, the output is what it has
/// always been, grouped by level.
///
/// # Arguments
///
@@ -60,37 +182,100 @@ pub fn objectives_markdown(course: &CourseFile, lecture: &str, style: Style) ->
let mut out = String::from("## Learning objectives\n\n");
out.push_str("After this lecture, you should be able to do the following.\n\n");
// Levels in taxonomy order, then whatever declares no ceiling.
let mut groups: Vec<(Option<Level>, Vec<&str>)> =
Level::ALL.iter().map(|l| (Some(*l), Vec::new())).collect();
groups.push((None, Vec::new()));
for id in &ids {
let ceiling = course.learning_objectives[*id].level_ceiling;
if let Some(slot) = groups.iter_mut().find(|(level, _)| *level == ceiling) {
slot.1.push(id);
}
}
for (level, members) in &groups {
if members.is_empty() {
continue;
}
for (level, members) in by_level(course, &ids) {
if let Some(level) = level {
out.push_str(&format!("### {}\n\n", level.name()));
}
for id in members {
let text = course.objective_text(id);
out.push_str(&match style {
Style::Quarto => format!("(@) {text}\n"),
Style::Plain => format!("1. {text}\n"),
});
out.push_str(&bullet(&course.text_for(id), style));
}
out.push('\n');
}
Ok(out)
}
/// Renders the learning targets for one lecture, grouped under their objectives.
///
/// The long page: every performance an item on this material could be written
/// against. Grouping by objective rather than by level is deliberate, because
/// the objective is the grouping the student is being taught and the one a
/// report will use; level headings would cut across it and scatter one
/// objective's targets over three places.
///
/// The numbers here are the ones a reading's `_(T 4, 7)_` refers to, and both
/// come from [`numbered_targets`], so they cannot disagree.
///
/// # Arguments
///
/// * `course` - the loaded course file.
/// * `lecture` - the lecture id.
/// * `style` - which flavour to emit.
///
/// # Returns
///
/// The Markdown, ending in a newline. On a lecture with no targets declared,
/// the objectives stand as their own targets and the page is grouped by level
/// instead.
///
/// # Errors
///
/// Returns [`Error::Unresolved`] when the lecture id is not registered.
pub fn targets_markdown(course: &CourseFile, lecture: &str, style: Style) -> Result<String> {
course.lecture(lecture, "lecture page")?;
let mut out = String::from("## Learning targets\n\n");
out.push_str(
"Each objective above is met by the specific things below. Exam questions are \
written against these.\n\n",
);
if !is_tiered(course, lecture) {
for (level, members) in by_level(course, &course.lecture_entries(lecture)) {
if let Some(level) = level {
out.push_str(&format!("### {}\n\n", level.name()));
}
for id in members {
out.push_str(&bullet(&course.text_for(id), style));
}
out.push('\n');
}
return Ok(out);
}
let (groups, leftovers) = target_layout(course, lecture);
for (objective, targets) in groups {
out.push_str(&format!("### {}\n\n", course.text_for(objective)));
for target in targets {
out.push_str(&bullet(&course.text_for(target), style));
}
out.push('\n');
}
if !leftovers.is_empty() {
for id in leftovers {
out.push_str(&bullet(&course.text_for(id), style));
}
out.push('\n');
}
Ok(out)
}
/// One list item, numbered so a reading can point at it.
///
/// # Arguments
///
/// * `text` - the objective or target text.
/// * `style` - which flavour to emit.
///
/// # Returns
///
/// The line, ending in a newline.
fn bullet(text: &str, style: Style) -> String {
match style {
Style::Quarto => format!("(@) {text}\n"),
Style::Plain => format!("1. {text}\n"),
}
}
/// Renders the readings for one lecture.
///
/// # Arguments
@@ -112,9 +297,9 @@ pub fn readings_markdown(course: &CourseFile, lecture: &str, style: Style) -> Re
let lec = course.lecture(lecture, "lecture page")?;
// Positional numbers for this page, so `{lo-id}` in a note and the trailing
// `_(LO ...)_` agree with the objective list printed above them.
let order = course.lecture_objectives(lecture);
let number = |id: &str| order.iter().position(|o| *o == id).map(|i| i + 1);
// `_(T ...)_` agree with the targets page printed alongside.
let order = numbered_targets(course, lecture);
let number = |id: &str| order.iter().position(|o| o == id).map(|i| i + 1);
let mut out = String::from("## Readings\n\n");
for role in [ReadingRole::Assigned, ReadingRole::Supplemental] {
@@ -177,8 +362,8 @@ fn entry(
.flatten()
.map(|prose| {
course.expand_objective_refs(prose, |id| match number(id) {
Some(n) => format!("LO {n}"),
None => course.objective_text(id),
Some(n) => format!("T {n}"),
None => course.text_for(id),
})
})
.collect();
@@ -188,15 +373,12 @@ fn entry(
if !body.is_empty() {
out.push_str(&format!(": {}\n", body.join("\n")));
}
let mut numbers: Vec<usize> = reading
.objectives
.iter()
.filter_map(|o| number(o))
.collect();
let mut numbers: Vec<usize> =
reading.targets.iter().filter_map(|o| number(o)).collect();
numbers.sort_unstable();
if !numbers.is_empty() {
let list: Vec<String> = numbers.iter().map(|n| n.to_string()).collect();
out.push_str(&format!("<br>\n_(LO {})_\n", list.join(", ")));
out.push_str(&format!("<br>\n_(T {})_\n", list.join(", ")));
}
out.push('\n');
}
@@ -239,13 +421,14 @@ fn heading(reading: &Reading, key: &str, reference: &Reference, style: Style) ->
#[cfg(test)]
mod tests {
use super::*;
use crate::course::{Lecture, Objective, ReferenceRole};
use crate::course::{Lecture, Objective, ReferenceRole, Target};
/// A course with one lecture, two objectives, and one reference.
fn course() -> CourseFile {
let mut c = CourseFile::skeleton("BIOSC 1000", "Biochemistry", "2026f");
c.lectures.clear();
c.learning_objectives.clear();
c.learning_targets.clear();
c.references.insert(
"kuriyan2013molecules".into(),
@@ -280,7 +463,7 @@ mod tests {
reference: Some("kuriyan2013molecules".into()),
locator: Some("§6.1".into()),
path: Some("6/A/#1".into()),
objectives: vec!["lo-second".into(), "lo-first".into()],
targets: vec!["lo-second".into(), "lo-first".into()],
summary: Some("What a system is.".into()),
focus: Some("A worked instance of {lo-first}.".into()),
..Reading::default()
@@ -290,7 +473,7 @@ mod tests {
locator: Some("§1.9".into()),
path: Some("1/B/#9".into()),
role: ReadingRole::Supplemental,
objectives: vec!["lo-second".into()],
targets: vec!["lo-second".into()],
summary: Some("Background.".into()),
..Reading::default()
},
@@ -322,27 +505,27 @@ mod tests {
`KKW` [§6.1](https://example.org/kkw/6/A/#1)
: What a system is.
A worked instance of LO 1.
A worked instance of T 1.
<br>
_(LO 1, 2)_
_(T 1, 2)_
### Supplemental
`KKW` [§1.9](https://example.org/kkw/1/B/#9)
: Background.
<br>
_(LO 2)_
_(T 2)_
";
assert_eq!(md, expected);
}
#[test]
fn objective_numbers_follow_teaching_order_not_id_order() {
fn target_numbers_follow_teaching_order_not_id_order() {
// `lo-second` sorts first alphabetically and second by `order`.
let md = readings_markdown(&course(), "L1.1", Style::Quarto).expect("renders");
assert!(md.contains("_(LO 1, 2)_"));
assert!(md.contains("A worked instance of LO 1."));
assert!(md.contains("_(T 1, 2)_"));
assert!(md.contains("A worked instance of T 1."));
}
#[test]
@@ -374,6 +557,98 @@ After this lecture, you should be able to do the following.
assert_eq!(md, expected);
}
/// The fixture course with its two entries moved into the target registry
/// under a new objective, which is the shape a migrated course has.
fn tiered_course() -> CourseFile {
let mut c = course();
c.learning_objectives.insert(
"lo-binding".into(),
Objective {
text: "Quantify binding.".into(),
lectures: vec!["L1.1".into()],
order: Some(0),
..objective_defaults()
},
);
// The readings cite `lo-second` and `lo-first`, so the ids are kept and
// only the registry they live in changes. A real migration renames them
// to the `t-` spelling and rewrites the citations with them.
for (id, order) in [("lo-first", 1), ("lo-second", 2)] {
let objective = c.learning_objectives.remove(id).expect("fixture");
c.learning_targets.insert(
id.into(),
Target {
text: objective.text,
objective: "lo-binding".into(),
lectures: objective.lectures,
order: Some(order),
level_ceiling: None,
prerequisites: Vec::new(),
tags: Vec::new(),
assessed: true,
},
);
}
c
}
#[test]
fn the_objectives_page_lists_claims_and_not_the_targets_under_them() {
let md = objectives_markdown(&tiered_course(), "L1.1", Style::Quarto).expect("renders");
let expected = "\
## Learning objectives
After this lecture, you should be able to do the following.
(@) Quantify binding.
";
assert_eq!(
md, expected,
"the page is the short list, not all forty rows"
);
}
#[test]
fn the_targets_page_groups_targets_under_their_objective() {
let md = targets_markdown(&tiered_course(), "L1.1", Style::Quarto).expect("renders");
let expected = "\
## Learning targets
Each objective above is met by the specific things below. Exam questions are \
written against these.
### Quantify binding.
(@) objective lo-first
(@) objective lo-second
";
assert_eq!(md, expected);
}
#[test]
fn reading_numbers_point_at_targets() {
// Numbering runs over the targets page, because that is the tier a
// reading serves.
let readings = readings_markdown(&tiered_course(), "L1.1", Style::Quarto).expect("renders");
assert!(readings.contains("_(T 1, 2)_"), "{readings}");
assert!(readings.contains("A worked instance of T 1."));
}
#[test]
fn an_untiered_lecture_renders_the_same_list_on_both_pages() {
// Where no targets are declared, each objective is its own target, and
// neither page silently drops anything.
let c = course();
let objectives = objectives_markdown(&c, "L1.1", Style::Quarto).expect("renders");
let targets = targets_markdown(&c, "L1.1", Style::Quarto).expect("renders");
for text in ["objective lo-first", "objective lo-second"] {
assert!(objectives.contains(text), "{objectives}");
assert!(targets.contains(text), "{targets}");
}
}
#[test]
fn an_objective_with_no_level_still_appears() {
// Ungrouped, at the end, rather than silently dropped.
+7 -7
View File
@@ -390,13 +390,13 @@ fn solution_body(out: &mut String, item: &Item) {
/// The `Tests:` line naming the objectives this item measures.
fn objectives_line(out: &mut String, item: &Item, course: &CourseFile) {
if item.learning_objectives.is_empty() {
if item.learning_targets.is_empty() {
return;
}
let texts: Vec<String> = item
.learning_objectives
.learning_targets
.iter()
.map(|id| course.objective_text(id))
.map(|id| course.text_for(id))
.collect();
out.push_str(&format!("**Tests:** {}\n\n", texts.join("; ")));
}
@@ -542,7 +542,7 @@ items:
status: draft
level: 1
stem: At constant pressure, the heat exchanged equals which quantity?
learning_objectives: [lo-enthalpy]
learning_targets: [lo-enthalpy]
options:
- { id: A, text: "the enthalpy change", correct: true, feedback_student: "Right: P dV work is folded into H." }
- { id: B, text: "the internal energy change", misconception: "ignores expansion work" }
@@ -556,7 +556,7 @@ items:
level: 2
format: open_response
stem: Explain why, at constant pressure, the heat exchanged equals the enthalpy change.
learning_objectives: [lo-enthalpy]
learning_targets: [lo-enthalpy]
solution:
model_answer: "At constant pressure the P dV expansion work is folded into H = U + PV, so q_p is the change in H."
rubric:
@@ -599,7 +599,7 @@ items:
bonus: false,
key: vec!["A".into()],
level: None,
learning_objectives: Vec::new(),
learning_targets: Vec::new(),
credit_overrides: Default::default(),
dropped: false,
dropped_as: None,
@@ -613,7 +613,7 @@ items:
bonus: false,
key: Vec::new(),
level: None,
learning_objectives: Vec::new(),
learning_targets: Vec::new(),
credit_overrides: Default::default(),
dropped: false,
dropped_as: None,
+4 -4
View File
@@ -1326,7 +1326,7 @@ items:
level: 2
format: single_best_answer
stem: "The heat at constant pressure equals a change in what?"
learning_objectives: [lo-enthalpy]
learning_targets: [lo-enthalpy]
options:
- { id: A, text: "Enthalpy, $\\Delta H$", correct: true }
- { id: B, text: "Internal energy, $\\Delta U$", misconception: "Constant-volume result." }
@@ -1335,7 +1335,7 @@ items:
level: 3
format: open_response
stem: "Show why $q_p = \\Delta H$."
learning_objectives: [lo-enthalpy]
learning_targets: [lo-enthalpy]
solution:
model_answer: "From $H = U + PV$ at constant pressure, $q_p = \\Delta H$."
"#,
@@ -1374,7 +1374,7 @@ items:
bonus: false,
key: vec!["A".into()],
level: None,
learning_objectives: Vec::new(),
learning_targets: Vec::new(),
credit_overrides: Default::default(),
dropped: false,
dropped_as: None,
@@ -1388,7 +1388,7 @@ items:
bonus: false,
key: Vec::new(),
level: None,
learning_objectives: Vec::new(),
learning_targets: Vec::new(),
credit_overrides: Default::default(),
dropped: false,
dropped_as: None,
+67 -22
View File
@@ -36,7 +36,7 @@ use crate::course::CourseFile;
use crate::date::Date;
use crate::irt::Fit;
use crate::students::{Cohort, Mastery, StudentSummary};
use crate::taxonomy::Level;
use crate::taxonomy::{Level, Tier};
/// What to include in a student report.
#[derive(Debug, Clone)]
@@ -150,24 +150,58 @@ pub fn student(
out.push_str("| | Objective | You | Class | Items |\n|:--|:--|--:|--:|--:|\n");
for o in &summary.objectives {
let you = format!("{:.0}%", o.rate * 100.0);
out.push_str(&format!(
"| {} | {} | {} | {:.0}% | {} |\n",
o.status.symbol(),
escape_pipes(&o.text),
you,
o.cohort_rate * 100.0,
o.n_items
));
if o.tier == Tier::Objective {
// The classification, over every question that touched the
// objective.
let scope = if o.targets_total > 0 {
format!(
"{} ({} of {} targets tested)",
escape_pipes(&o.text),
o.targets_seen,
o.targets_total
)
} else {
escape_pipes(&o.text)
};
out.push_str(&format!(
"| {} | **{}** | {} | {:.0}% | {} |\n",
o.status.symbol(),
scope,
you,
o.cohort_rate * 100.0,
o.n_items
));
} else {
// A target row is evidence for the objective above it, so it
// carries no symbol: one question does not classify anything,
// and printing "✗" against one question invites exactly that
// reading.
out.push_str(&format!(
"| | ⤷ {} | {} | {:.0}% | {} |\n",
escape_pipes(&o.text),
you,
o.cohort_rate * 100.0,
o.n_items
));
}
}
out.push('\n');
out.push_str("✓ meeting · ~ developing · ✗ not yet · ? too few questions to tell\n\n");
if summary.objectives.iter().any(|o| o.tier == Tier::Target) {
out.push_str(
"Bold rows are the learning objectives. Indented rows are the learning targets \
inside each one, which is what individual questions were written against: \
they show where the marks went, and a single indented row is one question \
rather than a verdict.\n\n",
);
}
// The "too few questions" cases are an honest caveat about the exam, and
// saying so protects the student from over-reading a single data point.
let thin: Vec<&str> = summary
.objectives
.iter()
.filter(|o| o.status == Mastery::NotEnoughEvidence)
.filter(|o| o.tier == Tier::Objective && o.status == Mastery::NotEnoughEvidence)
.map(|o| o.text.as_str())
.collect();
if !thin.is_empty() {
@@ -236,7 +270,7 @@ pub fn student(
out.push_str("## Where to put your time\n\n");
out.push_str("In this order:\n\n");
for (i, id) in summary.focus.iter().take(4).enumerate() {
let text = course.objective_text(id);
let text = course.text_for(id);
out.push_str(&format!("{}. {}\n", i + 1, text));
}
out.push('\n');
@@ -250,10 +284,7 @@ pub fn student(
.map(|(id, _)| id.as_str())
.collect();
if !class_gaps.is_empty() {
let texts: Vec<String> = class_gaps
.iter()
.map(|id| course.objective_text(id))
.collect();
let texts: Vec<String> = class_gaps.iter().map(|id| course.text_for(id)).collect();
let refs: Vec<&str> = texts.iter().map(|s| s.as_str()).collect();
out.push_str(&format!(
"Most of the class also struggled with {}, so expect it to come back in class. \
@@ -268,7 +299,7 @@ pub fn student(
.strengths
.iter()
.take(4)
.map(|id| course.objective_text(id))
.map(|id| course.text_for(id))
.collect();
let refs: Vec<&str> = texts.iter().map(|s| s.as_str()).collect();
out.push_str(&format!("You have clearly got {}.\n\n", list(&refs)));
@@ -549,7 +580,7 @@ pub fn cohort(
for (id, rate) in &cohort.class_gaps {
out.push_str(&format!(
"| {} | {:.0}% |\n",
escape_pipes(&course.objective_text(id)),
escape_pipes(&course.text_for(id)),
rate * 100.0
));
}
@@ -576,7 +607,7 @@ pub fn cohort(
out.push('\n');
if let Some(bp) = &record.blueprint {
let drift = crate::select::check_blueprint(record);
let drift = crate::select::check_blueprint(record, course);
if !drift.is_empty() {
out.push_str("Blueprint drift:\n\n");
for d in &drift {
@@ -956,6 +987,10 @@ pub fn write_all_students(
/// Per-objective class rates as a compact table, for pasting into a syllabus
/// review or a curriculum committee document.
///
/// Objectives only. A committee document listing three hundred learning targets
/// is not read, and the target rates are the wrong number to put in front of one
/// anyway: each rests on one or two questions.
///
/// # Arguments
///
/// * `cohort` - the class.
@@ -965,7 +1000,7 @@ pub fn write_all_students(
///
/// A Markdown table.
pub fn objective_summary(cohort: &Cohort, course: &CourseFile) -> String {
let mut out = String::from("| Objective | Class rate |\n|:--|--:|\n");
let mut out = String::from("| Objective | Class rate | Items |\n|:--|--:|--:|\n");
let mut rows: Vec<(&String, &f64)> = cohort.objective_rates.iter().collect();
rows.sort_by(|a, b| {
a.1.partial_cmp(b.1)
@@ -973,10 +1008,20 @@ pub fn objective_summary(cohort: &Cohort, course: &CourseFile) -> String {
.then_with(|| a.0.cmp(b.0))
});
for (id, rate) in rows {
// Items behind the rate, because a rate without a denominator is what
// makes a committee table misleading.
let n = cohort
.students
.iter()
.flat_map(|s| s.objectives.iter())
.find(|o| &o.id == id)
.map(|o| o.n_items)
.unwrap_or(0);
out.push_str(&format!(
"| {} | {:.0}% |\n",
escape_pipes(&course.objective_text(id)),
rate * 100.0
"| {} | {:.0}% | {} |\n",
escape_pipes(&course.text_for(id)),
rate * 100.0,
n
));
}
out
+4 -4
View File
@@ -803,7 +803,7 @@ items:
level: 2
format: single_best_answer
stem: "The heat at constant pressure equals a change in what?"
learning_objectives: [lo-enthalpy]
learning_targets: [lo-enthalpy]
options:
- { id: A, text: "Enthalpy, $\\Delta H$", correct: true, feedback_student: "Right, $q_p = \\Delta H$." }
- { id: B, text: "Internal energy, $\\Delta U$", misconception: "Uses the constant-volume result.", explanation: "That holds only at constant volume." }
@@ -816,7 +816,7 @@ items:
level: 3
format: open_response
stem: "Show why $q_p = \\Delta H$."
learning_objectives: [lo-enthalpy]
learning_targets: [lo-enthalpy]
solution:
model_answer: "From $H = U + PV$ at constant pressure, $q_p = \\Delta H$."
explanation: |
@@ -863,7 +863,7 @@ items:
bonus: false,
key: vec!["A".into()],
level: None,
learning_objectives: Vec::new(),
learning_targets: Vec::new(),
credit_overrides: Default::default(),
dropped: false,
dropped_as: None,
@@ -877,7 +877,7 @@ items:
bonus: false,
key: Vec::new(),
level: None,
learning_objectives: Vec::new(),
learning_targets: Vec::new(),
credit_overrides: Default::default(),
dropped: false,
dropped_as: None,
+2 -2
View File
@@ -424,7 +424,7 @@ mod tests {
bonus: false,
key: vec!["A".into()],
level: None,
learning_objectives: Vec::new(),
learning_targets: Vec::new(),
credit_overrides: Default::default(),
dropped: true,
dropped_as: None,
@@ -438,7 +438,7 @@ mod tests {
bonus: false,
key: vec!["B".into()],
level: None,
learning_objectives: Vec::new(),
learning_targets: Vec::new(),
credit_overrides: Default::default(),
dropped: false,
dropped_as: None,
+1 -1
View File
@@ -869,4 +869,4 @@ mod tests {
assert_eq!(file.resolve(Variant::Exam).reveal, Reveal::Nothing);
assert_eq!(file.resolve(Variant::Key).reveal, Reveal::Everything);
}
}
}
+11 -11
View File
@@ -322,7 +322,7 @@ pub fn student_value(diagnostic: &StudentDiagnostic, config: &RenderConfig) -> V
value.insert_some("level", question.level.map(|l| Value::Int(l as i64)));
value.insert(
"objectives",
Value::Array(question.objectives.iter().map(|o| Value::str(o)).collect()),
Value::Array(question.objectives.iter().map(Value::str).collect()),
);
value.insert_some("correct", question.correct.map(Value::Bool));
value.insert("credit", Value::Float(question.credit));
@@ -350,7 +350,7 @@ pub fn student_value(diagnostic: &StudentDiagnostic, config: &RenderConfig) -> V
}
value.insert(
"taught-in",
Value::Array(question.taught_in.iter().map(|s| Value::str(s)).collect()),
Value::Array(question.taught_in.iter().map(Value::str).collect()),
);
value.insert(
"review",
@@ -741,7 +741,7 @@ pub fn cohort_value(diagnostic: &CohortDiagnostic, config: &RenderConfig) -> Val
out.insert(
"blueprint",
Value::Array(diagnostic.blueprint.iter().map(|s| Value::str(s)).collect()),
Value::Array(diagnostic.blueprint.iter().map(Value::str).collect()),
);
out.insert(
@@ -767,7 +767,7 @@ pub fn cohort_value(diagnostic: &CohortDiagnostic, config: &RenderConfig) -> Val
out.insert(
"warnings",
Value::Array(diagnostic.warnings.iter().map(|s| Value::str(s)).collect()),
Value::Array(diagnostic.warnings.iter().map(Value::str).collect()),
);
out
@@ -793,7 +793,7 @@ fn triage_value(row: &crate::diagnostic::TriageRow, content: bool) -> Value {
);
value.insert(
"taught-in",
Value::Array(row.taught_in.iter().map(|t| Value::str(t)).collect()),
Value::Array(row.taught_in.iter().map(Value::str).collect()),
);
value.insert_some("option", row.option.as_ref().map(Value::str));
value.insert_some("option-share", row.option_share.map(Value::Float));
@@ -845,7 +845,7 @@ fn cohort_question_value(question: &CohortQuestionRow, content: bool) -> Value {
value.insert_some("level", question.level.map(|l| Value::Int(l as i64)));
value.insert(
"objectives",
Value::Array(question.objectives.iter().map(|o| Value::str(o)).collect()),
Value::Array(question.objectives.iter().map(Value::str).collect()),
);
value.insert(
"objective-texts",
@@ -859,11 +859,11 @@ fn cohort_question_value(question: &CohortQuestionRow, content: bool) -> Value {
);
value.insert(
"taught-in",
Value::Array(question.taught_in.iter().map(|t| Value::str(t)).collect()),
Value::Array(question.taught_in.iter().map(Value::str).collect()),
);
value.insert(
"lectures",
Value::Array(question.lectures.iter().map(|l| Value::str(l)).collect()),
Value::Array(question.lectures.iter().map(Value::str).collect()),
);
value.insert("difficulty-band", Value::str(&question.difficulty_band));
value.insert(
@@ -876,7 +876,7 @@ fn cohort_question_value(question: &CohortQuestionRow, content: bool) -> Value {
value.insert("blank-rate", Value::Float(question.blank_rate));
value.insert(
"key",
Value::Array(question.key.iter().map(|k| Value::str(k)).collect()),
Value::Array(question.key.iter().map(Value::str).collect()),
);
value.insert(
"options",
@@ -899,7 +899,7 @@ fn cohort_question_value(question: &CohortQuestionRow, content: bool) -> Value {
);
value.insert(
"flags",
Value::Array(question.flags.iter().map(|f| Value::str(f)).collect()),
Value::Array(question.flags.iter().map(Value::str).collect()),
);
value.insert(
"notes",
@@ -1236,4 +1236,4 @@ mod tests {
assert!(text.contains("reliability"));
assert!(!text.contains("stem"));
}
}
}
+14 -18
View File
@@ -50,7 +50,7 @@ pub struct Payload {
pub form: FormInfo,
/// Counts and sums, so a template does not have to derive them.
pub totals: Totals,
/// Learning objectives referenced by the printed items, by id.
/// Learning objectives and targets referenced by the printed items, by id.
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub objectives: BTreeMap<String, Objective>,
/// Shared stimuli, by id. Populated when the render config says stimuli are
@@ -268,9 +268,9 @@ pub struct Question {
/// letter. Omitted unless the config reveals the key.
#[serde(skip_serializing_if = "Option::is_none")]
pub credit_overrides: Option<BTreeMap<String, f64>>,
/// Learning objective ids.
/// Learning target ids.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub learning_objectives: Vec<String>,
pub learning_targets: Vec<String>,
/// Topic tags.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub topics: Vec<String>,
@@ -386,10 +386,10 @@ pub fn build(
.or_insert(0) += 1;
}
let objectives = if placement.learning_objectives.is_empty() {
item.learning_objectives.clone()
let objectives = if placement.learning_targets.is_empty() {
item.learning_targets.clone()
} else {
placement.learning_objectives.clone()
placement.learning_targets.clone()
};
if config.fields.objectives {
objective_ids.extend(objectives.iter().cloned());
@@ -467,7 +467,7 @@ pub fn build(
options,
key,
credit_overrides,
learning_objectives: if config.fields.objectives {
learning_targets: if config.fields.objectives {
objectives
} else {
Vec::new()
@@ -501,14 +501,10 @@ pub fn build(
let objectives = objective_ids
.into_iter()
.filter_map(|id| {
course.learning_objectives.get(&id).map(|o| {
(
id,
Objective {
text: markup::to_typst(&o.text),
unit: o.unit.clone(),
},
)
(course.is_objective(&id) || course.is_target(&id)).then(|| {
let text = markup::to_typst(&course.text_for(&id));
let unit = course.objective_unit(&id).map(str::to_string);
(id, Objective { text, unit })
})
})
.collect();
@@ -960,12 +956,12 @@ fn question_value(question: &Question, config: &RenderConfig) -> Value {
}),
);
if !question.learning_objectives.is_empty() {
if !question.learning_targets.is_empty() {
root.insert(
"learning-objectives",
"learning-targets",
Value::Array(
question
.learning_objectives
.learning_targets
.iter()
.map(|s| Value::str(s.as_str()))
.collect(),