Skip to content

Commit

Permalink
Grade validation for manual completion (#1286)
Browse files Browse the repository at this point in the history
* Error for invalid grade

* Fix to validation

---------

Co-authored-by: Maija Y <[email protected]>
  • Loading branch information
Maijjay and Maija Y authored Aug 15, 2024
1 parent 1a2f591 commit 26765b2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions services/headless-lms/models/src/library/progressing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,16 @@ pub async fn add_manual_completions(
},
)
.await?;

if completion.grade.is_some()
&& (completion.grade > Some(5) || completion.grade < Some(0))
{
return Err(ModelError::new(
ModelErrorType::PreconditionFailed,
"Invalid grade".to_string(),
None,
));
}
course_module_completions::insert(
&mut tx,
PKeyPolicy::Generate,
Expand Down

0 comments on commit 26765b2

Please sign in to comment.