Skip to content

Commit

Permalink
test: text input problem parse feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Feb 21, 2025
1 parent 9d1bbd8 commit dd3d777
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/editors/containers/ProblemEditor/data/OLXParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
dropdownOLXWithFeedbackAndHintsOLX,
numericInputWithFeedbackAndHintsOLX,
textInputWithFeedbackAndHintsOLX,
textInputWithFeedbackInIncorrectAnswerOnlyOLX,
multipleChoiceWithoutAnswers,
multipleChoiceSingleAnswer,
multipleChoiceWithFeedbackAndHintsOLX,
Expand Down Expand Up @@ -39,6 +40,7 @@ const multipleChoiceOlxParser = new OLXParser(multipleChoiceWithFeedbackAndHints
const multipleChoiceWithoutAnswersOlxParser = new OLXParser(multipleChoiceWithoutAnswers.rawOLX);
const multipleChoiceSingleAnswerOlxParser = new OLXParser(multipleChoiceSingleAnswer.rawOLX);
const textInputOlxParser = new OLXParser(textInputWithFeedbackAndHintsOLX.rawOLX);
const textInputIncorrectFeedbackOlxParser = new OLXParser(textInputWithFeedbackInIncorrectAnswerOnlyOLX.rawOLX);
const textInputMultipleAnswersOlxParser = new OLXParser(textInputWithFeedbackAndHintsOLXWithMultipleAnswers.rawOLX);
const advancedOlxParser = new OLXParser(advancedProblemOlX.rawOLX);
const multipleTextInputOlxParser = new OLXParser(multipleTextInputProblemOlX.rawOLX);
Expand Down Expand Up @@ -286,6 +288,13 @@ describe('OLXParser', () => {
expect(answers).toHaveLength(3);
});
});
describe('given text input olx with feedback for incorrect answer only and hints', () => {
const { answers } = textInputIncorrectFeedbackOlxParser.parseStringResponse();
it('should equal an array of objects with length three', () => {
expect(answers).toEqual(textInputWithFeedbackInIncorrectAnswerOnlyOLX.data.answers);
expect(answers).toHaveLength(3);
});
});
describe('given text input olx with feedback and hints with multiple answers', () => {
const { answers } = textInputMultipleAnswersOlxParser.parseStringResponse();
it('should equal an array of objects with length four', () => {
Expand Down
73 changes: 73 additions & 0 deletions src/editors/containers/ProblemEditor/data/mockData/olxTestData.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,79 @@ export const textInputWithFeedbackAndHintsOLX = {
`,
};

export const textInputWithFeedbackInIncorrectAnswerOnlyOLX = {
rawOLX: `<problem>
<stringresponse answer="the correct answer" type="ci">
<p>You can use this template as a guide to the simple editor markdown and OLX markup to use for text input with hints and feedback problems. Edit this component to replace this template with your own assessment.</p>
<label>Add the question text, or prompt, here. This text is required.</label>
<description>You can add an optional tip or note related to the prompt like this. </description>
<additional_answer answer="optional acceptable variant of the correct answer"/>
<stringequalhint answer="optional incorrect answer such as a frequent misconception"><p>You can specify optional feedback for none, a subset, or all of the answers.</p></stringequalhint>
<textline size="20"/>
</stringresponse>
<demandhint>
<hint><p>You can add an optional hint like this. Problems that have a hint include a hint button, and this text appears the first time learners select the button.</p></hint>
<hint><p>If you add more than one hint, a different hint appears each time learners select the hint button.</p></hint>
</demandhint>
</problem>`,
hints: [{
id: 0,
value: '<p>You can add an optional hint like this. Problems that have a hint include a hint button, and this text appears the first time learners select the button.</p>',
},
{
id: 1,
value: '<p>If you add more than one hint, a different hint appears each time learners select the hint button.</p>',
},
],
data: {
answers: [
{
id: 'A',
title: 'the correct answer',
correct: true,
selectedFeedback: '',
},
{
id: 'B',
title: 'optional acceptable variant of the correct answer',
correct: true,
selectedFeedback: '',
},
{
id: 'C',
title: 'optional incorrect answer such as a frequent misconception',
correct: false,
selectedFeedback: '<p>You can specify optional feedback for none, a subset, or all of the answers.</p>',
},
],
additionalStringAttributes: {
type: 'ci',
textline: {
size: '20',
},
},
},
question: `<p>You can use this template as a guide to the simple editor markdown and OLX markup to use for text input with hints and feedback problems. Edit this component to replace this template with your own assessment.</p>
<label>Add the question text, or prompt, here. This text is required.</label>
<em class="olx_description">You can add an optional tip or note related to the prompt like this. </em>`,
buildOLX: `<problem>
<stringresponse answer="the correct answer" type="ci">
<p>You can use this template as a guide to the simple editor markdown and OLX markup to use for text input with hints and feedback problems. Edit this component to replace this template with your own assessment.</p>
<label>Add the question text, or prompt, here. This text is required.</label>
<em>You can add an optional tip or note related to the prompt like this.</em>
<correcthint><p>You can specify optional feedback like this, which appears after this answer is submitted.</p></correcthint>
<additional_answer answer="optional acceptable variant of the correct answer"></additional_answer>
<stringequalhint answer="optional incorrect answer such as a frequent misconception"><p>You can specify optional feedback for none, a subset, or all of the answers.</p></stringequalhint>
<textline size="20"></textline>
</stringresponse>
<demandhint>
<hint><p>You can add an optional hint like this. Problems that have a hint include a hint button, and this text appears the first time learners select the button.</p></hint>
<hint><p>If you add more than one hint, a different hint appears each time learners select the hint button.</p></hint>
</demandhint>
</problem>
`,
};

export const textInputWithFeedbackAndHintsOLXWithMultipleAnswers = {
rawOLX: `<problem>
<stringresponse answer="the correct answer" type="ci">
Expand Down

0 comments on commit dd3d777

Please sign in to comment.