feat: improvement
This commit is contained in:
18 files changed
+2538
-108
No files matched your search
@@ -535,6 +535,27 @@ impl Merge {
|
||||
}
|
||||
}
|
||||
|
||||
// Teaching order, from the two sequences that already declare it: the
|
||||
// lectures in course order, and each lecture's `teaches` list. This is
|
||||
// what lets an objective stop carrying a hand-kept integer.
|
||||
let mut position = 0u32;
|
||||
let ordered: Vec<String> = self.lectures.keys().cloned().collect();
|
||||
for lecture_id in ordered {
|
||||
let teaches = self
|
||||
.lectures
|
||||
.get(&lecture_id)
|
||||
.map(|l| l.teaches.clone())
|
||||
.unwrap_or_default();
|
||||
for objective_id in teaches {
|
||||
position += 1;
|
||||
if let Some(objective) = self.objectives.get_mut(&objective_id) {
|
||||
if objective.order.is_none() {
|
||||
objective.order = Some(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A target with no lecture of its own is taught wherever its objective
|
||||
// is. Collected first: the read of `objectives` and the write to
|
||||
// `targets` cannot overlap in one pass.
|
||||
@@ -800,6 +821,93 @@ units:
|
||||
assert!(course.origin("nothing-like-this").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teaching_order_is_derived_from_the_two_sequences_that_declare_it() {
|
||||
let root = tmp("order");
|
||||
write(&root, "course.yaml", ROOT);
|
||||
write(
|
||||
&root,
|
||||
"lectures/l-1-2.yaml",
|
||||
"lectures:\n L1.2:\n title: One\n teaches: [lo-second, lo-first]\n",
|
||||
);
|
||||
write(
|
||||
&root,
|
||||
"lectures/l-1-3.yaml",
|
||||
"lectures:\n L1.3:\n title: Two\n teaches: [lo-third]\n",
|
||||
);
|
||||
write(
|
||||
&root,
|
||||
"objectives/lo-first.yaml",
|
||||
r#"learning_objectives:
|
||||
lo-first:
|
||||
text: A.
|
||||
lo-second:
|
||||
text: B.
|
||||
lo-third:
|
||||
text: C.
|
||||
"#,
|
||||
);
|
||||
|
||||
let course = assemble(&root).unwrap();
|
||||
// Position in `teaches`, not id order: the lecture lists `lo-second`
|
||||
// first and that is what teaching it first means.
|
||||
assert_eq!(course.learning_objectives["lo-second"].order, Some(1));
|
||||
assert_eq!(course.learning_objectives["lo-first"].order, Some(2));
|
||||
assert_eq!(course.learning_objectives["lo-third"].order, Some(3));
|
||||
assert_eq!(
|
||||
course.lecture_objectives("L1.2"),
|
||||
vec!["lo-second", "lo-first"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn targets_print_by_ceiling_rather_than_in_a_sequence() {
|
||||
let root = tmp("target-order");
|
||||
write(&root, "course.yaml", ROOT);
|
||||
write(
|
||||
&root,
|
||||
"lectures/l-1-2.yaml",
|
||||
"lectures:\n L1.2:\n title: One\n teaches: [lo-x]\n",
|
||||
);
|
||||
write(
|
||||
&root,
|
||||
"objectives/lo-x.yaml",
|
||||
r#"learning_objectives:
|
||||
lo-x:
|
||||
text: A.
|
||||
level_ceiling: 3
|
||||
learning_targets:
|
||||
t-predict:
|
||||
text: Predict the effect.
|
||||
objective: lo-x
|
||||
level_ceiling: 3
|
||||
t-define:
|
||||
text: Define the term.
|
||||
objective: lo-x
|
||||
level_ceiling: 1
|
||||
t-explain:
|
||||
text: Explain the mechanism.
|
||||
objective: lo-x
|
||||
level_ceiling: 2
|
||||
"#,
|
||||
);
|
||||
|
||||
let course = assemble(&root).unwrap();
|
||||
assert!(course.validate().is_empty(), "{:?}", course.validate());
|
||||
|
||||
// Shallowest first, which is the order the study methods apply in:
|
||||
// recall, then explanation, then variations. Not id order, which would
|
||||
// put `t-define` after `t-predict` for no reason at all.
|
||||
assert_eq!(
|
||||
course.targets("lo-x"),
|
||||
vec!["t-define", "t-explain", "t-predict"]
|
||||
);
|
||||
|
||||
// A target with no ceiling of its own inherits the objective's, so it
|
||||
// sorts where that puts it.
|
||||
assert_eq!(course.learning_targets["t-define"].order, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teaching_the_same_objective_from_two_lectures_unions() {
|
||||
let root = tmp("union");
|
||||
|
||||
Reference in new issue
Block a user