fix: switch to advanced editor for partial credit support
This commit reverts to advanced editor when partial_credit attribute is added to multichoice, single select and numerical problems. Without this change, the partial_credit attribute is removed from the problem on the next edit.
This commit is contained in:
@@ -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 = {};
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -1112,3 +1112,43 @@ export const parseOutExplanationTests = {
|
||||
<p>solution meat</p>
|
||||
`
|
||||
};
|
||||
|
||||
export const multiSelectPartialCredit = {
|
||||
rawOLX: `<problem>
|
||||
<choiceresponse partial_credit="EDC">
|
||||
<label>Which of the following is a fruit?</label>
|
||||
<description>Select all that apply.</description>
|
||||
<checkboxgroup>
|
||||
<choice correct="true">apple</choice>
|
||||
<choice correct="true">pumpkin</choice>
|
||||
<choice correct="false">potato</choice>
|
||||
<choice correct="true">tomato</choice>
|
||||
</checkboxgroup>
|
||||
</choiceresponse>
|
||||
</problem>`
|
||||
}
|
||||
|
||||
export const singleSelectPartialCredit = {
|
||||
rawOLX: `<problem>
|
||||
<multiplechoiceresponse partial_credit="points">
|
||||
<label>What Apple device competed with the portable CD player?</label>
|
||||
<choicegroup type="MultipleChoice">
|
||||
<choice correct="false">The iPad</choice>
|
||||
<choice correct="false">Napster</choice>
|
||||
<choice correct="true">The iPod</choice>
|
||||
<choice correct="partial" point_value="0.25">The vegetable peeler</choice>
|
||||
</choicegroup>
|
||||
</multiplechoiceresponse>
|
||||
</problem>`
|
||||
}
|
||||
|
||||
export const numericalProblemPartialCredit = {
|
||||
rawOLX: `<problem>
|
||||
<numericalresponse answer="9.3*10^7" partial_credit="close">
|
||||
<label>How many miles away from Earth is the sun?</label>
|
||||
<description>Use scientific notation to answer.</description>
|
||||
<formulaequationinput/>
|
||||
<responseparam type="tolerance" default="1%" partial_range="3"/>
|
||||
</numericalresponse>
|
||||
</problem>`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user