feat(render): 2.1 lecture page, glossary page, and student reports

Derive each glossary entry's first lecture from teaching order and split
a lecture's terms into new and earlier. Add `coursebank lecture page`
(objectives with descriptions, targets with explanations and ceilings
named by policy.levels, terms, equations, numbers, common mistakes,
readings with minutes, materials) and `coursebank lecture glossary`.
Render brace references in student prose as links, values, quoted
beliefs, or target numbers. Student reports, Markdown and Typst, show
what meeting each target looks like, the correction for a registry
misconception, and group misses that share one.

A test renders every student-facing output from the example and checks
that no authoring, notes_private, evidence, conflicts, or status text
reaches it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
alexmandClaude committed 2026-11-16 12:15:15 -05:00
1 parent b8fdf4d6a8
commit 50a1e083c1
10 files changed
+1612 -13

No files matched your search

+101
View File
@@ -181,6 +181,10 @@ pub struct StudentDiagnostic {
/// One row per question, with no question in it.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub questions: Vec<QuestionRow>,
/// Registry mistakes behind more than one missed question, so the report
/// can group those misses under the one thing to fix.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub mistakes: Vec<MistakeGroup>,
/// Questions thrown out, in number order.
///
/// Reported separately from the question rows so the document can say once,
@@ -337,6 +341,41 @@ pub struct Measured {
pub objective: Option<String>,
/// The target the question was written against.
pub target: String,
/// The target's explanation, with references rendered as words: what
/// meeting it looks like, which is what to practise towards.
#[serde(skip_serializing_if = "Option::is_none")]
pub explanation: Option<String>,
}
/// A named mistake behind a student's answer, from the course's misconception
/// registry. Student-facing: the belief and its correction are written for the
/// student.
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct Mistake {
/// The misconception id.
pub id: String,
/// The wrong idea as a student holds it. Absent when the chosen option
/// carries its own misconception text, which overrides the registry's for
/// that item and already reaches the student as feedback.
#[serde(skip_serializing_if = "Option::is_none")]
pub belief: Option<String>,
/// Why it fails and what is true instead.
pub correction: String,
}
/// A mistake that more than one missed question drew on.
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct MistakeGroup {
/// The misconception id.
pub id: String,
/// The registry's belief.
pub belief: String,
/// The registry's correction.
pub correction: String,
/// The questions, by recorded number.
pub questions: Vec<u32>,
}
/// One question, described without being reproduced.
@@ -397,6 +436,10 @@ pub struct QuestionRow {
/// The worked solution, when [`Options::solutions`] is on.
#[serde(skip_serializing_if = "Option::is_none")]
pub worked: Option<String>,
/// The registry misconception the chosen option encodes, with its
/// correction, when [`Options::feedback`] is on.
#[serde(skip_serializing_if = "Option::is_none")]
pub mistake: Option<Mistake>,
/// Where the material was taught.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub taught_in: Vec<String>,
@@ -678,6 +721,7 @@ pub fn student(
objectives,
strengths,
focus,
mistakes: shared_mistakes(&questions, course),
questions,
dropped_questions,
review_lectures,
@@ -706,6 +750,7 @@ fn question_row(
let mut hint = None;
let mut misconception = None;
let mut worked = None;
let mut mistake = None;
let mut taught_in = Vec::new();
let mut review = Vec::new();
@@ -714,6 +759,20 @@ fn question_row(
if missed {
if let Some(letter) = row.chosen().first() {
if let Some(choice) = entry.item.option(letter) {
if opts.feedback {
let course = &catalog.course;
mistake = choice.misconception_id.as_deref().and_then(|id| {
let registered = course.misconceptions.get(id)?;
Some(Mistake {
id: id.to_string(),
belief: choice
.misconception
.is_none()
.then(|| course.plain_refs(&registered.belief)),
correction: course.plain_refs(&registered.correction),
})
});
}
if opts.feedback {
// `student_text` falls back to `explanation`, which is
// written for a grader and often names the right
@@ -783,6 +842,11 @@ fn question_row(
// objective is left out.
objective: (objective != id).then(|| course.text_for(objective)),
target: course.text_for(id),
explanation: course
.learning_targets
.get(id)
.and_then(|t| t.explanation.as_deref())
.map(|e| course.plain_refs(e)),
}
})
.collect()
@@ -804,11 +868,47 @@ fn question_row(
hint,
misconception,
worked,
mistake,
taught_in,
review,
}
}
/// The registry mistakes that more than one of a student's missed questions
/// drew on, so a report can name the thing to fix once.
///
/// # Arguments
///
/// * `questions` - the student's question rows.
/// * `course` - the course, for the registry's wording.
///
/// # Returns
///
/// One group per shared misconception, in order of its first question.
pub fn shared_mistakes(questions: &[QuestionRow], course: &CourseFile) -> Vec<MistakeGroup> {
let mut groups: Vec<MistakeGroup> = Vec::new();
for q in questions {
let Some(mistake) = &q.mistake else {
continue;
};
if let Some(group) = groups.iter_mut().find(|g| g.id == mistake.id) {
group.questions.push(q.number);
continue;
}
let Some(entry) = course.misconceptions.get(&mistake.id) else {
continue;
};
groups.push(MistakeGroup {
id: mistake.id.clone(),
belief: course.plain_refs(&entry.belief),
correction: course.plain_refs(&entry.correction),
questions: vec![q.number],
});
}
groups.retain(|g| g.questions.len() > 1);
groups
}
/// Resolves an item's `review` citations against the course reference registry.
///
/// # Arguments
@@ -2565,6 +2665,7 @@ mod tests {
strengths: Vec::new(),
focus: Vec::new(),
questions: Vec::new(),
mistakes: Vec::new(),
dropped_questions: Vec::new(),
review_lectures: Vec::new(),
study: Vec::new(),