diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.js b/src/editors/containers/ProblemEditor/data/OLXParser.js index ccedbefbf..918aa4958 100644 --- a/src/editors/containers/ProblemEditor/data/OLXParser.js +++ b/src/editors/containers/ProblemEditor/data/OLXParser.js @@ -487,7 +487,12 @@ export class OLXParser { } }); const questionString = this.richTextBuilder.build(questionArray); - return questionString.replace(//gm, '').replace(/<\/description>/gm, ''); + const res = this.replaceOlxDescriptionTag(questionString); + return res; + } + + replaceOlxDescriptionTag(questionString) { + return questionString.replace(//gm, '').replace(/<\/description>/gm, ''); } /** getHints() diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.test.js b/src/editors/containers/ProblemEditor/data/OLXParser.test.js index 65a42eaba..ed5dbe83f 100644 --- a/src/editors/containers/ProblemEditor/data/OLXParser.test.js +++ b/src/editors/containers/ProblemEditor/data/OLXParser.test.js @@ -329,7 +329,7 @@ describe('OLXParser', () => { const olxparser = new OLXParser(labelDescriptionQuestionOLX.rawOLX); const problemType = olxparser.getProblemType(); const question = olxparser.parseQuestions(problemType); - it('should append the label/description to the question', () => { + it('should append the label/description to the question, converting description to with "olx_description" class', () => { expect(question.trim()).toBe(labelDescriptionQuestionOLX.question); }); }); diff --git a/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.js b/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.js index 4532308b0..8b0f01d1f 100644 --- a/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.js +++ b/src/editors/containers/ProblemEditor/data/ReactStateOLXParser.js @@ -193,29 +193,31 @@ class ReactStateOLXParser { /** addQuestion() * The editorObject saved to the class constuctor is parsed for the attribute question. The question is parsed and - * checked for label tags. After the question is fully updated, the questionObject is returned. + * checked for label and em tags. After the question is fully updated, the questionObject is returned. + * TODO: this is very brittle and unreliable. Needs improvement. * @return {object} object representaion of question */ addQuestion() { const { question } = this.editorObject; const questionObject = this.richTextParser.parse(question); - /* Removes block tags like

or

that surround the