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:
10 files changed
+1612
-13
No files matched your search
@@ -336,7 +336,26 @@ pub fn student(
|
||||
course.text_for(objective)
|
||||
));
|
||||
}
|
||||
// What meeting the target looks like, which is what to
|
||||
// practise towards.
|
||||
if let Some(explanation) = course
|
||||
.learning_targets
|
||||
.get(target)
|
||||
.and_then(|t| t.explanation.as_deref())
|
||||
{
|
||||
out.push_str(&format!(
|
||||
"What meeting it looks like: {}\n\n",
|
||||
course.plain_refs(explanation)
|
||||
));
|
||||
}
|
||||
}
|
||||
// A named registry misconception carries a student-facing belief
|
||||
// and correction. The option's own text, when it has one, wins for
|
||||
// the belief, and keeps the sentence it has always had.
|
||||
let registry = m
|
||||
.misconception_id
|
||||
.as_deref()
|
||||
.and_then(|id| course.misconceptions.get(id));
|
||||
if let Some(text) = &m.feedback {
|
||||
out.push_str(&format!("{text}\n\n"));
|
||||
} else if let Some(misconception) = &m.misconception {
|
||||
@@ -344,10 +363,38 @@ pub fn student(
|
||||
"The option you chose is the one students pick when {misconception}\n\n"
|
||||
));
|
||||
}
|
||||
if let Some(entry) = registry {
|
||||
if m.misconception.is_none() {
|
||||
out.push_str(&format!(
|
||||
"This answer reflects a common mistake: *{}*\n\n",
|
||||
course.plain_refs(&entry.belief)
|
||||
));
|
||||
}
|
||||
out.push_str(&format!("{}\n\n", course.plain_refs(&entry.correction)));
|
||||
}
|
||||
if !m.study.is_empty() {
|
||||
out.push_str(&format!("Review: {}\n\n", m.study.join("; ")));
|
||||
}
|
||||
}
|
||||
|
||||
// The same mistake behind more than one answer is worth more than any
|
||||
// one question: it is the thing to fix once.
|
||||
let groups = shared_mistakes(&summary.missed);
|
||||
if !groups.is_empty() {
|
||||
out.push_str("## The same mistake, more than once\n\n");
|
||||
for (id, numbers) in groups {
|
||||
let Some(entry) = course.misconceptions.get(id) else {
|
||||
continue;
|
||||
};
|
||||
let numbers: Vec<String> = numbers.iter().map(u32::to_string).collect();
|
||||
out.push_str(&format!(
|
||||
"**Questions {}**: *{}*\n\n{}\n\n",
|
||||
numbers.join(", "),
|
||||
course.plain_refs(&entry.belief),
|
||||
course.plain_refs(&entry.correction)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(closing) = &opts.closing {
|
||||
@@ -366,6 +413,31 @@ pub fn student(
|
||||
out
|
||||
}
|
||||
|
||||
/// Registry misconceptions that more than one missed question drew on.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `missed` - a student's missed items.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Each shared misconception id with the question numbers, in order of the
|
||||
/// first question that drew it.
|
||||
pub fn shared_mistakes(missed: &[crate::students::MissedItem]) -> Vec<(&str, Vec<u32>)> {
|
||||
let mut groups: Vec<(&str, Vec<u32>)> = Vec::new();
|
||||
for m in missed {
|
||||
let Some(id) = m.misconception_id.as_deref() else {
|
||||
continue;
|
||||
};
|
||||
match groups.iter_mut().find(|(g, _)| *g == id) {
|
||||
Some((_, numbers)) => numbers.push(m.number),
|
||||
None => groups.push((id, vec![m.number])),
|
||||
}
|
||||
}
|
||||
groups.retain(|(_, numbers)| numbers.len() > 1);
|
||||
groups
|
||||
}
|
||||
|
||||
/// Writes the instructor's report on one administration.
|
||||
///
|
||||
/// # Arguments
|
||||
|
||||
Reference in new issue
Block a user