From 0c53d8c4919c263368c397eb9e32253f0a692a01 Mon Sep 17 00:00:00 2001 From: Ihor Romaniuk Date: Tue, 27 Aug 2024 18:52:48 +0200 Subject: [PATCH] fix: reset active answers for single answer problem type (#426) --- src/editors/data/redux/problem/reducers.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/editors/data/redux/problem/reducers.js b/src/editors/data/redux/problem/reducers.js index c61dfb240..0255d0130 100644 --- a/src/editors/data/redux/problem/reducers.js +++ b/src/editors/data/redux/problem/reducers.js @@ -60,11 +60,9 @@ const problem = createSlice({ if (obj.id === id) { if (_.has(answer, 'correct') && payload.correct) { correctAnswerCount += 1; - return { ...obj, ...answer }; } - if (_.has(answer, 'correct') && payload.correct === false) { + if (_.has(answer, 'correct') && payload.correct === false && correctAnswerCount > 0) { correctAnswerCount -= 1; - return { ...obj, ...answer }; } return { ...obj, ...answer }; }