refactor: splitting models
This commit is contained in:
+9
-10
@@ -26,7 +26,7 @@ use crate::assessment::AssessmentFile;
|
||||
use crate::catalog::Catalog;
|
||||
use crate::date::Date;
|
||||
use crate::error::{Error, Result};
|
||||
use crate::responses::{administration_id, Response, ResponseSet};
|
||||
use crate::responses::{Response, ResponseSet, administration_id};
|
||||
|
||||
/// What the ingest needs that the export does not carry.
|
||||
pub type Context = crate::gradescope::Context;
|
||||
@@ -120,11 +120,9 @@ pub fn normalize(s: &str) -> String {
|
||||
if c.is_alphanumeric() {
|
||||
out.push(c);
|
||||
last_space = false;
|
||||
} else if c.is_whitespace() || c == '-' || c == '_' {
|
||||
if !last_space {
|
||||
out.push(' ');
|
||||
last_space = true;
|
||||
}
|
||||
} else if (c.is_whitespace() || c == '-' || c == '_') && !last_space {
|
||||
out.push(' ');
|
||||
last_space = true;
|
||||
}
|
||||
// Everything else — punctuation, entity leftovers — is dropped.
|
||||
}
|
||||
@@ -579,10 +577,11 @@ mod tests {
|
||||
|
||||
// Two real students, two questions each. The preview row is discarded.
|
||||
assert_eq!(set.rows.len(), 4, "{:?}", set.warnings);
|
||||
assert!(set
|
||||
.rows
|
||||
.iter()
|
||||
.all(|r| r.name.as_deref() != Some("Test Student")));
|
||||
assert!(
|
||||
set.rows
|
||||
.iter()
|
||||
.all(|r| r.name.as_deref() != Some("Test Student"))
|
||||
);
|
||||
assert_eq!(set.scored_total("1234567"), 2.0);
|
||||
assert_eq!(set.scored_total("7654321"), 1.0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user