Feat allow singleselect to accept multiple correct answers (#241)
This commit is contained in:
@@ -55,7 +55,7 @@ export const useFeedback = (answer) => {
|
||||
};
|
||||
|
||||
export const isSingleAnswerProblem = (problemType) => (
|
||||
problemType === ProblemTypeKeys.DROPDOWN || problemType === ProblemTypeKeys.SINGLESELECT
|
||||
problemType === ProblemTypeKeys.DROPDOWN
|
||||
);
|
||||
|
||||
export const useAnswerContainer = ({ answers, updateField }) => {
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('Answer Options Hooks', () => {
|
||||
});
|
||||
describe('isSingleAnswerProblem()', () => {
|
||||
test('singleSelect', () => {
|
||||
expect(module.isSingleAnswerProblem(ProblemTypeKeys.SINGLESELECT)).toBe(true);
|
||||
expect(module.isSingleAnswerProblem(ProblemTypeKeys.SINGLESELECT)).toBe(false);
|
||||
});
|
||||
test('multiSelect', () => {
|
||||
expect(module.isSingleAnswerProblem(ProblemTypeKeys.MULTISELECT)).toBe(false);
|
||||
|
||||
@@ -207,7 +207,7 @@ export const typeRowHooks = ({
|
||||
updateAnswer,
|
||||
}) => {
|
||||
const onClick = () => {
|
||||
if (typeKey === ProblemTypeKeys.SINGLESELECT || typeKey === ProblemTypeKeys.DROPDOWN) {
|
||||
if (typeKey === ProblemTypeKeys.DROPDOWN) {
|
||||
if (correctAnswerCount > 1) {
|
||||
answers.forEach(answer => {
|
||||
updateAnswer({ ...answer, correct: false });
|
||||
|
||||
@@ -250,7 +250,7 @@ describe('Problem settings hooks', () => {
|
||||
|
||||
describe('Type row hooks', () => {
|
||||
test('test onClick', () => {
|
||||
const typekey = 'multiplechoiceresponse';
|
||||
const typekey = 'optionresponse';
|
||||
const problemType = 'choiceresponse';
|
||||
const blockTitle = 'Multi-select';
|
||||
const setBlockTitle = jest.fn();
|
||||
@@ -275,7 +275,7 @@ describe('Problem settings hooks', () => {
|
||||
updateAnswer,
|
||||
});
|
||||
output.onClick();
|
||||
expect(setBlockTitle).toHaveBeenCalledWith('Single select');
|
||||
expect(setBlockTitle).toHaveBeenCalledWith('Dropdown');
|
||||
expect(updateAnswer).toHaveBeenNthCalledWith(1, { ...answers[0], correct: false });
|
||||
expect(updateAnswer).toHaveBeenNthCalledWith(2, { ...answers[1], correct: false });
|
||||
expect(updateField).toHaveBeenCalledWith({ problemType: typekey });
|
||||
|
||||
Reference in New Issue
Block a user