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

pub struct Rubric {
    pub name: String,
    pub desc: Option<String>,
    pub criteria: Vec<Criterion>,
    pub total: isize,
    pub deadline: Option<DateTime<Local>>,
    pub final_deadline: Option<DateTime<Local>>,
    pub allow_late: bool,
    pub late_penalty: isize,
    pub daily_penalty: isize,
}

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

Example

use rubric::{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: isizedeadline: Option<DateTime<Local>>final_deadline: Option<DateTime<Local>>allow_late: boollate_penalty: isizedaily_penalty: isize

Implementations

impl Rubric[src]

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

Parses yaml data into a Rubric.

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

Example

use rubric::{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, func: &str) -> Option<&mut Criterion>[src]

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

// `rubric` contains a criterion with the func '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.

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 criterion's index.

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 past_due(&self) -> bool[src]

pub fn past_final_deadline(&self) -> bool[src]

Trait Implementations

impl Default for Rubric[src]

fn default() -> Rubric[src]

This is only used for testing and examples. You shouldn't use this to create a new Rubric, instead use from_yaml().

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