[−][src]Struct lab_grader::submission::Submission
A submission is a bundle of data that represents one student's submission. They will do some sort of work for a lab, then run a rust script that builds some criteria, runs those criteria with some data from the student, and submits a Submission to a central webserver where the instructor can collect the graded submissions.
Fields
time: DateTime<Local>
A local timestamp when the submission was created
grade: i16
Numerical grade for the submission. Each criterion will add to this grade if it passes.
data: TestData
Extra data attached to the submission. Leave it empty if you don't need it
passed: Vec<String>
The criteria (name) that this submission passed
failed: Vec<String>
The citeria (name) that this submission failed
Implementations
impl Submission
[src]
pub fn new() -> Submission
[src]
Creates a new submission.
Example
use lab_grader::Submission; // You probably want it to be mutable so // you can attach data and change the grade let mut sub = Submission::new(); assert_eq!(sub.grade, 0); assert_eq!(sub.data.len(), 0);
pub fn use_data(&mut self, data: TestData)
[src]
Attaches data to a submission
The data must be a TestData
.
You may want to use the data!
macro to make it
easier to establish your data.
You may be interested in Submission::from_data
.
Example
let data = data! { "key" => "value", "key2" => "value2" }; let mut sub = Submission::new(); sub.use_data(data); assert_eq!(sub.data["key"], "value"); assert_eq!(sub.data["key2"], "value2");
pub fn from_data(data: TestData) -> Self
[src]
Creates a new submission and attaches data to it in one step
Example
let sub = Submission::from_data(data! { "name" => "luke i guess", "id" => "1234" }); assert_eq!(sub.data["id"], "1234");
pub fn pass<C: AsRef<str>>(&mut self, criterion: C)
[src]
Marks a criterion as passed. Provide the name of the criterion.
This struct does not include an actual Criterion
struct in it's passed
and failed
fields, because it's impossible to
serialize a Criterion
. Submission
s must be serializable. Instead, only the
name and message of the criterion are stored on the submission
Example
let mut sub = Submission::new(); sub.pass("Some criterion name"); assert!(sub.passed.contains(&"Some criterion name".to_string()));
pub fn fail<C: AsRef<str>>(&mut self, criterion: C)
[src]
Same as pass
, but adds to the failed
vector
pub fn grade_against(&mut self, criteria: &mut Criteria)
[src]
Tests a submission against a list of criterion
The submission's grade will change for every passed criterion,
and every criterion will add it's name and message to the submissions
passed
or failed
vectors.
Example
let mut sub = Submission::from_data(data! { "key" => "value" }); // Just one criterion here to save space let mut crits = Criteria::from(vec![ Criterion::new("Test Criterion", 10, ("passed", "failed"), Box::new( |data: &TestData| -> bool { data["key"] == "value" } )) ]); sub.grade_against(&mut crits); assert_eq!(sub.grade, 10); assert_eq!(sub.passed.len(), 1); assert_eq!(sub.failed.len(), 0);
pub fn server(port: u16)
[src]
Spins up a webserver to accept submission.
Accepted submissions will be written to a ResultsFile
.
The web server will run on the provided port.
The results file will be placed in the directory you execute the code in,
and be called submissions.csv
.
The best way to submit a submission to the server that this function starts is
to call post_json
from the web helpers module and
pass it the url that this server is accessible on, and a submission. It will convert
it to json for you.
Support for custom results file locations is coming...
use lab_grader::Submission; Submission::server(8080);
Trait Implementations
impl AsCsv for Submission
[src]
fn as_csv(&self) -> String
[src]
Returns the submission's values in csv format. The TestData
atttached will be
sorted alphabetically by key.
fn filename(&self) -> String
[src]
Returns the filename to use when writing submissions to disk
fn header(&self) -> String
[src]
Returns a header of all the fields, matching the data in as_csv
impl Debug for Submission
[src]
impl<'de> Deserialize<'de> for Submission
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl PartialEq<Submission> for Submission
[src]
fn eq(&self, other: &Submission) -> bool
[src]
fn ne(&self, other: &Submission) -> bool
[src]
impl Serialize for Submission
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Submission
[src]
Auto Trait Implementations
impl RefUnwindSafe for Submission
impl Send for Submission
impl Sync for Submission
impl Unpin for Submission
impl UnwindSafe for Submission
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,