Skip to content

Commit d25a46d

Browse files
author
Dima Alipov
committed
fix: confirmation window is displayed after save for dropdown
"No answer specified" confirmation window is displayed all the time after second save for dropdown.
1 parent 06d591d commit d25a46d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/editors/containers/ProblemEditor/components/EditProblemView/hooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export const checkForNoAnswers = ({ openSaveWarningModal, problem }) => {
107107
let correctAnswer;
108108
answers.forEach(answer => {
109109
if (answer.correct) {
110-
const title = simpleTextAreaProblems.includes(problemType) ? answer.title : answerTitles[answer.id];
111-
if (title?.length > 0) {
110+
const title = simpleTextAreaProblems.includes(problemType) ? answer.title.toString() : answerTitles[answer.id];
111+
if (title.length > 0) {
112112
correctAnswer = true;
113113
}
114114
}

src/editors/containers/ProblemEditor/components/EditProblemView/hooks.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,22 @@ describe('EditProblemView hooks parseState', () => {
360360
expect(openSaveWarningModal).toHaveBeenCalled();
361361
expect(content).toEqual(null);
362362
});
363+
it('should return the correct content if the user entered a number as the correct answer for a dropdown type problem', () => {
364+
const problem = { ...problemState, answers: [{ id: 'A', title: 1234, correct: true }] };
365+
const content = hooks.getContent({
366+
isAdvancedProblemType: false,
367+
problemState: problem,
368+
editorRef,
369+
assets,
370+
lmsEndpointUrl,
371+
openSaveWarningModal,
372+
});
373+
expect(openSaveWarningModal).toHaveBeenCalled();
374+
expect(content).toEqual({
375+
olx: mockBuiltOLX,
376+
settings: expectedSettings,
377+
});
378+
});
363379
});
364380
});
365381

0 commit comments

Comments
 (0)