From d81975e78cd3060dbf6b53a0cf596595410690f5 Mon Sep 17 00:00:00 2001 From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de> Date: Fri, 29 Mar 2019 18:15:19 +0100 Subject: [PATCH] Changes field 'submission_type' of submissions to 'type' --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/parser/xls_parser.rs | 2 +- src/parser/xml_parser.rs | 2 +- src/submission.rs | 8 ++++---- tests/test_xls_parser.rs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6dc2cd6..ba4ef72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1033,7 +1033,7 @@ dependencies = [ [[package]] name = "rusty-hektor" -version = "0.3.0" +version = "1.0.0" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "calamine 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index e70bb1c..6506ae9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rusty-hektor" -version = "0.3.0" +version = "1.0.0" authors = ["robinwilliam.hundt <robinwilliam.hundt@stud.uni-goettingen.de>"] license = "MIT OR Apache-2.0" description = "A tool to convert ILIAS exam output" diff --git a/src/parser/xls_parser.rs b/src/parser/xls_parser.rs index 8d4e289..d5ab17b 100644 --- a/src/parser/xls_parser.rs +++ b/src/parser/xls_parser.rs @@ -82,7 +82,7 @@ fn extract_submission_types(students: Vec<&Student>) -> parser::Result<BTreeSet< .as_ref() .expect(&format!("{:?} seems to have no submissions", stud)) .iter() - .map(|sub| sub.submission_type.clone()) + .map(|sub| sub.r#type.clone()) .collect(); if !submission_types.is_empty() && submission_types != sub_types_for_stud { return Err(ParserError::new(format!( diff --git a/src/parser/xml_parser.rs b/src/parser/xml_parser.rs index 7c686b7..5c8d250 100644 --- a/src/parser/xml_parser.rs +++ b/src/parser/xml_parser.rs @@ -311,7 +311,7 @@ fn extract_submission_for_student( Ok(Submission { code, - submission_type, + r#type: submission_type, ..Submission::default() }) } diff --git a/src/submission.rs b/src/submission.rs index a68bdc2..a6d0c32 100644 --- a/src/submission.rs +++ b/src/submission.rs @@ -4,15 +4,15 @@ use std::hash::{Hash, Hasher}; #[derive(Debug, Eq, PartialEq, Serialize, Default, Clone, PartialOrd, Ord)] pub struct Submission { pub code: String, - pub submission_type: String, + pub r#type: String, pub tests: BTreeMap<(), ()>, } impl Submission { - pub fn new(code: String, submission_type: String) -> Self { + pub fn new(code: String, r#type: String) -> Self { Submission { code, - submission_type, + r#type, tests: BTreeMap::new(), } } @@ -21,6 +21,6 @@ impl Submission { impl Hash for Submission { fn hash<H: Hasher>(&self, state: &mut H) { self.code.hash(state); - self.submission_type.hash(state); + self.r#type.hash(state); } } diff --git a/tests/test_xls_parser.rs b/tests/test_xls_parser.rs index f7321fd..9d73755 100644 --- a/tests/test_xls_parser.rs +++ b/tests/test_xls_parser.rs @@ -152,7 +152,7 @@ fn correct_mapping_is_generated() -> Result<(), Box<dyn Error>> { &find_student_by_key_in_serializable(stud_key) .submissions .iter() - .find(|sub| sub.submission_type == sub_type_name) + .find(|sub| sub.r#type == sub_type_name) .expect( format!( "Unable to find Submission {} for {}", -- GitLab