fix: correct question parsing/building after use of styling. TNL-10413.

This commit is contained in:
Ken Clary
2023-02-02 12:43:54 -05:00
parent 74b2b76beb
commit ea6c2c6658
3 changed files with 27 additions and 1 deletions

View File

@@ -274,7 +274,10 @@ export class OLXParser {
}
parseQuestions(problemType) {
const builder = new XMLBuilder();
const options = {
ignoreAttributes: false,
};
const builder = new XMLBuilder(options);
const problemObject = _.get(this.problem, problemType);
let questionObject = {};
/* TODO: How do we uniquely identify the label and description?

View File

@@ -12,6 +12,7 @@ import {
multipleProblemOlX,
blankProblemOLX,
blankQuestionOLX,
styledQuestionOLX,
} from './mockData/olxTestData';
import { ProblemTypeKeys } from '../../../data/constants/problem';
@@ -161,6 +162,12 @@ describe('Check OLXParser for question parsing', () => {
const question = olxparser.parseQuestions(problemType);
expect(question).toBe(blankQuestionOLX.question);
});
test('Test OLX question content with styling should parse/build with correct styling', () => {
const olxparser = new OLXParser(styledQuestionOLX.rawOLX);
const problemType = olxparser.getProblemType();
const question = olxparser.parseQuestions(problemType);
expect(question).toBe(styledQuestionOLX.question);
});
});
describe('OLXParser for problem with solution tag', () => {

View File

@@ -613,3 +613,19 @@ export const blankQuestionOLX = {
</problem>`,
question: '',
};
export const styledQuestionOLX = {
rawOLX: `<problem>
<p>
<strong>
<span style="background-color: #e03e2d;">
test
</span>
</strong>
</p>
<stringresponse type="ci">
<additional_answer />
<textline size="20"/>
</stringresponse>
</problem>`,
question: '<p><strong><span style="background-color: #e03e2d;">test</span></strong></p>',
};