Skip to content

Commit

Permalink
feat: add conditional for new parser beta testing (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Jul 26, 2024
1 parent ebab15f commit 3dfc579
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const onSelect = ({
attempts_before_showanswer_button: 0,
show_reset_button: null,
showanswer: null,
defaultToAdvanced: false,
},
defaultSettings: snakeCaseKeys(defaultSettings),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('SelectTypeModal hooks', () => {
attempts_before_showanswer_button: 0,
show_reset_button: null,
showanswer: null,
defaultToAdvanced: false,
},
defaultSettings: mockDefaultSettings,
});
Expand Down
9 changes: 9 additions & 0 deletions src/editors/containers/ProblemEditor/data/OLXParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
7 changes: 6 additions & 1 deletion src/editors/data/redux/thunkActions/problem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3dfc579

Please sign in to comment.