diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.js b/src/editors/containers/ProblemEditor/data/OLXParser.js index ca4965bd4..2a7af7dcd 100644 --- a/src/editors/containers/ProblemEditor/data/OLXParser.js +++ b/src/editors/containers/ProblemEditor/data/OLXParser.js @@ -323,6 +323,9 @@ export class OLXParser { problemArray.forEach(tag => { const tagName = Object.keys(tag)[0]; if (!nonQuestionKeys.includes(tagName)) { + if (tagName === 'script') { + throw new Error('Script Tag, reverting to Advanced Editor'); + } questionArray.push(tag); } }); diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.test.js b/src/editors/containers/ProblemEditor/data/OLXParser.test.js index 99b4580f8..23e9c8a63 100644 --- a/src/editors/containers/ProblemEditor/data/OLXParser.test.js +++ b/src/editors/containers/ProblemEditor/data/OLXParser.test.js @@ -16,6 +16,7 @@ import { blankQuestionOLX, styledQuestionOLX, shuffleProblemOLX, + scriptProblemOlX, } from './mockData/olxTestData'; import { ProblemTypeKeys } from '../../../data/constants/problem'; @@ -181,6 +182,10 @@ describe('Check OLXParser for question parsing', () => { const question = olxparser.parseQuestions('numericalresponse'); expect(question).toEqual(numericInputWithFeedbackAndHintsOLX.question); }); + test('Test Advanced Problem Type by script tag', () => { + const olxparser = new OLXParser(scriptProblemOlX.rawOLX); + expect(() => olxparser.parseQuestions('numericalresponse')).toThrow(new Error('Script Tag, reverting to Advanced Editor')); + }); 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/mockData/olxTestData.js b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js index c2e534dee..8a8603162 100644 --- a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js +++ b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js @@ -551,6 +551,22 @@ export const advancedProblemOlX = { `, }; +export const scriptProblemOlX = { + 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 add an optional tip or note related to the prompt like this. + + +

You can specify optional feedback like this, which appears after this answer is submitted.

+

You can specify optional feedback like this, which appears after this answer is submitted.

+
+
`, +}; export const multipleProblemOlX = { rawOLX: `