[][src]Struct lab_grader::rubric::Rubric

pub struct Rubric {
    pub name: String,
    pub desc: Option<String>,
    pub criteria: Vec<Criterion>,
    pub total: isize,
}

A collection of criteria, meant to be serialized from yaml.

Example

use lab_grader::{Rubric, yaml};

// Relative path to the yaml file
let yaml = yaml!("../test_data/test_rubric.yml").expect("Couldn't load yaml");
let mut rubric = Rubric::from_yaml(yaml).expect("Bad yaml!");

assert_eq!(rubric.name, "Test Rubric");
assert_eq!(rubric.len(), 2);

Fields

name: Stringdesc: Option<String>criteria: Vec<Criterion>total: isize

Implementations

impl Rubric[src]

pub fn from_yaml(yaml: &str) -> Result<Self, Error>[src]

Parses yaml data into a Rubric.

This is equivilent to calling parse() on a string, except this will return a lab_grader::Error error instead of a serde_yaml::Error.

Example

use lab_grader::{Rubric, yaml};
let yaml = yaml!("../test_data/test_rubric.yml").expect("Couldn't load yaml");
// If this is an Err, it will panic with the line/col of the yaml err
let mut rubric = Rubric::from_yaml(yaml).expect("Bad yaml!");

assert_eq!(rubric.name, "Test Rubric");
assert_eq!(rubric.criteria().len(), 2);

pub fn get(&mut self, stub: &str) -> Option<&mut Criterion>[src]

Searches for a criterion with the given stub, returning None if it couldn't be found

// `rubric` contains a criterion with the stub 'first-crit`
let criterion = rubric.get("first-crit");
assert!(criterion.is_some());
let not_criterion = rubric.get("doesnt-exist");
assert!(not_criterion.is_none());

pub fn add(&mut self, criterion: Criterion)[src]

Adds a criterion to the rubric's collection.

You probably shouldn't use this, instead define all your criteria in yaml.

pub fn sorted(&mut self) -> &mut Vec<Criterion>[src]

Returns the criteria as a &mut Vec<Criterion>, sorted by the index provided.

Criteria with the same index/no index will not have guaranteed order.

pub fn points(&self) -> usize[src]

The total points earned after grading.

Each criterion stores a flag that determines if it passed or failed. This will give the total worth of all criteria that passed.

If you run this before grading, it should return 0. If it doesn't, call me lmao.

pub fn total_points(&self) -> isize[src]

Returns the total worth of all criteria, ie. the maximum number of points possible.

pub fn criteria(&self) -> &Vec<Criterion>[src]

Returns a reference to a Vec of the criteria. This is like sorted, but they aren't sorted.

pub fn len(&self) -> usize[src]

Returns the amount of criteria in the rubric

pub fn print_short(&self)[src]

Prints the rubric name, then each criteria, only taking one line each. It's a shortened version of println!("{}", rubric).

pub fn print_table(&mut self)[src]

Prints a table with the rubric info and all the criteria to stdout

Trait Implementations

impl Display for Rubric[src]

impl FromStr for Rubric[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

impl !RefUnwindSafe for Rubric

impl !Send for Rubric

impl !Sync for Rubric

impl Unpin for Rubric

impl !UnwindSafe for Rubric

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> 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> ToString for T where
    T: Display + ?Sized
[src]

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>,