diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.js b/src/editors/containers/ProblemEditor/data/OLXParser.js
index 561b365c4..44d70e73a 100644
--- a/src/editors/containers/ProblemEditor/data/OLXParser.js
+++ b/src/editors/containers/ProblemEditor/data/OLXParser.js
@@ -226,28 +226,6 @@ export class OLXParser {
parseNumericResponse() {
const { numericalresponse } = this.problem;
- let answers = [];
- let subAnswers = [];
- let data = {};
- // TODO: Find a way to add answers using additional_answers v/s numericalresponse
- if (_.isArray(numericalresponse)) {
- numericalresponse.forEach((numericalAnswer) => {
- subAnswers = this.parseNumericResponseObject(numericalAnswer, answers.length);
- answers = _.concat(answers, subAnswers);
- });
- } else {
- subAnswers = this.parseNumericResponseObject(numericalresponse, answers.length);
- answers = _.concat(answers, subAnswers);
- }
-
- data = {
- answers,
- };
-
- return data;
- }
-
- parseNumericResponseObject(numericalresponse, answerOffset) {
let answerFeedback = '';
const answers = [];
let responseParam = {};
@@ -261,7 +239,7 @@ export class OLXParser {
};
}
answers.push({
- id: indexToLetterMap[answers.length + answerOffset],
+ id: indexToLetterMap[answers.length],
title: numericalresponse['@_answer'],
correct: true,
selectedFeedback: feedback,
@@ -274,7 +252,7 @@ export class OLXParser {
additionalAnswer.forEach((newAnswer) => {
answerFeedback = this.getFeedback(newAnswer);
answers.push({
- id: indexToLetterMap[answers.length + answerOffset],
+ id: indexToLetterMap[answers.length],
title: newAnswer['@_answer'],
correct: true,
selectedFeedback: answerFeedback,
@@ -283,13 +261,13 @@ export class OLXParser {
} else {
answerFeedback = this.getFeedback(additionalAnswer);
answers.push({
- id: indexToLetterMap[answers.length + answerOffset],
+ id: indexToLetterMap[answers.length],
title: additionalAnswer['@_answer'],
correct: true,
selectedFeedback: answerFeedback,
});
}
- return answers;
+ return { answers };
}
parseQuestions(problemType) {
@@ -386,10 +364,8 @@ export class OLXParser {
return ProblemTypeKeys.ADVANCED;
}
// make sure compound problems are treated as advanced
- // TODO: Find a way to add answers using additional_answers v/s numericalresponse
if ((problemTypeKeys.length > 1)
- || (problemTypeKeys[0] !== ProblemTypeKeys.NUMERIC // multiple numeric problems are really just multiple answers
- && _.isArray(this.problem[problemTypeKeys[0]])
+ || (_.isArray(this.problem[problemTypeKeys[0]])
&& this.problem[problemTypeKeys[0]].length > 1)) {
return ProblemTypeKeys.ADVANCED;
}
diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.test.js b/src/editors/containers/ProblemEditor/data/OLXParser.test.js
index c0c8b4bab..9041ead4d 100644
--- a/src/editors/containers/ProblemEditor/data/OLXParser.test.js
+++ b/src/editors/containers/ProblemEditor/data/OLXParser.test.js
@@ -4,13 +4,14 @@ import {
getCheckboxesOLXWithFeedbackAndHintsOLX,
dropdownOLXWithFeedbackAndHintsOLX,
numericInputWithFeedbackAndHintsOLX,
- numericInputWithFeedbackAndHintsOLXException,
textInputWithFeedbackAndHintsOLX,
multipleChoiceWithoutAnswers,
multipleChoiceWithFeedbackAndHintsOLX,
textInputWithFeedbackAndHintsOLXWithMultipleAnswers,
advancedProblemOlX,
multipleProblemOlX,
+ multipleProblemTwoOlX,
+ multipleProblemThreeOlX,
blankProblemOLX,
blankQuestionOLX,
styledQuestionOLX,
@@ -53,6 +54,16 @@ describe('Check OLXParser problem type', () => {
const problemType = olxparser.getProblemType();
expect(problemType).toBe(ProblemTypeKeys.ADVANCED);
});
+ test('Test Advanced Problem Type by multiples, second example', () => {
+ const olxparser = new OLXParser(multipleProblemTwoOlX.rawOLX);
+ const problemType = olxparser.getProblemType();
+ expect(problemType).toBe(ProblemTypeKeys.ADVANCED);
+ });
+ test('Test Advanced Problem Type by multiples, third example', () => {
+ const olxparser = new OLXParser(multipleProblemThreeOlX.rawOLX);
+ const problemType = olxparser.getProblemType();
+ expect(problemType).toBe(ProblemTypeKeys.ADVANCED);
+ });
test('Test Blank Problem Type', () => {
const olxparser = new OLXParser(blankProblemOLX.rawOLX);
const problemType = olxparser.getProblemType();
@@ -124,11 +135,6 @@ describe('Check OLXParser for answer parsing', () => {
const answer = olxparser.parseNumericResponse();
expect(answer).toEqual(numericInputWithFeedbackAndHintsOLX.data);
});
- test('Test numerical response answers exception', () => {
- const olxparser = new OLXParser(numericInputWithFeedbackAndHintsOLXException.rawOLX);
- const answer = olxparser.parseNumericResponse();
- expect(answer).toEqual(numericInputWithFeedbackAndHintsOLXException.data);
- });
});
describe('Check OLXParser for question parsing', () => {
@@ -157,11 +163,6 @@ describe('Check OLXParser for question parsing', () => {
const question = olxparser.parseQuestions('numericalresponse');
expect(question).toEqual(numericInputWithFeedbackAndHintsOLX.question);
});
- test('Test numerical response question exception', () => {
- const olxparser = new OLXParser(numericInputWithFeedbackAndHintsOLXException.rawOLX);
- const question = olxparser.parseQuestions('numericalresponse');
- expect(question).toEqual(numericInputWithFeedbackAndHintsOLXException.question);
- });
test('Test OLX with no question content should have empty string for question', () => {
const olxparser = new OLXParser(blankQuestionOLX.rawOLX);
const problemType = olxparser.getProblemType();
diff --git a/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.js b/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.js
index 4197d2f0a..0f7681335 100644
--- a/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.js
+++ b/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.js
@@ -258,11 +258,6 @@ class ReactStateOLXParser {
let answerObject = {};
const additionalAnswers = [];
let firstCorrectAnswerParsed = false;
- /*
- TODO: Need to figure out how to add multiple numericalresponse,
- the parser right now converts all the other right answers into
- additional answers.
- */
answers.forEach((answer) => {
const correcthint = this.getAnswerHints(answer);
if (this.hasAttributeWithValue(answer, 'title')) {
diff --git a/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.test.js b/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.test.js
index 6c98ba99d..6ea378195 100644
--- a/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.test.js
+++ b/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.test.js
@@ -3,7 +3,6 @@ import {
checkboxesOLXWithFeedbackAndHintsOLX,
dropdownOLXWithFeedbackAndHintsOLX,
numericInputWithFeedbackAndHintsOLX,
- numericInputWithFeedbackAndHintsOLXException,
textInputWithFeedbackAndHintsOLX,
multipleChoiceWithFeedbackAndHintsOLX,
textInputWithFeedbackAndHintsOLXWithMultipleAnswers,
@@ -46,13 +45,6 @@ describe('Check React Sate OLXParser problem', () => {
const buildOLX = stateParser.buildOLX();
expect(buildOLX.replace(/\s/g, '')).toEqual(numericInputWithFeedbackAndHintsOLX.buildOLX.replace(/\s/g, ''));
});
- test('Test numerical response with feedback and hints problem type with exception', () => {
- const olxparser = new OLXParser(numericInputWithFeedbackAndHintsOLXException.rawOLX);
- const problem = olxparser.getParsedOLXData();
- const stateParser = new ReactStateOLXParser({ problem });
- const buildOLX = stateParser.buildOLX();
- expect(buildOLX.replace(/\s/g, '')).toEqual(numericInputWithFeedbackAndHintsOLXException.buildOLX.replace(/\s/g, ''));
- });
test('Test string response with feedback and hints, multiple answers', () => {
const olxparser = new OLXParser(textInputWithFeedbackAndHintsOLXWithMultipleAnswers.rawOLX);
const problem = olxparser.getParsedOLXData();
diff --git a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js
index 2c6da1e90..5333bdc58 100644
--- a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js
+++ b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js
@@ -523,83 +523,6 @@ export const textInputWithFeedbackAndHintsOLXWithMultipleAnswers = {
`,
};
-export const numericInputWithFeedbackAndHintsOLXException = {
- rawOLX: ` You can use this template as a guide to the simple editor markdown and OLX markup to use for numerical input with hints and feedback problems. Edit this component to replace this template with your own assessment.
You can use this template as a guide to the simple editor markdown and OLX markup to use for numerical input with hints and feedback problems. Edit this component to replace this template with your own assessment.
You can add an optional tip or note related to the prompt like this.', - buildOLX: `You can use this template as a guide to the simple editor markdown and OLX markup to use for numerical input with hints and feedback problems. Edit this component to replace this template with your own assessment.
- - You can add an optional tip or note related to the prompt like this. -