diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.js b/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.js index 6d5b9afda1..21938def8a 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.js +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.js @@ -122,8 +122,8 @@ export const checkForNoAnswers = ({ openSaveWarningModal, problem }) => { let correctAnswer; answers.forEach(answer => { if (answer.correct) { - const title = simpleTextAreaProblems.includes(problemType) ? answer.title : answerTitles[answer.id]; - if (title?.length > 0) { + const title = simpleTextAreaProblems.includes(problemType) ? answer.title.toString() : answerTitles[answer.id]; + if (title.length > 0) { correctAnswer = true; } } diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js b/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js index 2184782e37..7e4ce5adee 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js @@ -383,6 +383,22 @@ describe('EditProblemView hooks parseState', () => { expect(openSaveWarningModal).toHaveBeenCalled(); expect(content).toEqual(null); }); + it('should return the correct content if the user entered a number as the correct answer for a dropdown type problem', () => { + const problem = { ...problemState, answers: [{ id: 'A', title: 1234, correct: true }] }; + const content = hooks.getContent({ + isAdvancedProblemType: false, + problemState: problem, + editorRef, + assets, + lmsEndpointUrl, + openSaveWarningModal, + }); + expect(openSaveWarningModal).toHaveBeenCalled(); + expect(content).toEqual({ + olx: mockBuiltOLX, + settings: expectedSettings, + }); + }); }); });