as they often are both valid olx as siblings or children of response
+ type tags. */
tag[tagName].forEach(subTag => {
const subTagName = Object.keys(subTag)[0];
- if (subTagName === 'label' || subTagName === 'description' || richTextFormats.includes(subTagName)) {
+ if (!nonQuestionKeys.includes(subTagName)) {
questionArray.push(subTag);
}
});
@@ -544,6 +533,12 @@ export class OLXParser {
solutionArray.push(tag);
}
});
+ } else {
+ solutionBody.solution.forEach(tag => {
+ if (_.get(Object.values(tag)[0][0], '#text', null) !== 'Explanation') {
+ solutionArray.push(tag);
+ }
+ });
}
const solutionString = this.richTextBuilder.build(solutionArray);
return solutionString;
diff --git a/src/editors/containers/ProblemEditor/data/OLXParser.test.js b/src/editors/containers/ProblemEditor/data/OLXParser.test.js
index d3922330a..49eedeaef 100644
--- a/src/editors/containers/ProblemEditor/data/OLXParser.test.js
+++ b/src/editors/containers/ProblemEditor/data/OLXParser.test.js
@@ -21,6 +21,8 @@ import {
htmlEntityTestOLX,
numberParseTestOLX,
solutionExplanationTest,
+ solutionExplanationWithoutDivTest,
+ tablesInRichTextTest,
} from './mockData/olxTestData';
import { ProblemTypeKeys } from '../../../data/constants/problem';
@@ -294,6 +296,14 @@ describe('OLXParser', () => {
expect(question.trim()).toBe(labelDescriptionQuestionOLX.question);
});
});
+ describe('given olx with table tags', () => {
+ const olxparser = new OLXParser(tablesInRichTextTest.rawOLX);
+ const problemType = olxparser.getProblemType();
+ const question = olxparser.parseQuestions(problemType);
+ it('should append the table to the question', () => {
+ expect(question.trim()).toBe(tablesInRichTextTest.question);
+ });
+ });
});
describe('getSolutionExplanation()', () => {
describe('for checkbox questions', () => {
@@ -311,5 +321,11 @@ describe('OLXParser', () => {
const explanation = olxparser.getSolutionExplanation(problemType);
expect(explanation).toBe(solutionExplanationTest.solutionExplanation);
});
+ it('should parse solution fields without div', () => {
+ const olxparser = new OLXParser(solutionExplanationWithoutDivTest.rawOLX);
+ const problemType = olxparser.getProblemType();
+ const explanation = olxparser.getSolutionExplanation(problemType);
+ expect(explanation).toBe(solutionExplanationWithoutDivTest.solutionExplanation);
+ });
});
});
diff --git a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js
index ae3fd2d58..01983ca88 100644
--- a/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js
+++ b/src/editors/containers/ProblemEditor/data/mockData/olxTestData.js
@@ -539,7 +539,9 @@ export const textInputWithFeedbackAndHintsOLX = {
},
},
},
- question: 'You can use this template as a guide to the simple editor markdown and OLX markup to use for text 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. ',
+ question: `You can use this template as a guide to the simple editor markdown and OLX markup to use for text 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. `,
buildOLX: `
You can use this template as a guide to the simple editor markdown and OLX markup to use for text input with hints and feedback problems. Edit this component to replace this template with your own assessment.
@@ -769,7 +771,9 @@ export const labelDescriptionQuestionOLX = {
`,
question: `
- Watch out, boiling water is hot`,
+
+
+ Watch out, boiling water is hot`,
};
export const htmlEntityTestOLX = {
@@ -804,7 +808,8 @@ export const htmlEntityTestOLX = {
},
],
},
- question: `What is the content of the register x2 after executing the following three lines of instructions?
Address assembly instructions
0x0 addi x1, x0, 1
0x4 slli x2, x1, 4
0x8 sub x1, x2, x1
`,
+ question: `What is the content of the register x2 after executing the following three lines of instructions?
+ Address assembly instructions
0x0 addi x1, x0, 1
0x4 slli x2, x1, 4
0x8 sub x1, x2, x1
`,
solutionExplanation: `Address assembly instructions comment
0x0 addi x1, x0, 1 x1 = 0x1
0x4 slli x2, x1, 4 x2 = x1 << 4 = 0x10
0x8 sub x1, x2, x1 x1 = x2 - x1 = 0x10 - 0x01 = 0xf
`,
};
@@ -880,3 +885,208 @@ export const solutionExplanationTest = {
solutionExplanation: `\n
This loop will iterate 99 times, but the length of q will not be 99 due to indexing with the value 2*i -1. On the last iteration, i = 99, so 2*i - 1 = 2*78 - 1 = 197. This will be the last position filled in q, so the answer is 197.\n `,
};
+
+export const solutionExplanationWithoutDivTest = {
+ rawOLX: `
+
+ Considering a list z=[8,12,2,9,7] and the following for loop:
+
+ for i in z:
+ y=i+1
+ print(y)
+
+
+ Select the correct answer
+
+ 8
+ [9,13,3,10,8]
+ 9
+ 13
+ 3
+
10
+ 8
+
+
+
+
+ How would you adjust your code to get the other results? We encourage you to try different for loops and share them in the discussion forum.
+
+
+ `,
+ solutionExplanation: `
+
+
+ How would you adjust your code to get the other results? We encourage you to try different for loops and share them in the discussion forum.
+ `,
+};
+
+export const tablesInRichTextTest = {
+ rawOLX: `
+
+
+ The table shows the number of protein-coding genes, chromosomes, and bases in a range of eukaryotic species.
+
+
+ Eukaryotic Genomes Comparison
+
+
+ |
+ Species
+ |
+
+ Protein-coding genes
+ |
+
+ Chromosomes
+ |
+
+ Bases
+ |
+
+
+ | Yeast (S. cerevisiae) |
+ ~5,800 |
+ 16 |
+ ~12 Mb |
+
+
+ | Arabidopsis (A. thaliana) |
+ ~27,000 |
+ 5 |
+ ~115 Mb |
+
+
+ | Rice (O. sativa) |
+ ~41,000 |
+ 12 |
+ ~390 Mb |
+
+
+ | Worm (C. elegans) |
+ ~19,000 |
+ 6 |
+ ~100 Mb |
+
+
+ | Fly (D. melanogaster) |
+ ~14,000 |
+ 4 |
+ ~165 Mb |
+
+
+ | Mouse (M. musculus) |
+ ~23,000 |
+ 20 |
+ ~3 Gb |
+
+
+ | Human (H. sapiens) |
+ ~21,000 |
+ 23 |
+ ~3 Gb |
+
+
+
+
+ In which of the following observations does the C-value paradox apply? Select all that apply.
+
+
+
+
+ Rice has a larger genome and more genes than Arabidopsis.
+
+
+
+
+ Humans have a larger genome but fewer genes than Arabidopsis.
+
+
+
+
+ Worms have a smaller genome but more genes than flies.
+
+
+
+
+
+
+ Explanation
+
+
+ Explanation
+
+
+ The C-value paradox states that there is no relation between size of genome and number of genes. In the comparison between rice and Arabidopsis, the size of the rice genome is both larger and contains a greater number of genes than Arabidopsis, so the C-value paradox does not apply here. In the remaining options, the larger genomes have fewer genes.
+
+
+
+
+ `,
+ question: `
+ The table shows the number of protein-coding genes, chromosomes, and bases in a range of eukaryotic species.
+
+
+ Eukaryotic Genomes Comparison
+
+
+ |
+ Species
+ |
+
+ Protein-coding genes
+ |
+
+ Chromosomes
+ |
+
+ Bases
+ |
+
+
+ | Yeast (S. cerevisiae) |
+ ~5,800 |
+ 16 |
+ ~12 Mb |
+
+
+ | Arabidopsis (A. thaliana) |
+ ~27,000 |
+ 5 |
+ ~115 Mb |
+
+
+ | Rice (O. sativa) |
+ ~41,000 |
+ 12 |
+ ~390 Mb |
+
+
+ | Worm (C. elegans) |
+ ~19,000 |
+ 6 |
+ ~100 Mb |
+
+
+ | Fly (D. melanogaster) |
+ ~14,000 |
+ 4 |
+ ~165 Mb |
+
+
+ | Mouse (M. musculus) |
+ ~23,000 |
+ 20 |
+ ~3 Gb |
+
+
+ | Human (H. sapiens) |
+ ~21,000 |
+ 23 |
+ ~3 Gb |
+
+
+
+
+ In which of the following observations does the C-value paradox apply? Select all that apply.
+
`,
+};
diff --git a/src/editors/sharedComponents/ErrorBoundary/index.test.jsx b/src/editors/sharedComponents/ErrorBoundary/index.test.jsx
index 3f16f4249..4c5b8259a 100644
--- a/src/editors/sharedComponents/ErrorBoundary/index.test.jsx
+++ b/src/editors/sharedComponents/ErrorBoundary/index.test.jsx
@@ -11,7 +11,7 @@ jest.mock('@edx/frontend-platform/logging', () => ({
}));
// stubbing this to avoid needing to inject a stubbed intl into an internal component
-jest.mock('./ErrorPage', () => function () {
+jest.mock('./ErrorPage', () => function mockErrorPage() {
return Error Page
;
});
diff --git a/src/editors/sharedComponents/SelectionModal/index.test.jsx b/src/editors/sharedComponents/SelectionModal/index.test.jsx
index f63c51193..45a29f3f8 100644
--- a/src/editors/sharedComponents/SelectionModal/index.test.jsx
+++ b/src/editors/sharedComponents/SelectionModal/index.test.jsx
@@ -79,22 +79,22 @@ const mockUploadErrorAlertFn = jest.fn();
jest.mock('../BaseModal', () => 'BaseModal');
jest.mock('./SearchSort', () => 'SearchSort');
-jest.mock('./Gallery', () => function (componentProps) {
+jest.mock('./Gallery', () => function mockGallery(componentProps) {
mockGalleryFn(componentProps);
return (Gallery
);
});
-jest.mock('../FileInput', () => function (componentProps) {
+jest.mock('../FileInput', () => function mockFileInput(componentProps) {
mockFileInputFn(componentProps);
return (FileInput
);
});
-jest.mock('../ErrorAlerts/ErrorAlert', () => function () {
+jest.mock('../ErrorAlerts/ErrorAlert', () => function mockErrorAlert() {
return ErrorAlert
;
});
-jest.mock('../ErrorAlerts/FetchErrorAlert', () => function (componentProps) {
+jest.mock('../ErrorAlerts/FetchErrorAlert', () => function mockFetchErrorAlert(componentProps) {
mockFetchErrorAlertFn(componentProps);
return (FetchErrorAlert
);
});
-jest.mock('../ErrorAlerts/UploadErrorAlert', () => function (componentProps) {
+jest.mock('../ErrorAlerts/UploadErrorAlert', () => function mockUploadErrorAlert(componentProps) {
mockUploadErrorAlertFn(componentProps);
return (UploadErrorAlert
);
});