Skip to content

Commit

Permalink
fix: Do not apply cross-check score more than max score of a task (#2540
Browse files Browse the repository at this point in the history
)

* chore: Do not apply cross-check score more than max score of a task

* Excplicit error message for score exceeding max score

* Add check from front-end side for score exceeding max score

* Update client/src/pages/course/student/cross-check-review.tsx

Co-authored-by: Valery <[email protected]>

* Update client/src/pages/course/student/cross-check-review.tsx

Co-authored-by: Valery <[email protected]>

---------

Co-authored-by: Valery <[email protected]>
  • Loading branch information
REW1L and valerydluski authored Oct 16, 2024
1 parent 2577812 commit 758a203
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client/src/pages/course/student/cross-check-review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ function Page() {

const submitReview = withLoading(async values => {
try {
if (values.maxScore != null && values.maxScore < score) {
message.error(`The score (${score}) exceeds the maximum score (${values.maxScore}) for the task.`);
return;
}
await courseService.postTaskSolutionResult(values.githubId, values.courseTaskId, {
score,
comment: markdownLabel + values.comment,
Expand Down
5 changes: 5 additions & 0 deletions server/src/routes/course/crossCheck/createResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export const createResult = (_: ILogger) => async (ctx: Router.RouterContext) =>
review: Array.isArray(inputData.review) ? inputData.review : [],
};

if (data.score > courseTask.maxScore) {
setErrorResponse(ctx, BAD_REQUEST, 'score provided is greater than max score for the task');
return;
}

if (isNaN(data.score) || data.score < 0) {
setErrorResponse(ctx, BAD_REQUEST, 'no score provided');
return;
Expand Down

0 comments on commit 758a203

Please sign in to comment.