fix: restrict single select questions to one correct answer (#2618)
This commit is contained in:
@@ -90,7 +90,7 @@ export const useFeedback = (answer) => {
|
||||
};
|
||||
|
||||
export const isSingleAnswerProblem = (problemType) => (
|
||||
problemType === ProblemTypeKeys.DROPDOWN
|
||||
problemType === ProblemTypeKeys.SINGLESELECT || problemType === ProblemTypeKeys.DROPDOWN
|
||||
);
|
||||
|
||||
export const useAnswerContainer = ({ answers, updateField }) => {
|
||||
|
||||
@@ -200,7 +200,7 @@ describe('Answer Options Hooks', () => {
|
||||
});
|
||||
describe('isSingleAnswerProblem()', () => {
|
||||
test('singleSelect', () => {
|
||||
expect(module.isSingleAnswerProblem(ProblemTypeKeys.SINGLESELECT)).toBe(false);
|
||||
expect(module.isSingleAnswerProblem(ProblemTypeKeys.SINGLESELECT)).toBe(true);
|
||||
});
|
||||
test('multiSelect', () => {
|
||||
expect(module.isSingleAnswerProblem(ProblemTypeKeys.MULTISELECT)).toBe(false);
|
||||
|
||||
@@ -299,9 +299,9 @@ export const typeRowHooks = ({
|
||||
if (typeKey === ProblemTypeKeys.TEXTINPUT && RichTextProblems.includes(problemType)) {
|
||||
convertToPlainText();
|
||||
}
|
||||
// Dropdown problems can only have one correct answer. When there is more than one correct answer
|
||||
// Dropdown and single-select problems can only have one correct answer. When there is more than one correct answer
|
||||
// from a previous problem type, the correct attribute for selected answers need to be set to false.
|
||||
if (typeKey === ProblemTypeKeys.DROPDOWN) {
|
||||
if (typeKey === ProblemTypeKeys.DROPDOWN || typeKey === ProblemTypeKeys.SINGLESELECT) {
|
||||
if (correctAnswerCount > 1) {
|
||||
clearPreviouslySelectedAnswers();
|
||||
} else if (RichTextProblems.includes(problemType)) {
|
||||
|
||||
Reference in New Issue
Block a user