From e543ccc2e1038dda47feaf4eba767dc6008537e0 Mon Sep 17 00:00:00 2001 From: Kristin Aoki <42981026+KristinAoki@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:41:58 -0400 Subject: [PATCH] fix: parser not saving unlimited attempts (#483) * fix: default settings not loading for new problems * fix: unlimited attempts not saving --- .../components/EditProblemView/hooks.test.js | 3 +- .../SelectTypeWrapper/SelectTypeFooter.jsx | 19 +++++++++-- .../SelectTypeFooter.test.jsx | 3 +- .../components/SelectTypeModal/hooks.js | 22 ++++++++++--- .../components/SelectTypeModal/hooks.test.js | 29 +++++++++++++---- .../ProblemEditor/data/SettingsParser.js | 4 ++- src/editors/data/redux/problem/reducers.js | 2 +- src/editors/utils/index.js | 1 + src/editors/utils/snakeCaseKeys.js | 15 +++++++++ src/editors/utils/snakeCaseKeys.test.js | 32 +++++++++++++++++++ 10 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 src/editors/utils/snakeCaseKeys.js create mode 100644 src/editors/utils/snakeCaseKeys.test.js diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js b/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js index 83226be54..fe3a4d7b0 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js @@ -305,7 +305,7 @@ describe('EditProblemView hooks parseState', () => { }); }); - it('returned parseState content.settings should not include default values', () => { + it('returned parseState content.settings should not include default values (not including maxAttempts)', () => { const problem = { ...problemState, problemType: ProblemTypeKeys.NUMERIC, @@ -326,6 +326,7 @@ describe('EditProblemView hooks parseState', () => { openSaveWarningModal, }); expect(settings).toEqual({ + max_attempts: '', attempts_before_showanswer_button: 0, submission_wait_seconds: 0, weight: 1, diff --git a/src/editors/containers/ProblemEditor/components/SelectTypeModal/SelectTypeWrapper/SelectTypeFooter.jsx b/src/editors/containers/ProblemEditor/components/SelectTypeModal/SelectTypeWrapper/SelectTypeFooter.jsx index efb25fa80..677dc4988 100644 --- a/src/editors/containers/ProblemEditor/components/SelectTypeModal/SelectTypeWrapper/SelectTypeFooter.jsx +++ b/src/editors/containers/ProblemEditor/components/SelectTypeModal/SelectTypeWrapper/SelectTypeFooter.jsx @@ -11,12 +11,13 @@ import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/ import messages from './messages'; import hooks from '../hooks'; -import { actions } from '../../../../../data/redux'; +import { actions, selectors } from '../../../../../data/redux'; export const SelectTypeFooter = ({ onCancel, selected, // redux + defaultSettings, updateField, setBlockTitle, // injected, @@ -35,7 +36,12 @@ export const SelectTypeFooter = ({