fix: multiple non-numeric problems of the same type should also route to the advanced editor. TNL-10401.
This commit is contained in:
@@ -330,8 +330,8 @@ export class OLXParser {
|
||||
|
||||
getProblemType() {
|
||||
const problemKeys = Object.keys(this.problem);
|
||||
const intersectedProblems = _.intersection(Object.values(ProblemTypeKeys), problemKeys);
|
||||
if (intersectedProblems.length === 0) {
|
||||
const problemTypeKeys = problemKeys.filter(key => Object.values(ProblemTypeKeys).indexOf(key) !== -1);
|
||||
if (problemTypeKeys.length === 0) {
|
||||
// a blank problem is a problem which contains only `<problem></problem>` as it's olx.
|
||||
// blank problems are not given types, so that a type may be selected.
|
||||
if (problemKeys.length === 1 && problemKeys[0] === '#text' && this.problem[problemKeys[0]] === '') {
|
||||
@@ -341,10 +341,14 @@ export class OLXParser {
|
||||
return ProblemTypeKeys.ADVANCED;
|
||||
}
|
||||
// make sure compound problems are treated as advanced
|
||||
if (intersectedProblems.length > 1) {
|
||||
// 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]])
|
||||
&& this.problem[problemTypeKeys[0]].length > 1)) {
|
||||
return ProblemTypeKeys.ADVANCED;
|
||||
}
|
||||
const problemType = intersectedProblems[0];
|
||||
const problemType = problemTypeKeys[0];
|
||||
return problemType;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
mutlipleChoiceWithFeedbackAndHintsOLX,
|
||||
textInputWithFeedbackAndHintsOLXWithMultipleAnswers,
|
||||
advancedProblemOlX,
|
||||
multipleProblemOlX,
|
||||
blankProblemOLX,
|
||||
} from './mockData/olxTestData';
|
||||
import { ProblemTypeKeys } from '../../../data/constants/problem';
|
||||
@@ -43,6 +44,11 @@ describe('Check OLXParser problem type', () => {
|
||||
const problemType = olxparser.getProblemType();
|
||||
expect(problemType).toBe(ProblemTypeKeys.ADVANCED);
|
||||
});
|
||||
test('Test Advanced Problem Type by multiples', () => {
|
||||
const olxparser = new OLXParser(multipleProblemOlX.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();
|
||||
|
||||
@@ -564,6 +564,16 @@ export const advancedProblemOlX = {
|
||||
</formularesponse>
|
||||
</problem>`,
|
||||
};
|
||||
export const multipleProblemOlX = {
|
||||
rawOLX: `<problem>
|
||||
<stringresponse answer="correct answer">
|
||||
<textline size="20"/>
|
||||
</stringresponse>
|
||||
<stringresponse answer="other correct answer">
|
||||
<textline size="20"/>
|
||||
</stringresponse>
|
||||
</problem>`,
|
||||
};
|
||||
export const blankProblemOLX = {
|
||||
rawOLX: '<problem></problem>',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user