Feat allow not select feedback for only multi select problem type (#267)

This commit is contained in:
Raymond Zhou
2023-03-08 12:18:57 -08:00
committed by GitHub
parent b0c1e4d754
commit e6b532c71e
3 changed files with 45 additions and 45 deletions

View File

@@ -20,18 +20,7 @@ export const FeedbackBox = ({
intl,
};
return ((problemType === ProblemTypeKeys.NUMERIC || problemType === ProblemTypeKeys.TEXTINPUT) ? (
<div className="bg-light-300 p-4 mt-3 rounded text-primary-500">
<FeedbackControl
key={`selectedfeedback-${answer.id}`}
feedback={answer.selectedFeedback}
labelMessage={messages.selectedFeedbackLabel}
labelMessageBoldUnderline={messages.selectedFeedbackLabelBoldUnderlineText}
onChange={setSelectedFeedback}
{...props}
/>
</div>
) : (
return ((problemType === ProblemTypeKeys.MULTISELECT) ? (
<div className="bg-light-300 p-4 mt-3 rounded text-primary-500">
<FeedbackControl
key={`selectedfeedback-${answer.id}`}
@@ -50,6 +39,17 @@ export const FeedbackBox = ({
{...props}
/>
</div>
) : (
<div className="bg-light-300 p-4 mt-3 rounded text-primary-500">
<FeedbackControl
key={`selectedfeedback-${answer.id}`}
feedback={answer.selectedFeedback}
labelMessage={messages.selectedFeedbackLabel}
labelMessageBoldUnderline={messages.selectedFeedbackLabelBoldUnderlineText}
onChange={setSelectedFeedback}
{...props}
/>
</div>
));
};
FeedbackBox.propTypes = {

View File

@@ -22,7 +22,7 @@ describe('FeedbackBox component', () => {
test('renders as expected with a numeric input problem', () => {
expect(shallow(<FeedbackBox {...props} problemType="numericalresponse" />)).toMatchSnapshot();
});
test('renders as expected with a text input problem', () => {
expect(shallow(<FeedbackBox {...props} problemType="stringresponse" />)).toMatchSnapshot();
test('renders as expected with a multi select problem', () => {
expect(shallow(<FeedbackBox {...props} problemType="choiceresponse" />)).toMatchSnapshot();
});
});

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`FeedbackBox component renders as expected with a numeric input problem 1`] = `
exports[`FeedbackBox component renders as expected with a multi select problem 1`] = `
<div
className="bg-light-300 p-4 mt-3 rounded text-primary-500"
>
@@ -33,10 +33,39 @@ exports[`FeedbackBox component renders as expected with a numeric input problem
}
}
/>
<FeedbackControl
answer={
Object {
"correct": true,
"id": "A",
"problemType": "sOMepRObleM",
"selectedFeedback": "some feedback",
"title": "Answer 1",
"unselectedFeedback": "unselectedFeedback",
}
}
feedback="unselectedFeedback"
intl={Object {}}
key="unselectedfeedback-A"
labelMessage={
Object {
"defaultMessage": "Show following feedback when {answerId} {boldunderline}:",
"description": "Label text for feedback if option is not selected",
"id": "authoring.answerwidget.feedback.unselected.label",
}
}
labelMessageBoldUnderline={
Object {
"defaultMessage": "is not selected",
"description": "Bold & underlined text for feedback if option is not selected",
"id": "authoring.answerwidget.feedback.unselected.label.boldunderline",
}
}
/>
</div>
`;
exports[`FeedbackBox component renders as expected with a text input problem 1`] = `
exports[`FeedbackBox component renders as expected with a numeric input problem 1`] = `
<div
className="bg-light-300 p-4 mt-3 rounded text-primary-500"
>
@@ -105,34 +134,5 @@ exports[`FeedbackBox component renders as expected with default props 1`] = `
}
}
/>
<FeedbackControl
answer={
Object {
"correct": true,
"id": "A",
"problemType": "sOMepRObleM",
"selectedFeedback": "some feedback",
"title": "Answer 1",
"unselectedFeedback": "unselectedFeedback",
}
}
feedback="unselectedFeedback"
intl={Object {}}
key="unselectedfeedback-A"
labelMessage={
Object {
"defaultMessage": "Show following feedback when {answerId} {boldunderline}:",
"description": "Label text for feedback if option is not selected",
"id": "authoring.answerwidget.feedback.unselected.label",
}
}
labelMessageBoldUnderline={
Object {
"defaultMessage": "is not selected",
"description": "Bold & underlined text for feedback if option is not selected",
"id": "authoring.answerwidget.feedback.unselected.label.boldunderline",
}
}
/>
</div>
`;