Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3681d0b
initial commit for validation feature
BoySanic May 15, 2025
8f47411
Mild refactor of validate_submit
BoySanic May 23, 2025
1c5f22e
Fix bug in validate_fetch since we're not using a vec of project_ids …
BoySanic May 23, 2025
8944ccf
fixup! Fix bug in validate_fetch since we're not using a vec of proje…
BoySanic May 23, 2025
f900b30
Implement dutchen's refactor suggestions
BoySanic May 24, 2025
5eb9901
Big refactor to final design as discussed in VC in June
BoySanic Aug 5, 2025
ba72e02
Rebased for sqlx stuff, fixed comments on route
BoySanic Aug 5, 2025
241fd66
Minor fix for cargo fmt
BoySanic Aug 5, 2025
27a22e5
Add ability for validator to report errors
BoySanic Aug 5, 2025
c9c7332
Refactored a hashmap away since we never used it
BoySanic Aug 5, 2025
43234d1
Add use of group_assignment_id in result, create method to validate a…
BoySanic Aug 5, 2025
abeaa2c
Mark invalid, don't error
BoySanic Aug 5, 2025
b2b3ea5
Refactoring again, still in progress
BoySanic Aug 6, 2025
29a7026
More refactoring
BoySanic Aug 23, 2025
22dafe9
clippy and sqlx prepare
BoySanic Aug 23, 2025
58e42b2
Re-add TraceLayer thing
BoySanic Aug 23, 2025
6f7db7e
Cargo clippy and sqlx prepare
BoySanic Aug 23, 2025
c686f8d
Cargo fmt
BoySanic Aug 23, 2025
093abd9
sqlx prepare
BoySanic Aug 23, 2025
5173c89
finally some progress
BoySanic Dec 1, 2025
bda4d53
formatting/clippy
BoySanic Dec 1, 2025
41cd060
Implement fix
BoySanic Dec 1, 2025
d027e01
Some fixes
BoySanic Dec 1, 2025
d073a92
Rename state transition error, other fixes
BoySanic Dec 1, 2025
f7662c8
Change sql query
BoySanic Dec 1, 2025
a56e47d
Fix sql stuff
BoySanic Dec 1, 2025
3a70ceb
Fix format
BoySanic Dec 1, 2025
fde2af7
Refactor
DutChen18 Dec 3, 2025
646948f
Add search parameters
DutChen18 Dec 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ pub mod infallible;
pub mod not_found;
pub mod register_error;
pub mod submit_result_error;
pub mod validate_fetch_error;
pub mod validate_submit_error;

pub use fetch_tasks_error::FetchTasksError;
pub use infallible::Infallible;
pub use not_found::NotFound;
pub use register_error::RegisterError;
pub use submit_result_error::SubmitResultError;
pub use validate_fetch_error::ValidateFetchError;
pub use validate_submit_error::ValidateSubmitError;
8 changes: 8 additions & 0 deletions common/src/errors/validate_fetch_error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use serde::{Deserialize, Serialize};
use thiserror::Error;

#[derive(Clone, Hash, Debug, Serialize, Deserialize, Error)]
pub enum ValidateFetchError {
#[error("invalid project")]
InvalidProject,
}
16 changes: 16 additions & 0 deletions common/src/errors/validate_submit_error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use serde::{Deserialize, Serialize};
use thiserror::Error;

#[derive(Clone, Hash, Debug, Serialize, Deserialize, Error)]
pub enum ValidateSubmitError {
#[error("invalid result")]
InvalidResult,
#[error("expected results for exactly one task")]
InvalidTaskCount,
#[error("the group id of all results in a group must be the first submitted result")]
InconsistentGroup,
#[error("forbidden state transition")]
ForbiddenStateTransition,
#[error("missing some results for this task")]
MissingResults,
}
16 changes: 15 additions & 1 deletion common/src/records/result.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

use crate::types::Id;
use crate::types::{Id, ResultState};

use super::Assignment;

Expand All @@ -13,17 +13,31 @@ pub struct Result {
pub stdout: String,
pub stderr: String,
pub exit_code: Option<i32>,
pub group_result_id: Option<Id<Result>>,
pub state: ResultState,
}

#[non_exhaustive]
#[derive(Clone, Hash, Debug, Default, Serialize, Deserialize)]
pub struct ResultFilter {
pub assignment_id: Option<Id<Assignment>>,
pub group_result_id: Option<Id<Result>>,
pub state: Option<ResultState>,
}

impl ResultFilter {
pub fn assignment_id(mut self, assignment_id: Id<Assignment>) -> Self {
self.assignment_id = Some(assignment_id);
self
}

pub fn group_result_id(mut self, group_result_id: Id<Result>) -> Self {
self.group_result_id = Some(group_result_id);
self
}

pub fn state(mut self, state: ResultState) -> Self {
self.state = Some(state);
self
}
}
10 changes: 9 additions & 1 deletion common/src/records/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};

use crate::types::{Id, Interval};

use super::{Project, User};
use super::{Project, Result, User};

#[derive(Clone, Hash, Debug, Serialize, Deserialize)]
pub struct Task {
Expand All @@ -14,17 +14,25 @@ pub struct Task {
pub stdin: String,
pub assignments_needed: i32,
pub assignment_user_ids: Vec<Id<User>>,
pub canonical_result_id: Option<Id<Result>>,
pub quorum: i32,
}

#[non_exhaustive]
#[derive(Clone, Hash, Debug, Default, Serialize, Deserialize)]
pub struct TaskFilter {
pub project_id: Option<Id<Project>>,
pub canonical_result_id: Option<Id<Result>>,
}

impl TaskFilter {
pub fn project_id(mut self, project_id: Id<Project>) -> Self {
self.project_id = Some(project_id);
self
}

pub fn canonical_result_id(mut self, canonical_result_id: Id<Result>) -> Self {
self.canonical_result_id = Some(canonical_result_id);
self
}
}
2 changes: 2 additions & 0 deletions common/src/requests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pub mod fetch_tasks_request;
pub mod register_request;
pub mod submit_result_request;
pub mod validate_submit_request;

pub use fetch_tasks_request::FetchTasksRequest;
pub use register_request::RegisterRequest;
pub use submit_result_request::SubmitResultRequest;
pub use validate_submit_request::ValidateSubmitRequest;
11 changes: 11 additions & 0 deletions common/src/requests/validate_submit_request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use std::collections::HashMap;

use serde::{Deserialize, Serialize};

use crate::{records::Result, types::Id};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ValidateSubmitRequest {
// Map from result id to group id. None means error.
pub results: HashMap<Id<Result>, Option<Id<Result>>>,
}
3 changes: 0 additions & 3 deletions common/src/types/assignment_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ pub enum AssignmentState {
Canceled,
Expired,
Submitted,
Valid,
Invalid,
Inconclusive,
}
2 changes: 2 additions & 0 deletions common/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pub mod assignment_state;
pub mod id;
pub mod interval;
pub mod result_state;

pub use assignment_state::AssignmentState;
pub use id::Id;
pub use interval::Interval;
pub use result_state::ResultState;
15 changes: 15 additions & 0 deletions common/src/types/result_state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use serde::{Deserialize, Serialize};

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(
feature = "sqlx",
sqlx(type_name = "result_state", rename_all = "snake_case")
)]
pub enum ResultState {
Init,
Valid,
Invalid,
Inconclusive,
Error,
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading