feat: add conditional for new parser beta testing (#496)
This commit is contained in:
@@ -37,6 +37,7 @@ export const onSelect = ({
|
||||
attempts_before_showanswer_button: 0,
|
||||
show_reset_button: null,
|
||||
showanswer: null,
|
||||
defaultToAdvanced: false,
|
||||
},
|
||||
defaultSettings: snakeCaseKeys(defaultSettings),
|
||||
});
|
||||
|
||||
@@ -78,6 +78,7 @@ describe('SelectTypeModal hooks', () => {
|
||||
attempts_before_showanswer_button: 0,
|
||||
show_reset_button: null,
|
||||
showanswer: null,
|
||||
defaultToAdvanced: false,
|
||||
},
|
||||
defaultSettings: mockDefaultSettings,
|
||||
});
|
||||
|
||||
@@ -738,4 +738,13 @@ export class OLXParser {
|
||||
groupFeedbackList,
|
||||
};
|
||||
}
|
||||
|
||||
getBetaParsedOLXData() {
|
||||
/* TODO: Replace olxParser.getParsedOLXData() with new parser function
|
||||
* and remove console.log()
|
||||
*/
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Should default to the advanced editor');
|
||||
return this.getParsedOLXData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,14 @@ export const isBlankProblem = ({ rawOLX }) => {
|
||||
export const getDataFromOlx = ({ rawOLX, rawSettings, defaultSettings }) => {
|
||||
let olxParser;
|
||||
let parsedProblem;
|
||||
const { default_to_advanced: defaultToAdvanced } = rawSettings;
|
||||
try {
|
||||
olxParser = new OLXParser(rawOLX);
|
||||
parsedProblem = olxParser.getParsedOLXData();
|
||||
if (defaultToAdvanced) {
|
||||
parsedProblem = olxParser.getBetaParsedOLXData();
|
||||
} else {
|
||||
parsedProblem = olxParser.getParsedOLXData();
|
||||
}
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The Problem Could Not Be Parsed from OLX. redirecting to Advanced editor.', error);
|
||||
|
||||
Reference in New Issue
Block a user