Feat allow singleselect to accept multiple correct answers (#241)

This commit is contained in:
Raymond Zhou
2023-02-10 08:31:52 -08:00
committed by GitHub
parent a22ad54502
commit eff3df7115
4 changed files with 5 additions and 5 deletions

View File

@@ -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 }) => {

View File

@@ -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);

View File

@@ -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 });

View File

@@ -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 });