Skip to main content

ExerciseScheduler

Trait ExerciseScheduler 

Source
pub trait ExerciseScheduler {
    // Required methods
    fn get_exercise_batch(
        &self,
        filter: Option<ExerciseFilter>,
    ) -> Result<Vec<ExerciseManifest>, ExerciseSchedulerError>;
    fn score_exercise(
        &self,
        exercise_id: Ustr,
        score: MasteryScore,
        timestamp: i64,
    ) -> Result<(), ExerciseSchedulerError>;
    fn get_unit_score(
        &self,
        unit_id: Ustr,
    ) -> Result<Option<f32>, ExerciseSchedulerError>;
    fn invalidate_cached_score(&self, unit_id: Ustr);
    fn invalidate_cached_scores_with_prefix(&self, prefix: &str);
    fn get_scheduler_options(&self) -> SchedulerOptions;
    fn set_scheduler_options(&mut self, options: SchedulerOptions);
    fn reset_scheduler_options(&mut self);
}
Expand description

The trait that defines the interface for the scheduler. Contains functions to request a new batch of exercises and to provide Trane the self-reported scores for said exercises.

Required Methods§

Source

fn get_exercise_batch( &self, filter: Option<ExerciseFilter>, ) -> Result<Vec<ExerciseManifest>, ExerciseSchedulerError>

Gets a new batch of exercises scheduled for a new trial. Contains an optimal filter to restrict the units visited during the search with the purpose of allowing students to choose which material to practice. If the filter is not provided, the scheduler will search the entire graph.

Source

fn score_exercise( &self, exercise_id: Ustr, score: MasteryScore, timestamp: i64, ) -> Result<(), ExerciseSchedulerError>

Records the score of the given exercise’s trial. The scores are used by the scheduler to decide when to stop traversing a path and how to sort and filter all the found candidates into a final batch.

Source

fn get_unit_score( &self, unit_id: Ustr, ) -> Result<Option<f32>, ExerciseSchedulerError>

Gets the score for the given unit. The unit can be a course, lesson, or exercise.

Source

fn invalidate_cached_score(&self, unit_id: Ustr)

Removes any cached scores for the given unit. The score will be recomputed the next time the score is needed.

The scores for lessons and exercises are cached to save a large amount of unnecessary computation. Without the caller manually invalidating the cache using this call, it is not possible to know when the cached value becomes outdated with the current interface. The reason is that the calls to modify the blacklist are not known by the scheduler.

However, the final users of Trane do not need to call this function because the Trane object in lib.rs takes care of clearing the cache when exposing the interface that modifies the blacklist.

Source

fn invalidate_cached_scores_with_prefix(&self, prefix: &str)

Removes any cached scores from units with the given prefix. The same considerations as invalidate_cached_score apply.

Source

fn get_scheduler_options(&self) -> SchedulerOptions

Returns the options used to control the behavior of the scheduler.

Source

fn set_scheduler_options(&mut self, options: SchedulerOptions)

Sets the options used to control the behavior of the scheduler.

Source

fn reset_scheduler_options(&mut self)

Resets the options used to control the behavior of the scheduler to their default values.

Implementors§