[−][src]Struct rubric::rubric::Rubric
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: String
desc: Option<String>
criteria: Vec<Criterion>
total: isize
deadline: Option<DateTime<Local>>
final_deadline: Option<DateTime<Local>>
allow_late: bool
late_penalty: isize
daily_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]
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]
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> 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> Same<T> for T
type Output = T
Should always be Self
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,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,