[][src]Struct lab_grader::submission::Submission

pub struct Submission {
    pub time: DateTime<Local>,
    pub grade: i16,
    pub data: TestData,
    pub passed: Vec<String>,
    pub failed: Vec<String>,
}

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. Submissions 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, rubric: &mut Rubric)[src]

Tests a submission against a list of criterion

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]

impl PartialEq<Submission> for Submission[src]

impl Serialize for Submission[src]

impl StructuralPartialEq for Submission[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoCollection<T> for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,