Skip to main content

CourseState

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

Source

pub fn publish_blockers(&self) -> Vec<PublishBlocker>

What publishing this state would break, in a fixed order; empty if nothing.

Source

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

Source

pub fn course_id(&self) -> Uuid

The course the state belongs to.

Source

pub fn page(&self, page_id: Uuid) -> Option<&PageRecord>

The page page_id.

Source

pub fn page_mut(&mut self, page_id: Uuid) -> Option<&mut PageRecord>

Self::page for editing.

Source

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.

Source

pub fn chapters_in_order(&self, module_id: Uuid) -> Vec<&ChapterSnapshot>

The chapters of a module in the order the course structure shows them.

Source

pub fn modules_in_order(&self) -> Vec<&ModuleSnapshot>

The modules in the order the course structure shows them: the default module first.

Source

pub fn has_entity(&self, _: EntityKey) -> bool

Whether the state has the entity.

Source

pub fn entity_snapshot(&self, _: EntityKey) -> Option<EntitySnapshot>

The full snapshot of an entity, which a state holds of every entity type but pages.

Source

pub fn entity_label(&self, key: EntityKey) -> Option<String>

What people call the entity; see entity_snapshots::EntityRef::label.

Source

pub fn set_entity(&mut self, _: EntityKey, snapshot: Option<&EntitySnapshot>)

Replaces, adds or (with None) removes one entity. Course settings can’t be removed.

Source

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.

Source

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.

Source

pub fn set_page_exercise_deadlines(&mut self, page: &PageSnapshot)

Sets the deadlines of the page’s exercises from its snapshot.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn exercise(&self, exercise_id: Uuid) -> Option<&ExerciseRecord>

The exercise’s record; None also when the state has no exercise records.

Source

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.

Source

pub fn exercise_page_ids(&self) -> HashMap<Uuid, Uuid>

The page whose blocks hold each exercise, by exercise id.

Source

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.

Source

pub fn changes_since(&self, before: &CourseState) -> StateChanges

The entities that differ between before and this state; the inverse of CourseState::overlay.

Source

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.

Source

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.

Source

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.

Source

pub fn is_chapter_front_page(&self, page_id: Uuid) -> bool

Whether the page is its chapter’s front page in this state.

Source

pub fn is_live(&self) -> bool

Students see this course: it is neither a draft nor in test mode.

Source§

impl CourseState

Source

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

Source§

fn clone(&self) -> CourseState

Returns a duplicate 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 Debug for CourseState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for CourseState

Source§

fn eq(&self, other: &CourseState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CourseState

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn decompression(self) -> Decompression<Self>
where Self: Sized,

Decompress response bodies. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

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

Source§

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>,

Source§

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>,

Source§

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 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,