diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.js b/src/editors/containers/ProblemEditor/data/OLXParser.js index 45ffa16e0..ccedbefbf 100644 --- a/src/editors/containers/ProblemEditor/data/OLXParser.js +++ b/src/editors/containers/ProblemEditor/data/OLXParser.js @@ -181,6 +181,9 @@ export class OLXParser { if (_.keys(widget).some((tag) => !permissableTags.includes(tag))) { throw new Error('Misc Tags, reverting to Advanced Editor'); } + if (_.get(this.problem, `${problemType}.@_partial_credit`)) { + throw new Error('Partial credit not supported by GUI, reverting to Advanced Editor'); + } const choice = _.get(widget, option); const isComplexAnswer = RichTextProblems.includes(problemType); if (_.isEmpty(choice)) { @@ -401,6 +404,9 @@ export class OLXParser { 'correcthint', ); const { numericalresponse } = this.problem; + if (_.get(numericalresponse, '@_partial_credit')) { + throw new Error('Partial credit not supported by GUI, reverting to Advanced Editor'); + } let answerFeedback = ''; const answers = []; let responseParam = {}; diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.test.js b/src/editors/containers/ProblemEditor/data/OLXParser.test.js index 410fa85eb..65a42eaba 100644 --- a/src/editors/containers/ProblemEditor/data/OLXParser.test.js +++ b/src/editors/containers/ProblemEditor/data/OLXParser.test.js @@ -11,15 +11,18 @@ import { advancedProblemOlX, multipleTextInputProblemOlX, multipleNumericProblemOlX, + multiSelectPartialCredit, NumericAndTextInputProblemOlX, blankProblemOLX, blankQuestionOLX, styledQuestionOLX, shuffleProblemOLX, scriptProblemOlX, + singleSelectPartialCredit, labelDescriptionQuestionOLX, htmlEntityTestOLX, numberParseTestOLX, + numericalProblemPartialCredit, solutionExplanationTest, solutionExplanationWithoutDivTest, tablesInRichTextTest, @@ -42,6 +45,9 @@ const multipleNumericOlxParser = new OLXParser(multipleNumericProblemOlX.rawOLX) const numericAndTextInputOlxParser = new OLXParser(NumericAndTextInputProblemOlX.rawOLX); const labelDescriptionQuestionOlxParser = new OLXParser(labelDescriptionQuestionOLX.rawOLX); const shuffleOlxParser = new OLXParser(shuffleProblemOLX.rawOLX); +const multiSelectPartialCreditOlxParser = new OLXParser(multiSelectPartialCredit.rawOLX); +const singleSelectPartialCreditParser = new OLXParser(singleSelectPartialCredit.rawOLX); +const numericalProblemPartialCreditParser = new OLXParser(numericalProblemPartialCredit.rawOLX); describe('OLXParser', () => { describe('throws error and redirects to advanced editor', () => { @@ -71,6 +77,36 @@ describe('OLXParser', () => { expect(() => olxparser.parseQuestions('numericalresponse')).toThrow(new Error('Script Tag, reverting to Advanced Editor')); }); }); + describe('when multi select problem finds partial_credit attribute', () => { + it('should throw error and contain message regarding opening advanced editor', () => { + try { + multiSelectPartialCreditOlxParser.getParsedOLXData(); + } catch (e) { + expect(e).toBeInstanceOf(Error); + expect(e.message).toBe('Partial credit not supported by GUI, reverting to Advanced Editor'); + } + }); + }); + describe('when multi select problem finds partial_credit attribute', () => { + it('should throw error and contain message regarding opening advanced editor', () => { + try { + numericalProblemPartialCreditParser.getParsedOLXData(); + } catch (e) { + expect(e).toBeInstanceOf(Error); + expect(e.message).toBe('Partial credit not supported by GUI, reverting to Advanced Editor'); + } + }); + }); + describe('when multi select problem finds partial_credit attribute', () => { + it('should throw error and contain message regarding opening advanced editor', () => { + try { + singleSelectPartialCreditParser.getParsedOLXData(); + } catch (e) { + expect(e).toBeInstanceOf(Error); + expect(e.message).toBe('Partial credit not supported by GUI, reverting to Advanced Editor'); + } + }); + }); }); describe('getProblemType()', () => { describe('given a blank problem', () => { diff --git a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js index a6d53ce29..79d4b9cbf 100644 --- a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js +++ b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js @@ -1112,3 +1112,43 @@ export const parseOutExplanationTests = {
solution meat
` }; + +export const multiSelectPartialCredit = { + rawOLX: `