pub struct CourseState {
pub settings: CourseSettingsSnapshot,
pub modules: Vec<ModuleSnapshot>,
pub chapters: Vec<ChapterSnapshot>,
pub pages: Vec<PageRecord>,
pub glossary: Vec<GlossaryTermSnapshot>,
pub references: Vec<ReferenceSnapshot>,
pub course_default_review_config: Option<CourseDefaultReviewConfigSnapshot>,
pub exercises: Option<BTreeMap<Uuid, ExerciseRecord>>,
pub exercise_deadlines: BTreeMap<Uuid, ExerciseDeadline>,
}Expand description
Every editable entity of one course.
Fields§
§settings: CourseSettingsSnapshot§modules: Vec<ModuleSnapshot>§chapters: Vec<ChapterSnapshot>§pages: Vec<PageRecord>§glossary: Vec<GlossaryTermSnapshot>§references: Vec<ReferenceSnapshot>§course_default_review_config: Option<CourseDefaultReviewConfigSnapshot>None when the course has none, or when the state was loaded without it.
exercises: Option<BTreeMap<Uuid, ExerciseRecord>>By exercise id; None until CourseView::load_exercises
or CourseView::load_exercises_on_pages
(only those pages’) loads them.
exercise_deadlines: BTreeMap<Uuid, ExerciseDeadline>By exercise id; loaded with the pages. Entries of exercises no page holds any more stay.
Implementations§
Source§impl CourseState
impl CourseState
Sourcepub fn publish_blockers(&self) -> Vec<PublishBlocker>
pub fn publish_blockers(&self) -> Vec<PublishBlocker>
What publishing this state would break, in a fixed order; empty if nothing.
Sourcepub fn blockers_added_since(&self, before: &CourseState) -> Vec<PublishBlocker>
pub fn blockers_added_since(&self, before: &CourseState) -> Vec<PublishBlocker>
The publish blockers of this state that before doesn’t have. The entities’ labels don’t
count, so a blocker that only renames them isn’t new.
Source§impl CourseState
impl CourseState
Sourcepub fn page(&self, page_id: Uuid) -> Option<&PageRecord>
pub fn page(&self, page_id: Uuid) -> Option<&PageRecord>
The page page_id.
Sourcepub fn page_mut(&mut self, page_id: Uuid) -> Option<&mut PageRecord>
pub fn page_mut(&mut self, page_id: Uuid) -> Option<&mut PageRecord>
Self::page for editing.
Sourcepub fn pages_in_order(&self, chapter_id: Option<Uuid>) -> Vec<&PageRecord>
pub fn pages_in_order(&self, chapter_id: Option<Uuid>) -> Vec<&PageRecord>
The pages of a chapter, or the top-level pages with None, in the order the course
structure shows them: the chapter’s front page (the course front page /) first, then by
order number and path.
Sourcepub fn chapters_in_order(&self, module_id: Uuid) -> Vec<&ChapterSnapshot>
pub fn chapters_in_order(&self, module_id: Uuid) -> Vec<&ChapterSnapshot>
The chapters of a module in the order the course structure shows them.
Sourcepub fn modules_in_order(&self) -> Vec<&ModuleSnapshot>
pub fn modules_in_order(&self) -> Vec<&ModuleSnapshot>
The modules in the order the course structure shows them: the default module first.
Sourcepub fn has_entity(&self, _: EntityKey) -> bool
pub fn has_entity(&self, _: EntityKey) -> bool
Whether the state has the entity.
Sourcepub fn entity_snapshot(&self, _: EntityKey) -> Option<EntitySnapshot>
pub fn entity_snapshot(&self, _: EntityKey) -> Option<EntitySnapshot>
The full snapshot of an entity, which a state holds of every entity type but pages.
Sourcepub fn entity_label(&self, key: EntityKey) -> Option<String>
pub fn entity_label(&self, key: EntityKey) -> Option<String>
What people call the entity; see entity_snapshots::EntityRef::label.
Sourcepub fn set_entity(&mut self, _: EntityKey, snapshot: Option<&EntitySnapshot>)
pub fn set_entity(&mut self, _: EntityKey, snapshot: Option<&EntitySnapshot>)
Replaces, adds or (with None) removes one entity. Course settings can’t be removed.
Sourcepub fn copy_entity_from(&mut self, source: &CourseState, key: EntityKey)
pub fn copy_entity_from(&mut self, source: &CourseState, key: EntityKey)
Sets one entity to its state in source, removing it if source doesn’t have it.
Sourcepub fn set_page_exercises(&mut self, page_id: Uuid, page: Option<&PageSnapshot>)
pub fn set_page_exercises(&mut self, page_id: Uuid, page: Option<&PageSnapshot>)
Replaces the exercise records made from the page’s snapshot with those of page, or
removes them with None. Does nothing to a state without exercise records.
Sourcepub fn set_page_exercise_deadlines(&mut self, page: &PageSnapshot)
pub fn set_page_exercise_deadlines(&mut self, page: &PageSnapshot)
Sets the deadlines of the page’s exercises from its snapshot.
Sourcepub fn set_exercise_deadline(
&mut self,
exercise_id: Uuid,
deadline: Option<DateTime<Utc>>,
)
pub fn set_exercise_deadline( &mut self, exercise_id: Uuid, deadline: Option<DateTime<Utc>>, )
Sets the exercise’s own deadline in its record, if loaded, and in its deadline entry.
Sourcepub fn fork_review_config(&mut self, exercise_id: Uuid, config_id: Uuid)
pub fn fork_review_config(&mut self, exercise_id: Uuid, config_id: Uuid)
Gives the exercise its own review config config_id, starting from a copy of the course
default’s review instructions. No-op when the exercise’s record isn’t loaded.
Sourcepub fn use_course_default_review_config(&mut self, exercise_id: Uuid)
pub fn use_course_default_review_config(&mut self, exercise_id: Uuid)
Switches the exercise to the course default review config, dropping its own. No-op when the exercise’s record isn’t loaded.
Sourcepub fn exercise_mut(&mut self, exercise_id: Uuid) -> Option<&mut ExerciseRecord>
pub fn exercise_mut(&mut self, exercise_id: Uuid) -> Option<&mut ExerciseRecord>
The exercise’s record, to change; None also when the state has no exercise records.
Sourcepub fn effective_exercise_deadline(
&self,
exercise_id: Uuid,
) -> Option<DateTime<Utc>>
pub fn effective_exercise_deadline( &self, exercise_id: Uuid, ) -> Option<DateTime<Utc>>
The deadline that applies to the exercise: its own, else its chapter’s. None also when
the state doesn’t know the exercise.
Sourcepub fn exercise(&self, exercise_id: Uuid) -> Option<&ExerciseRecord>
pub fn exercise(&self, exercise_id: Uuid) -> Option<&ExerciseRecord>
The exercise’s record; None also when the state has no exercise records.
Sourcepub fn exercise_page_id(&self, exercise_id: Uuid) -> Option<Uuid>
pub fn exercise_page_id(&self, exercise_id: Uuid) -> Option<Uuid>
The page holding the exercise: the one whose blocks hold it, else the one its record was made from.
Sourcepub fn exercise_page_ids(&self) -> HashMap<Uuid, Uuid>
pub fn exercise_page_ids(&self) -> HashMap<Uuid, Uuid>
The page whose blocks hold each exercise, by exercise id.
Sourcepub fn overlay<'a>(
&self,
rows: impl IntoIterator<Item = &'a AgentChangesetEntity>,
parts: CourseParts,
) -> CourseState
pub fn overlay<'a>( &self, rows: impl IntoIterator<Item = &'a AgentChangesetEntity>, parts: CourseParts, ) -> CourseState
The state with the staged entities of a changeset laid over it. Rows of entity types left
out of parts are skipped.
Sourcepub fn changes_since(&self, before: &CourseState) -> StateChanges
pub fn changes_since(&self, before: &CourseState) -> StateChanges
The entities that differ between before and this state; the inverse of
CourseState::overlay.
Sourcepub fn exercises_changed_since(&self, before: &CourseState) -> Vec<Uuid>
pub fn exercises_changed_since(&self, before: &CourseState) -> Vec<Uuid>
The exercises whose records differ from those of before, when both have records.
Exercises only one of the states has are left out: their pages’ blocks differ.
Sourcepub fn pages_changed_since<'a>(
&'a self,
before: &CourseState,
) -> impl Iterator<Item = &'a PageRecord>
pub fn pages_changed_since<'a>( &'a self, before: &CourseState, ) -> impl Iterator<Item = &'a PageRecord>
The pages of this state that differ from their state in before, new pages included.
Sourcepub fn entity_ref(&self, key: EntityKey) -> EntityRef
pub fn entity_ref(&self, key: EntityKey) -> EntityRef
The entity, labelled as this state has it; with an empty label if the state lacks it.
Sourcepub fn is_chapter_front_page(&self, page_id: Uuid) -> bool
pub fn is_chapter_front_page(&self, page_id: Uuid) -> bool
Whether the page is its chapter’s front page in this state.
Source§impl CourseState
impl CourseState
Sourcepub fn field_changes_since(
&self,
before: &CourseState,
key: EntityKey,
) -> Vec<FieldChange>
pub fn field_changes_since( &self, before: &CourseState, key: EntityKey, ) -> Vec<FieldChange>
What this state changes of one entity of before, field by field, with references
labelled as this state calls them, or before does.
Trait Implementations§
Source§impl Clone for CourseState
impl Clone for CourseState
Source§fn clone(&self) -> CourseState
fn clone(&self) -> CourseState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CourseState
impl Debug for CourseState
Source§impl PartialEq for CourseState
impl PartialEq for CourseState
impl StructuralPartialEq for CourseState
Auto Trait Implementations§
impl Freeze for CourseState
impl RefUnwindSafe for CourseState
impl Send for CourseState
impl Sync for CourseState
impl Unpin for CourseState
impl UnsafeUnpin for CourseState
impl UnwindSafe for CourseState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].