diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx index ec229c7fc..037cc4e4d 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx @@ -118,7 +118,11 @@ export const SettingsWidget = ({ { problemType === ProblemTypeKeys.ADVANCED && (
- +
) } @@ -162,6 +166,7 @@ SettingsWidget.propTypes = { maxAttempts: PropTypes.number, showanswer: PropTypes.string, showReseButton: PropTypes.bool, + rerandomize: PropTypes.string, }).isRequired, // eslint-disable-next-line settings: PropTypes.any.isRequired, diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/__snapshots__/index.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/__snapshots__/index.test.jsx.snap index a9a780585..2c8432711 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/__snapshots__/index.test.jsx.snap @@ -1,6 +1,58 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`RandomizationCard snapshot snapshot: renders randonmization setting card with randomization defined 1`] = ` +exports[`RandomizationCard snapshot snapshot: renders randomization setting card with default randomization 1`] = ` + +
+ {randomization, select, + null {No Python based randomization is present in this problem.} + other {Defines when to randomize the variables specified in the associated Python script. For problems that do not randomize values, specify "Never".} + } +
+ + + + + + + + +
+`; + +exports[`RandomizationCard snapshot snapshot: renders randomization setting card with randomization defined 1`] = ` @@ -52,7 +104,7 @@ exports[`RandomizationCard snapshot snapshot: renders randonmization setting car `; -exports[`RandomizationCard snapshot snapshot: renders randonmization setting card with randomization null 1`] = ` +exports[`RandomizationCard snapshot snapshot: renders randomization setting card with randomization null 1`] = ` diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.jsx index 0cb2817e4..f20845ed8 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.jsx @@ -9,11 +9,16 @@ import { RandomizationTypesKeys, RandomizationTypes } from '../../../../../../.. export const RandomizationCard = ({ randomization, + defaultValue, updateSettings, // inject intl, }) => { - const { summary, handleChange } = useRandomizationSettingStatus({ randomization, updateSettings }); + const curretRandomization = randomization || defaultValue; + const { summary, handleChange } = useRandomizationSettingStatus({ + randomization: curretRandomization, + updateSettings, + }); return ( { @@ -48,6 +53,7 @@ export const RandomizationCard = ({ }; RandomizationCard.propTypes = { + defaultValue: PropTypes.string.isRequired, randomization: PropTypes.string.isRequired, updateSettings: PropTypes.func.isRequired, intl: intlShape.isRequired, diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.jsx index b4a062a48..c47799848 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.jsx @@ -11,6 +11,7 @@ jest.mock('./hooks', () => ({ describe('RandomizationCard', () => { const props = { randomization: 'sOmE_vAlUE', + defaultValue: 'default_vAlUE', updateSettings: jest.fn().mockName('args.updateSettings'), intl: { formatMessage }, }; @@ -32,11 +33,14 @@ describe('RandomizationCard', () => { }); describe('snapshot', () => { - test('snapshot: renders randonmization setting card with randomization defined', () => { + test('snapshot: renders randomization setting card with randomization defined', () => { expect(shallow()).toMatchSnapshot(); }); - test('snapshot: renders randonmization setting card with randomization null', () => { + test('snapshot: renders randomization setting card with default randomization', () => { expect(shallow()).toMatchSnapshot(); }); + test('snapshot: renders randomization setting card with randomization null', () => { + expect(shallow()).toMatchSnapshot(); + }); }); }); diff --git a/src/editors/data/constants/problem.js b/src/editors/data/constants/problem.js index 1f0c378ae..5dcc8558c 100644 --- a/src/editors/data/constants/problem.js +++ b/src/editors/data/constants/problem.js @@ -193,7 +193,7 @@ export const ShowAnswerTypes = StrictDict({ export const RandomizationTypesKeys = StrictDict({ NEVER: 'never', ALWAYS: 'always', - ONRESET: 'on_reset', + ONRESET: 'onreset', PERSTUDENT: 'per_student', }); diff --git a/src/editors/data/redux/thunkActions/problem.js b/src/editors/data/redux/thunkActions/problem.js index 4ed432660..9edf656b5 100644 --- a/src/editors/data/redux/thunkActions/problem.js +++ b/src/editors/data/redux/thunkActions/problem.js @@ -32,6 +32,7 @@ export const getDataFromOlx = ({ rawOLX, rawSettings, defaultSettings }) => { olxParser = new OLXParser(rawOLX); 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); return { problemType: ProblemTypeKeys.ADVANCED, rawOLX, settings: parseSettings(rawSettings, defaultSettings) }; } @@ -55,7 +56,7 @@ export const loadProblem = ({ rawOLX, rawSettings, defaultSettings }) => (dispat }; export const fetchAdvancedSettings = ({ rawOLX, rawSettings }) => (dispatch) => { - const advancedProblemSettingKeys = ['max_attempts', 'showanswer', 'show_reset_button']; + const advancedProblemSettingKeys = ['max_attempts', 'showanswer', 'show_reset_button', 'rerandomize']; dispatch(requests.fetchAdvancedSettings({ onSuccess: (response) => { const defaultSettings = {}; diff --git a/src/editors/data/redux/thunkActions/video.js b/src/editors/data/redux/thunkActions/video.js index e3524e9f0..cc5b0797c 100644 --- a/src/editors/data/redux/thunkActions/video.js +++ b/src/editors/data/redux/thunkActions/video.js @@ -50,6 +50,7 @@ export const loadVideoData = (selectedVideoId, selectedVideoUrl) => (dispatch, g // Use the selected video url first const videoSourceUrl = selectedVideoUrl != null ? selectedVideoUrl : videoUrl; const [licenseType, licenseOptions] = module.parseLicense({ licenseData: studioView, level: 'block' }); + // eslint-disable-next-line no-console console.log(licenseType); const transcripts = rawVideoData.transcriptsFromSelected ? rawVideoData.transcriptsFromSelected : module.parseTranscripts({ transcriptsData: studioView }); @@ -168,6 +169,7 @@ export const parseTranscripts = ({ transcriptsData }) => { return Object.keys(transcriptsObj.value); } catch (error) { if (error instanceof SyntaxError) { + // eslint-disable-next-line no-console console.error('Invalid JSON:', error.message); } else { throw error; @@ -265,6 +267,7 @@ export const uploadThumbnail = ({ thumbnail, emptyCanvas }) => (dispatch, getSta })); } }, + // eslint-disable-next-line no-console onFailure: (e) => console.log({ UploadFailure: e }, 'Resampling thumbnail upload'), })); }; @@ -404,6 +407,7 @@ export const uploadVideo = ({ supportedFiles, setLoadSpinner, postUploadRedirect const uploadUrl = fileObj.upload_url; const uploadFile = supportedFiles.find((file) => file.get('file').name === fileName); if (!uploadFile) { + // eslint-disable-next-line no-console console.error(`Could not find file object with name "${fileName}" in supportedFiles array.`); return; } @@ -417,6 +421,7 @@ export const uploadVideo = ({ supportedFiles, setLoadSpinner, postUploadRedirect }, }) .then(() => postUploadRedirect(edxVideoId)) + // eslint-disable-next-line no-console .catch((error) => console.error('Error uploading file:', error)); })); setLoadSpinner(false); diff --git a/src/editors/data/services/cms/types.js b/src/editors/data/services/cms/types.js index c63d87a6c..f35ec2441 100644 --- a/src/editors/data/services/cms/types.js +++ b/src/editors/data/services/cms/types.js @@ -64,6 +64,7 @@ export const problemDataProps = { max_attempts: PropTypes.number, showanswer: PropTypes.string, show_reset_button: PropTypes.bool, + rerandomize: PropTypes.string, }), }), };