Struct trane::Trane

source ·
pub struct Trane { /* private fields */ }
Expand description

Trane is a library for the acquisition of highly hierarchical knowledge and skills based on the principles of mastery learning and spaced repetition. Given a list of courses, its lessons and corresponding exercises, Trane presents the student with a list of exercises based on the demonstrated mastery of previous exercises. It makes sure that new material and skills are not introduced until the prerequisite material and skills have been sufficiently mastered.

Implementations§

source§

impl Trane

source

pub fn new(working_dir: &Path, library_root: &Path) -> Result<Trane>

Creates a new instance of the library given the path to the root of a course library. The user data will be stored in a directory named .trane inside the library root directory. The working directory will be used to resolve relative paths.

source

pub fn library_root(&self) -> String

Returns the path to the root of the course library.

source

pub fn mantra_count(&self) -> usize

Returns the number of mantras that have been recited by the mantra miner.

Trait Implementations§

source§

impl Blacklist for Trane

source§

fn add_to_blacklist(&mut self, unit_id: &Ustr) -> Result<()>

Adds the given unit to the blacklist.
source§

fn remove_from_blacklist(&mut self, unit_id: &Ustr) -> Result<()>

Removes the given unit from the blacklist. Do nothing if the unit is not already in the list.
source§

fn remove_prefix_from_blacklist(&mut self, prefix: &str) -> Result<()>

Remvoves all the units that match the given prefix from the blacklist.
source§

fn blacklisted(&self, unit_id: &Ustr) -> Result<bool>

Returns whether the given unit is in the blacklist and should be skipped during scheduling.
source§

fn all_blacklist_entries(&self) -> Result<Vec<Ustr>>

Returns all the entries in the blacklist.
source§

impl CourseLibrary for Trane

source§

fn get_course_manifest(&self, course_id: &Ustr) -> Option<CourseManifest>

Returns the course manifest for the given course.
source§

fn get_lesson_manifest(&self, lesson_id: &Ustr) -> Option<LessonManifest>

Returns the lesson manifest for the given lesson.
source§

fn get_exercise_manifest(&self, exercise_id: &Ustr) -> Option<ExerciseManifest>

Returns the exercise manifest for the given exercise.
source§

fn get_course_ids(&self) -> Vec<Ustr>

Returns the IDs of all courses in the library sorted alphabetically.
source§

fn get_lesson_ids(&self, course_id: &Ustr) -> Result<Vec<Ustr>>

Returns the IDs of all lessons in the given course sorted alphabetically.
source§

fn get_exercise_ids(&self, lesson_id: &Ustr) -> Result<Vec<Ustr>>

Returns the IDs of all exercises in the given lesson sorted alphabetically.
source§

fn get_all_exercise_ids(&self) -> Result<Vec<Ustr>>

Returns the IDs of all exercises in the given course sorted alphabetically.
source§

fn search(&self, query: &str) -> Result<Vec<Ustr>>

Returns the IDs of all the units which match the given query.
source§

fn get_user_preferences(&self) -> UserPreferences

Returns the user preferences found in the library. The default preferences should be returned if the user preferences file is not found.
source§

impl ExerciseScheduler for Trane

source§

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

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<()>

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 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. Read more
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.
source§

impl FilterManager for Trane

source§

fn get_filter(&self, id: &str) -> Option<SavedFilter>

Gets the filter with the given ID.
source§

fn list_filters(&self) -> Vec<(String, String)>

Returns a list of filter IDs and descriptions.
source§

impl PracticeStats for Trane

source§

fn get_scores( &self, exercise_id: &Ustr, num_scores: usize ) -> Result<Vec<ExerciseTrial>>

Retrieves the last num_scores scores of a particular exercise. The scores are returned in descending order according to the timestamp.
source§

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

Records the score assigned to the exercise in a particular trial. Therefore, the score is a value of the MasteryScore enum instead of a float. Only units of type UnitType::Exercise should have scores recorded. However, the enforcement of this requirement is left to the caller.
source§

fn trim_scores(&mut self, num_scores: usize) -> Result<()>

Deletes all the exercise trials except for the last num_scores with the aim of keeping the storage size under check.
source§

impl RepositoryManager for Trane

source§

fn add_repo(&mut self, url: &str, repo_id: Option<String>) -> Result<()>

Downloads the courses from the given git repository into the given directory. The ID will also be used to identify the repository in the future and as the name of the directory. If omitted, the name of the repository will be used to generate an ID.
source§

fn remove_repo(&mut self, repo_id: &str) -> Result<()>

Removes the repository with the given ID.
source§

fn update_repo(&self, repo_id: &str) -> Result<()>

Attempts to pull the latest version of the given repository.
source§

fn update_all_repos(&self) -> Result<()>

Attempts to pull the latest version of all repositories.
source§

fn list_repos(&self) -> Result<Vec<RepositoryMetadata>>

Returns a list of all the repositories that are currently being managed.
source§

impl ReviewList for Trane

source§

fn add_to_review_list(&mut self, unit_id: &Ustr) -> Result<()>

Adds the given unit to the review list.
source§

fn remove_from_review_list(&mut self, unit_id: &Ustr) -> Result<()>

Removes the given unit from the review list. Do nothing if the unit is not already in the list.
source§

fn all_review_list_entries(&self) -> Result<Vec<Ustr>>

Returns all the entries in the review list.
source§

impl StudySessionManager for Trane

source§

fn get_study_session(&self, id: &str) -> Option<StudySession>

Gets the study session with the given ID.
source§

fn list_study_sessions(&self) -> Vec<(String, String)>

Returns a list of study session IDs and descriptions.
source§

impl UnitGraph for Trane

source§

fn add_course(&mut self, course_id: &Ustr) -> Result<()>

Adds a new course to the unit graph.
source§

fn add_lesson(&mut self, lesson_id: &Ustr, course_id: &Ustr) -> Result<()>

Adds a new lesson to the unit graph. It also takes the ID of the course to which this lesson belongs.
source§

fn add_exercise(&mut self, exercise_id: &Ustr, lesson_id: &Ustr) -> Result<()>

Adds a new exercise to the unit graph. It also takes the ID of the lesson to which this exercise belongs.
source§

fn add_dependencies( &mut self, unit_id: &Ustr, unit_type: UnitType, dependencies: &[Ustr] ) -> Result<()>

Takes a unit and its dependencies and updates the graph accordingly. Returns an error if unit_type is UnitType::Exercise as only courses and lessons are allowed to have dependencies. An error is also returned if the unit was not previously added by calling one of add_course or add_lesson.
source§

fn get_unit_type(&self, unit_id: &Ustr) -> Option<UnitType>

Returns the type of the given unit.
source§

fn get_course_lessons(&self, course_id: &Ustr) -> Option<UstrSet>

Returns the lessons belonging to the given course.
source§

fn get_starting_lessons(&self, course_id: &Ustr) -> Option<UstrSet>

Returns the starting lessons for the given course.
source§

fn update_starting_lessons(&mut self)

Updates the starting lessons for all courses. The starting lessons of the course are those of its lessons that should be practiced first when the course is introduced to the student. The scheduler uses them to traverse through the other lessons in the course in the correct order. This function should be called once after all the courses and lessons have been added to the graph.
source§

fn get_lesson_course(&self, lesson_id: &Ustr) -> Option<Ustr>

Returns the course to which the given lesson belongs.
source§

fn get_lesson_exercises(&self, lesson_id: &Ustr) -> Option<UstrSet>

Returns the exercises belonging to the given lesson.
source§

fn get_exercise_lesson(&self, exercise_id: &Ustr) -> Option<Ustr>

Returns the lesson to which the given exercise belongs.
source§

fn get_dependencies(&self, unit_id: &Ustr) -> Option<UstrSet>

Returns the dependencies of the given unit.
source§

fn get_dependents(&self, unit_id: &Ustr) -> Option<UstrSet>

Returns all the units which depend on the given unit.
source§

fn get_dependency_sinks(&self) -> UstrSet

Returns the dependency sinks of the graph. A dependency sink is a unit with no dependencies from which a walk of the entire unit graph needs to start. Because the lessons in a course implicitly depend on their course, properly initialized lessons do not belong to this set. Read more
source§

fn check_cycles(&self) -> Result<()>

Performs a cycle check on the graph, done currently when opening the Trane library to prevent any infinite traversal of the graph and immediately inform the user of the issue.
source§

fn generate_dot_graph(&self) -> String

Generates a DOT graph of the dependent graph. DOT files are used by Graphviz to visualize a graph, in this case the dependent graph. This operation was suggested in issue #13 in the trane-cli repo. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Trane

§

impl Send for Trane

§

impl !Sync for Trane

§

impl Unpin for Trane

§

impl !UnwindSafe for Trane

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> Fruit for Twhere T: Send + Downcast,