Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add conditional for new parser beta testing #496

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
groupFeedbackList,
};
}

getBetaParsedOLXData() {

Check warning on line 742 in src/editors/containers/ProblemEditor/data/OLXParser.js

View check run for this annotation

Codecov / codecov/patch

src/editors/containers/ProblemEditor/data/OLXParser.js#L742

Added line #L742 was not covered by tests
/* 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();

Check warning on line 748 in src/editors/containers/ProblemEditor/data/OLXParser.js

View check run for this annotation

Codecov / codecov/patch

src/editors/containers/ProblemEditor/data/OLXParser.js#L747-L748

Added lines #L747 - L748 were not covered by tests
}
}
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 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();

Check warning on line 35 in src/editors/data/redux/thunkActions/problem.js

View check run for this annotation

Codecov / codecov/patch

src/editors/data/redux/thunkActions/problem.js#L35

Added line #L35 was not covered by tests
} 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
Loading