pub struct Model {
pub id: i64,
pub module_id: i64,
pub name: String,
pub description: Option<String>,
pub assignment_type: AssignmentType,
pub status: Status,
pub available_from: DateTime<Utc>,
pub due_date: DateTime<Utc>,
pub config: Option<JsonValue>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
Expand description
Assignment model representing the assignments
table in the database.
Fields§
§id: i64
§module_id: i64
§name: String
§description: Option<String>
§assignment_type: AssignmentType
§status: Status
§available_from: DateTime<Utc>
§due_date: DateTime<Utc>
§config: Option<JsonValue>
§created_at: DateTime<Utc>
§updated_at: DateTime<Utc>
Implementations§
Source§impl Model
impl Model
pub async fn create( db: &DatabaseConnection, module_id: i64, name: &str, description: Option<&str>, assignment_type: AssignmentType, available_from: DateTime<Utc>, due_date: DateTime<Utc>, ) -> Result<Self, DbErr>
pub async fn edit( db: &DatabaseConnection, id: i64, module_id: i64, name: &str, description: Option<&str>, assignment_type: AssignmentType, available_from: DateTime<Utc>, due_date: DateTime<Utc>, ) -> Result<Self, DbErr>
pub async fn delete( db: &DatabaseConnection, id: i32, module_id: i32, ) -> Result<(), DbErr>
pub async fn filter( db: &DatabaseConnection, page: u64, per_page: u64, sort_by: Option<String>, query: Option<String>, ) -> Result<Vec<Self>, DbErr>
Sourcepub async fn compute_readiness_report(
db: &DatabaseConnection,
module_id: i64,
assignment_id: i64,
) -> Result<ReadinessReport, DbErr>
pub async fn compute_readiness_report( db: &DatabaseConnection, module_id: i64, assignment_id: i64, ) -> Result<ReadinessReport, DbErr>
Computes a detailed readiness report for an assignment by checking if all required components are present.
This function verifies the presence of all expected resources for an assignment:
- At least one task is defined in the database.
- A configuration file exists.
- A main file exists.
- A memo file exists.
- A makefile exists.
- A memo output file exists.
- A JSON mark allocator file exists.
The returned ReadinessReport
(or [AssignmentReadiness
]) contains boolean flags for each component
and an is_ready
field indicating whether the assignment is fully ready
(i.e., suitable to transition from Setup
to Ready
state).
This function only checks readiness — it does not modify the assignment’s status in the database.
§Arguments
db
- A reference to the database connection.module_id
- The ID of the module to which the assignment belongs.assignment_id
- The ID of the assignment to check.
§Returns
Ok(ReadinessReport)
with per-component readiness details.Err(DbErr)
if a database error occurs while checking tasks.
§Notes
File presence is checked on the file system under the expected directories for each file type. Missing directories or I/O errors are treated as absence of the respective component.
Sourcepub async fn try_transition_to_ready(
db: &DatabaseConnection,
module_id: i64,
assignment_id: i64,
) -> Result<bool, DbErr>
pub async fn try_transition_to_ready( db: &DatabaseConnection, module_id: i64, assignment_id: i64, ) -> Result<bool, DbErr>
Attempts to transition an assignment to Ready
state if all readiness conditions are met.
This function:
- Computes a full readiness report for the assignment.
- If all components are present (
is_ready
== true), it checks the current status. - If the current status is
Setup
, it updates the status toReady
and updatesupdated_at
. - If already in
Ready
,Open
, etc., it does not change the status.
§Arguments
db
- A reference to the database connection.module_id
- The ID of the module to which the assignment belongs.assignment_id
- The ID of the assignment.
§Returns
Ok(true)
if the assignment is fully ready (regardless of whether the status was updated).Ok(false)
if the assignment is not ready.Err(DbErr)
if a database error occurs.
Trait Implementations§
Source§impl From<Model> for ActiveModel
impl From<Model> for ActiveModel
Source§impl FromQueryResult for Model
impl FromQueryResult for Model
Source§fn from_query_result(row: &QueryResult, pre: &str) -> Result<Self, DbErr>
fn from_query_result(row: &QueryResult, pre: &str) -> Result<Self, DbErr>
§fn from_query_result_optional(
res: &QueryResult,
pre: &str,
) -> Result<Option<Self>, DbErr>
fn from_query_result_optional( res: &QueryResult, pre: &str, ) -> Result<Option<Self>, DbErr>
§fn from_query_result_nullable(
res: &QueryResult,
pre: &str,
) -> Result<Self, TryGetError>
fn from_query_result_nullable( res: &QueryResult, pre: &str, ) -> Result<Self, TryGetError>
§fn find_by_statement(stmt: Statement) -> SelectorRaw<SelectModel<Self>>
fn find_by_statement(stmt: Statement) -> SelectorRaw<SelectModel<Self>>
Source§impl IntoActiveModel<ActiveModel> for Model
impl IntoActiveModel<ActiveModel> for Model
Source§fn into_active_model(self) -> ActiveModel
fn into_active_model(self) -> ActiveModel
Source§impl ModelTrait for Model
impl ModelTrait for Model
type Entity = Entity
Source§fn get(&self, c: <Self::Entity as EntityTrait>::Column) -> Value
fn get(&self, c: <Self::Entity as EntityTrait>::Column) -> Value
Source§fn set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value)
fn set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value)
§fn find_linked<L>(&self, l: L) -> Select<<L as Linked>::ToEntity>where
L: Linked<FromEntity = Self::Entity>,
fn find_linked<L>(&self, l: L) -> Select<<L as Linked>::ToEntity>where
L: Linked<FromEntity = Self::Entity>,
§fn delete<'a, 'async_trait, A, C>(
self,
db: &'a C,
) -> Pin<Box<dyn Future<Output = Result<DeleteResult, DbErr>> + Send + 'async_trait>>where
'a: 'async_trait,
Self: IntoActiveModel<A> + 'async_trait,
C: ConnectionTrait + 'async_trait,
A: ActiveModelTrait<Entity = Self::Entity> + ActiveModelBehavior + Send + 'a + 'async_trait,
fn delete<'a, 'async_trait, A, C>(
self,
db: &'a C,
) -> Pin<Box<dyn Future<Output = Result<DeleteResult, DbErr>> + Send + 'async_trait>>where
'a: 'async_trait,
Self: IntoActiveModel<A> + 'async_trait,
C: ConnectionTrait + 'async_trait,
A: ActiveModelTrait<Entity = Self::Entity> + ActiveModelBehavior + Send + 'a + 'async_trait,
Source§impl TryFrom<ActiveModel> for Model
impl TryFrom<ActiveModel> for Model
Source§impl TryIntoModel<Model> for ActiveModel
impl TryIntoModel<Model> for ActiveModel
Source§fn try_into_model(self) -> Result<Model, DbErr>
fn try_into_model(self) -> Result<Model, DbErr>
impl StructuralPartialEq for Model
Auto Trait Implementations§
impl Freeze for Model
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnwindSafe for Model
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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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