fix: seals after changes

This commit is contained in:
alexm committed 2026-09-22 00:58:32 -04:00
1 parent d3f21e913b
commit cea9769022
9 files changed
+106 -12

No files matched your search

+35
View File
@@ -305,6 +305,28 @@ pub struct Placement {
/// contribute.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dropped_as: Option<DropStyle>,
/// Set only when the item was pulled *before* the paper was printed.
///
/// `dropped` on its own means what its own documentation says: the item was
/// printed, students answered it, and it was then taken out of scoring.
/// Such an item keeps its printed position, because it occupied one on the
/// page the students held, and the responses that come back are numbered
/// around it.
///
/// An item pulled before printing never occupied a position, so every later
/// question moves up one. That case has to be distinguished, and it cannot
/// be inferred: both look identical in the record. Getting it wrong is not
/// a cosmetic error. Sealing a post-administration drop as if it had never
/// been printed renumbers every question after it, so each response is
/// attributed to the wrong item, the statistics for those items are
/// computed from answers to different questions, and nothing in the output
/// looks obviously wrong.
///
/// Practically: leave this alone when you discover a bad question after the
/// exam, which is the common case. Set it when you cut a question from the
/// draft and reprinted.
#[serde(default, skip_serializing_if = "is_false")]
pub dropped_before_printing: bool,
}
/// How a dropped item was handled on the grading platform.
@@ -327,6 +349,19 @@ impl Placement {
pub fn dropped_with_credit(&self) -> bool {
self.dropped && self.dropped_as == Some(DropStyle::FullCredit)
}
/// Whether this placement occupied a printed position on the paper.
///
/// Everything that lays out a page or reads a page back goes through this,
/// so the printed form, the seal, and the decoder cannot disagree about
/// which question sat where.
///
/// # Returns
///
/// `true` unless the item was pulled before printing.
pub fn was_printed(&self) -> bool {
!(self.dropped && self.dropped_before_printing)
}
}
impl AssessmentFile {
+5 -4
View File
@@ -518,12 +518,13 @@ fn sealed_item(
fn sealed_form(catalog: &Catalog, record: &AssessmentFile, form: &Form) -> Result<SealedForm> {
let mut questions = Vec::new();
// Dropped placements are not printed, so they take no printed position. A
// drop recorded before sealing therefore shifts every later position, exactly
// as it shifts them on the page.
// Only an item pulled before printing takes no printed position. An item
// dropped from scoring after the exam was on the page and keeps its place,
// so re-sealing after a drop describes the same paper the students held
// rather than renumbering everything after it.
let printed: Vec<Placement> = select::layout(record, form)
.into_iter()
.filter(|p| !p.dropped)
.filter(|p| p.was_printed())
.collect();
for (index, placement) in printed.iter().enumerate() {