From 4bfd3fa966eeaa604697321ecf39e8e41907a721 Mon Sep 17 00:00:00 2001 From: Ivan Danilov Date: Tue, 15 Oct 2024 21:27:27 +0300 Subject: [PATCH 1/5] chore: Do not apply cross-check score more than max score of a task --- server/src/routes/course/crossCheck/createResult.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/routes/course/crossCheck/createResult.ts b/server/src/routes/course/crossCheck/createResult.ts index 46d3178ce4..63f830980b 100644 --- a/server/src/routes/course/crossCheck/createResult.ts +++ b/server/src/routes/course/crossCheck/createResult.ts @@ -62,7 +62,7 @@ export const createResult = (_: ILogger) => async (ctx: Router.RouterContext) => review: Array.isArray(inputData.review) ? inputData.review : [], }; - if (isNaN(data.score) || data.score < 0) { + if (isNaN(data.score) || data.score < 0 || data.score > courseTask.maxScore) { setErrorResponse(ctx, BAD_REQUEST, 'no score provided'); return; } From 9961135be9093ca71256e5086b509bfd3482828d Mon Sep 17 00:00:00 2001 From: Ivan Danilov Date: Tue, 15 Oct 2024 23:36:41 +0300 Subject: [PATCH 2/5] Excplicit error message for score exceeding max score --- server/src/routes/course/crossCheck/createResult.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/routes/course/crossCheck/createResult.ts b/server/src/routes/course/crossCheck/createResult.ts index 63f830980b..4196fca377 100644 --- a/server/src/routes/course/crossCheck/createResult.ts +++ b/server/src/routes/course/crossCheck/createResult.ts @@ -62,7 +62,12 @@ export const createResult = (_: ILogger) => async (ctx: Router.RouterContext) => review: Array.isArray(inputData.review) ? inputData.review : [], }; - if (isNaN(data.score) || data.score < 0 || data.score > courseTask.maxScore) { + 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; } From 86bdbaf136516b38da3a6f66b787cc577dc208c8 Mon Sep 17 00:00:00 2001 From: Ivan Danilov Date: Wed, 16 Oct 2024 00:02:02 +0300 Subject: [PATCH 3/5] Add check from front-end side for score exceeding max score --- client/src/pages/course/student/cross-check-review.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/pages/course/student/cross-check-review.tsx b/client/src/pages/course/student/cross-check-review.tsx index 4aa5c04800..317cce8315 100644 --- a/client/src/pages/course/student/cross-check-review.tsx +++ b/client/src/pages/course/student/cross-check-review.tsx @@ -140,6 +140,10 @@ function Page() { const submitReview = withLoading(async values => { try { + if (typeof values.maxScore !== 'undefined' && values.maxScore < score) { + message.error('The score is greater than the maximum score for the task'); + return; + } await courseService.postTaskSolutionResult(values.githubId, values.courseTaskId, { score, comment: markdownLabel + values.comment, From 4b4d0da4812418f6bbe1fc7a867d77ac9b5f35d4 Mon Sep 17 00:00:00 2001 From: Ivan Danilov Date: Wed, 16 Oct 2024 11:36:43 +0300 Subject: [PATCH 4/5] Update client/src/pages/course/student/cross-check-review.tsx Co-authored-by: Valery <57412523+valerydluski@users.noreply.github.com> --- client/src/pages/course/student/cross-check-review.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/pages/course/student/cross-check-review.tsx b/client/src/pages/course/student/cross-check-review.tsx index 317cce8315..fb4f814b7a 100644 --- a/client/src/pages/course/student/cross-check-review.tsx +++ b/client/src/pages/course/student/cross-check-review.tsx @@ -141,7 +141,7 @@ function Page() { const submitReview = withLoading(async values => { try { if (typeof values.maxScore !== 'undefined' && values.maxScore < score) { - message.error('The score is greater than the maximum score for the task'); + message.error(`The score (${score}) exceeds the maximum score (${values.maxScore}) for the task.`); return; } await courseService.postTaskSolutionResult(values.githubId, values.courseTaskId, { From 1a8a242dfc939c21cb949f621c8eb8f11d2df9a1 Mon Sep 17 00:00:00 2001 From: Ivan Danilov Date: Wed, 16 Oct 2024 11:37:57 +0300 Subject: [PATCH 5/5] Update client/src/pages/course/student/cross-check-review.tsx Co-authored-by: Valery <57412523+valerydluski@users.noreply.github.com> --- client/src/pages/course/student/cross-check-review.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/pages/course/student/cross-check-review.tsx b/client/src/pages/course/student/cross-check-review.tsx index fb4f814b7a..f23acb337c 100644 --- a/client/src/pages/course/student/cross-check-review.tsx +++ b/client/src/pages/course/student/cross-check-review.tsx @@ -140,7 +140,7 @@ function Page() { const submitReview = withLoading(async values => { try { - if (typeof values.maxScore !== 'undefined' && values.maxScore < score) { + if (values.maxScore != null && values.maxScore < score) { message.error(`The score (${score}) exceeds the maximum score (${values.maxScore}) for the task.`); return; }