[−][src]Struct lab_grader::rubric::Rubric
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: String
desc: 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
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,