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

+85
View File
@@ -818,6 +818,91 @@ impl super::CourseFile {
out
}
/// Replaces each brace reference in prose with whatever the caller renders
/// for it.
///
/// A reference is a brace pair around a declared id: a prefixed glossary
/// id (`{term-...}`, `{eq-...}`, `{val-...}`, `{mis-...}`) or any declared
/// objective or target id, which is the 2.0 rule and keeps unprefixed
/// target ids working. Anything else, `$U_\text{final}$` or `10^{59}`
/// included, passes through untouched.
///
/// # Arguments
///
/// * `prose` - the field to expand.
/// * `render` - called with each referenced id.
///
/// # Returns
///
/// The prose with references replaced.
pub fn expand_refs(&self, prose: &str, render: impl Fn(&str) -> String) -> String {
let mut out = String::with_capacity(prose.len());
let mut rest = prose;
while let Some(open) = rest.find('{') {
let (head, tail) = rest.split_at(open);
out.push_str(head);
let Some(close) = tail.find('}') else {
out.push_str(tail);
return out;
};
let name = &tail[1..close];
if self.resolves(name)
|| self.learning_objectives.contains_key(name)
|| self.learning_targets.contains_key(name)
{
out.push_str(&render(name));
} else {
out.push_str(&tail[..=close]);
}
rest = &tail[close + 1..];
}
out.push_str(rest);
out
}
/// Prose with every reference rendered as plain words, for a report or a
/// terminal: a term as its name, an equation as its name, a value as its
/// `say`, a misconception as its belief in quotation marks, and an
/// objective or target as its text.
///
/// # Arguments
///
/// * `prose` - the field to expand.
///
/// # Returns
///
/// The prose, with whitespace runs collapsed to single spaces.
pub fn plain_refs(&self, prose: &str) -> String {
let collapsed = prose.split_whitespace().collect::<Vec<_>>().join(" ");
self.expand_refs(&collapsed, |id| self.ref_words(id))
}
/// The words a reference stands for, as [`plain_refs`](Self::plain_refs)
/// prints them.
///
/// # Arguments
///
/// * `id` - a declared id of any registry.
///
/// # Returns
///
/// The words.
pub fn ref_words(&self, id: &str) -> String {
if let Some(t) = self.terms.get(id) {
return t.term.clone();
}
if let Some(e) = self.equations.get(id) {
return e.name.clone();
}
if let Some(v) = self.values.get(id) {
return v.say.clone();
}
if let Some(m) = self.misconceptions.get(id) {
return format!("\u{201c}{}\u{201d}", m.belief.trim());
}
self.text_for(id)
}
/// A lecture's targets in teaching order: its objectives in the order the
/// lecture page prints them, each objective's targets by ceiling and then
/// id, and then any target the lecture covers whose objective it does not