Struct umm::grade::QueryGrader

source ·
pub struct QueryGrader {
    req_name: String,
    out_of: f64,
    queries: Vec<Query>,
    project: Project,
    file: String,
    constraint: QueryConstraint,
    reason: String,
}
Expand description

A struct to represent a query grader.

Fields§

§req_name: String

The name of the requirement.

§out_of: f64

The grade for the requirement.

§queries: Vec<Query>

The queries to run.

§project: Project

The input to run the queries on.

§file: String

The file to run the query on.

§constraint: QueryConstraint

The constraint of the query.

§reason: String

The reason to share with the student.

Implementations§

source§

impl QueryGrader

source

pub fn new() -> Self

Creates a new query grader with default values.

source

pub fn req_name(&self) -> &str

Gets the name of the requirement.

source

pub fn set_req_name(self, req_name: String) -> Self

Sets the name of the requirement.

source

pub fn out_of(&self) -> f64

Gets the “out of” grade for the requirement.

source

pub fn set_out_of(self, out_of: f64) -> Self

Sets the “out of” grade for the requirement.

source

pub fn file(&self) -> &str

Gets the file to run the query on.

source

pub fn set_file(self, file: String) -> Self

Sets the file to run the query on.

source

pub fn project(&self) -> &Project

Gets the project to run the query on.

source

pub fn set_project(self, project: Project) -> Self

Sets the project to run the query on.

source

pub fn queries(&self) -> Vec<Query>

Gets the queries to run.

source

pub fn constraint(&self) -> QueryConstraint

Gets the constraint of the query.

source

pub fn must_match_at_least_once(self) -> Self

Sets the constraint of the query to “must match at least once”.

source

pub fn must_match_exactly_n_times(self, n: usize) -> Self

Sets the constraint of the query to “must match exactly n times”.

source

pub fn must_not_match(self) -> Self

Sets the constraint of the query to “must not match”.

source

pub fn reason(&self) -> &str

Gets the reason to share with the student.

source

pub fn set_reason(self, reason: String) -> Self

Sets the reason to share with the student.

source

pub fn query(self, q: String) -> Result<Self, QueryError>

Adds a query to run. If no file has been selected, this will throw an error.

source

pub fn query_script(self, q: String) -> Result<Self, Box<EvalAltResult>>

Macro generated variant of #fn_name that returns EvalAltResult. This allows the function to be used in scripts.

source

pub fn capture(self, c: String) -> Result<Self, QueryError>

Adds a capture to the last query. If no queries have been added, this will throw an error.

source

pub fn capture_script(self, c: String) -> Result<Self, Box<EvalAltResult>>

Macro generated variant of #fn_name that returns EvalAltResult. This allows the function to be used in scripts.

source

pub fn filter(self, f: FnPtr) -> Result<Self, QueryError>

Adds a capture to the last query. If no queries have been added, this will throw an error.

source

pub fn filter_script(self, f: FnPtr) -> Result<Self, Box<EvalAltResult>>

Macro generated variant of #fn_name that returns EvalAltResult. This allows the function to be used in scripts.

source

pub fn method_body_with_name(self, method_name: String) -> Self

Selects entire method body and returns

source

pub fn method_body_with_return_type(self, return_type: String) -> Self

Selects entire method body and returns

source

pub fn main_method(self) -> Self

Selects and returns the entire main method

source

pub fn class_body_with_name(self, class_name: String) -> Self

Selects entire class body with name

source

pub fn local_variables(self) -> Self

Selects local variable declaration statements

source

pub fn local_variables_with_name(self, name: String) -> Self

Selects local variable declaration statements with supplied name

source

pub fn local_variables_with_type(self, type_name: String) -> Self

Selects local variable declaration statements with supplied type

source

pub fn if_statements(self) -> Self

Selects if statements (entire, including else if and else)

source

pub fn for_loops(self) -> Self

Selects for loops

source

pub fn while_loops(self) -> Self

Selects while loops

source

pub fn method_invocations(self) -> Self

Selects method invocations

source

pub fn method_invocations_with_name(self, name: String) -> Self

Selects method invocations with supplied name

source

pub fn method_invocations_with_arguments(self, name: String) -> Self

Selects method invocations with supplied arguments

source

pub fn method_invocations_with_object(self, name: String) -> Self

Selects method invocations with supplied object

source

pub fn run_query(&self) -> Result<Dynamic, QueryError>

Runs the queries, and returns the result. TODO: Make it so that it doesn’t parse a new piece of code, just filters out the irrelevant line ranges. This performs better but more importantly is more accurate.

source

pub fn run_query_script(&self) -> Result<Dynamic, Box<EvalAltResult>>

Macro generated variant of #fn_name that returns EvalAltResult. This allows the function to be used in scripts.

source

pub fn grade_by_query(self) -> Result<GradeResult>

Grades the file according to the supplied queries, captures, and constraints.

source

pub fn grade_by_query_script(self) -> Result<GradeResult, Box<EvalAltResult>>

Macro generated variant of #fn_name that returns EvalAltResult. This allows the function to be used in scripts.

Trait Implementations§

source§

impl Clone for QueryGrader

source§

fn clone(&self) -> QueryGrader

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CustomType for QueryGrader

Allows registering custom types with Rhai.

source§

fn build(builder: TypeBuilder<'_, Self>)

Builds a custom type to be registered with Rhai.

source§

impl Default for QueryGrader

source§

fn default() -> QueryGrader

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into<'async_trait>( self ) -> Pin<Box<dyn Future<Output = Result<U, <U as TryFrom<T>>::Error>> + 'async_trait>>
where T: 'async_trait,

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more