feat: improve dropped question support
This commit is contained in:
18 files changed
+302
-86
No files matched your search
@@ -351,6 +351,7 @@ pub fn ingest(
|
||||
topics: Vec::new(),
|
||||
bonus: false,
|
||||
dropped: false,
|
||||
dropped_full_credit: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,6 +709,7 @@ mod tests {
|
||||
topics: Vec::new(),
|
||||
bonus: false,
|
||||
dropped: false,
|
||||
dropped_full_credit: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -659,6 +659,7 @@ pub fn to_responses(questions: &[Question], ctx: &Context) -> Import {
|
||||
topics: Vec::new(),
|
||||
bonus,
|
||||
dropped: false,
|
||||
dropped_full_credit: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+48
-5
@@ -108,10 +108,26 @@ pub struct Response {
|
||||
pub bonus: bool,
|
||||
/// Whether the item was dropped after the fact.
|
||||
pub dropped: bool,
|
||||
/// Whether that drop was applied by crediting every option, so the item is
|
||||
/// still part of the points of record even though it is out of the
|
||||
/// statistics.
|
||||
///
|
||||
/// Written by [`ResponseSet::enrich`] from the placement's `dropped_as`.
|
||||
#[serde(default)]
|
||||
pub dropped_full_credit: bool,
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Whether this row should count toward scored totals and item statistics.
|
||||
/// Whether this row counts as evidence.
|
||||
///
|
||||
/// Evidence means item statistics, objective mastery, level rates, and the
|
||||
/// IRT fit. A dropped item is never evidence, however the drop was applied:
|
||||
/// an item everyone was given has no variance to contribute and would only
|
||||
/// flatter the objective it was written against.
|
||||
///
|
||||
/// This is deliberately not the same question as [`Response::scores`]. The
|
||||
/// two were one predicate until dropping a question stopped always meaning
|
||||
/// removing it.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
@@ -120,6 +136,21 @@ impl Response {
|
||||
!self.bonus && !self.dropped
|
||||
}
|
||||
|
||||
/// Whether this row counts toward the points of record.
|
||||
///
|
||||
/// A question dropped by crediting every option still sits in the student's
|
||||
/// total on the platform, and a report that disagreed with the platform
|
||||
/// about a student's percentage would be worse than no report. So a
|
||||
/// full-credit drop stays in both the numerator and the denominator here,
|
||||
/// while a removed drop leaves both.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// `true` when the row belongs in the score.
|
||||
pub fn scores(&self) -> bool {
|
||||
!self.bonus && (!self.dropped || self.dropped_full_credit)
|
||||
}
|
||||
|
||||
/// The response coded for a dichotomous model.
|
||||
///
|
||||
/// Partial credit is rounded toward the majority: a half-credit response is
|
||||
@@ -188,7 +219,11 @@ impl ResponseSet {
|
||||
set.into_iter().map(|s| s.to_string()).collect()
|
||||
}
|
||||
|
||||
/// The distinct item numbers that count toward the scored total, sorted.
|
||||
/// The distinct item numbers that count as evidence, sorted.
|
||||
///
|
||||
/// Named for the scored total it once described; it is the analysis matrix's
|
||||
/// item list, so it uses [`Response::counts`] and excludes every dropped
|
||||
/// item. [`ResponseSet::points_available`] is the scoring denominator.
|
||||
pub fn scored_items(&self) -> Vec<u32> {
|
||||
let set: BTreeSet<u32> = self
|
||||
.rows
|
||||
@@ -247,11 +282,12 @@ impl ResponseSet {
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The sum of `score` over scored, undropped items.
|
||||
/// The sum of `score` over the items that count toward the score, which
|
||||
/// includes a question dropped by crediting every option.
|
||||
pub fn scored_total(&self, key: &str) -> f64 {
|
||||
self.rows
|
||||
.iter()
|
||||
.filter(|r| r.student_key == key && r.counts())
|
||||
.filter(|r| r.student_key == key && r.scores())
|
||||
.map(|r| r.score)
|
||||
.sum()
|
||||
}
|
||||
@@ -269,7 +305,7 @@ impl ResponseSet {
|
||||
/// for each item so a student who skipped an item still has a denominator.
|
||||
pub fn points_available(&self) -> f64 {
|
||||
let mut per_item: BTreeMap<u32, f64> = BTreeMap::new();
|
||||
for r in self.rows.iter().filter(|r| r.counts()) {
|
||||
for r in self.rows.iter().filter(|r| r.scores()) {
|
||||
let e = per_item.entry(r.item_number).or_insert(0.0);
|
||||
if r.points_possible > *e {
|
||||
*e = r.points_possible;
|
||||
@@ -382,6 +418,7 @@ impl ResponseSet {
|
||||
r.item_version = p.version;
|
||||
r.bonus = r.bonus || p.bonus;
|
||||
r.dropped = r.dropped || p.dropped;
|
||||
r.dropped_full_credit = r.dropped_full_credit || p.dropped_with_credit();
|
||||
if let Some(points) = p.points {
|
||||
// The record is authoritative for points as administered; the
|
||||
// export sometimes carries a stale maximum.
|
||||
@@ -636,6 +673,9 @@ pub struct FlatResponse {
|
||||
/// Comma-joined eliminated letters in the bank's lettering.
|
||||
#[serde(default)]
|
||||
pub eliminated_source: String,
|
||||
/// Whether a dropped item was dropped by crediting every option.
|
||||
#[serde(default)]
|
||||
pub dropped_full_credit: bool,
|
||||
}
|
||||
|
||||
impl FlatResponse {
|
||||
@@ -656,6 +696,7 @@ impl FlatResponse {
|
||||
assessment_id: r.assessment_id.clone(),
|
||||
date: r.date.map(|d| d.to_string()).unwrap_or_default(),
|
||||
form: r.form.clone().unwrap_or_default(),
|
||||
dropped_full_credit: r.dropped_full_credit,
|
||||
form_position: r.form_position.unwrap_or(0),
|
||||
student_key: r.student_key.clone(),
|
||||
sid: r.sid.clone().unwrap_or_default(),
|
||||
@@ -709,6 +750,7 @@ impl FlatResponse {
|
||||
assessment_id: self.assessment_id.clone(),
|
||||
date: self.date.parse().ok(),
|
||||
form: none_if_empty(&self.form),
|
||||
dropped_full_credit: self.dropped_full_credit,
|
||||
form_position: if self.form_position == 0 {
|
||||
None
|
||||
} else {
|
||||
@@ -792,6 +834,7 @@ mod tests {
|
||||
topics: vec![],
|
||||
bonus: false,
|
||||
dropped: false,
|
||||
dropped_full_credit: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -564,6 +564,7 @@ mod tests {
|
||||
topics: vec![],
|
||||
bonus: false,
|
||||
dropped: false,
|
||||
dropped_full_credit: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ pub fn schema() -> Schema {
|
||||
Field::new("bonus", DataType::Boolean, false),
|
||||
Field::new("dropped", DataType::Boolean, false),
|
||||
Field::new("form_position", DataType::UInt32, false),
|
||||
Field::new("dropped_full_credit", DataType::Boolean, false),
|
||||
Field::new("selected_source", DataType::Utf8, false),
|
||||
Field::new("eliminated_source", DataType::Utf8, false),
|
||||
])
|
||||
@@ -124,6 +125,7 @@ fn to_batch(rows: &[FlatResponse]) -> Result<RecordBatch> {
|
||||
boolc(|r| r.bonus),
|
||||
boolc(|r| r.dropped),
|
||||
u32c(|r| r.form_position),
|
||||
boolc(|r| r.dropped_full_credit),
|
||||
s(|r| &r.selected_source),
|
||||
s(|r| &r.eliminated_source),
|
||||
];
|
||||
@@ -256,6 +258,11 @@ fn from_batch(batch: &RecordBatch, path: &Path) -> Result<Vec<FlatResponse>> {
|
||||
.column_by_name(name)
|
||||
.and_then(|c| c.as_any().downcast_ref::<UInt32Array>())
|
||||
};
|
||||
let optional_bools = |name: &str| -> Option<&BooleanArray> {
|
||||
batch
|
||||
.column_by_name(name)
|
||||
.and_then(|c| c.as_any().downcast_ref::<BooleanArray>())
|
||||
};
|
||||
|
||||
let administration_id = strings("administration_id")?;
|
||||
let course = strings("course")?;
|
||||
@@ -284,6 +291,7 @@ fn from_batch(batch: &RecordBatch, path: &Path) -> Result<Vec<FlatResponse>> {
|
||||
let dropped = bools("dropped")?;
|
||||
|
||||
let form_position = optional_uints("form_position");
|
||||
let dropped_full_credit = optional_bools("dropped_full_credit");
|
||||
let selected_source = optional_strings("selected_source");
|
||||
let eliminated_source = optional_strings("eliminated_source");
|
||||
|
||||
@@ -322,6 +330,7 @@ fn from_batch(batch: &RecordBatch, path: &Path) -> Result<Vec<FlatResponse>> {
|
||||
topics: topics.value(i).to_string(),
|
||||
bonus: bonus.value(i),
|
||||
dropped: dropped.value(i),
|
||||
dropped_full_credit: dropped_full_credit.map(|a| a.value(i)).unwrap_or(false),
|
||||
});
|
||||
}
|
||||
Ok(out)
|
||||
@@ -367,6 +376,7 @@ mod tests {
|
||||
topics: "kinetics".into(),
|
||||
bonus: false,
|
||||
dropped: false,
|
||||
dropped_full_credit: false,
|
||||
form_position: 0,
|
||||
selected_source: String::new(),
|
||||
eliminated_source: String::new(),
|
||||
|
||||
Reference in new issue
Block a user