From 1d66a9d14dce538320890d1571f9958706b36e51 Mon Sep 17 00:00:00 2001
From: Kristin Aoki <42981026+KristinAoki@users.noreply.github.com>
Date: Wed, 10 May 2023 15:17:16 -0400
Subject: [PATCH] feat: remove matlab api widget and refs (#331)
---
.../__snapshots__/index.test.jsx.snap | 15 ---
.../EditProblemView/SettingsWidget/hooks.js | 21 ----
.../SettingsWidget/hooks.test.js | 29 ------
.../EditProblemView/SettingsWidget/index.jsx | 4 -
.../SettingsWidget/index.test.jsx | 1 -
.../SettingsWidget/messages.js | 25 -----
.../settingsComponents/MatlabCard.jsx | 53 -----------
.../settingsComponents/MatlabCard.test.jsx | 50 ----------
.../__snapshots__/MatlabCard.test.jsx.snap | 95 -------------------
.../data/ReactStateSettingsParser.js | 1 -
.../ProblemEditor/data/SettingsParser.js | 2 -
.../ProblemEditor/data/SettingsParser.test.js | 12 +--
.../data/mockData/problemTestData.js | 6 --
src/editors/data/redux/problem/reducers.js | 1 -
src/editors/data/services/cms/mockApi.js | 2 -
src/editors/data/services/cms/types.js | 1 -
16 files changed, 2 insertions(+), 316 deletions(-)
delete mode 100644 src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/MatlabCard.jsx
delete mode 100644 src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/MatlabCard.test.jsx
delete mode 100644 src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/MatlabCard.test.jsx.snap
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap
index 26d0bb4ec..ea8ae5d6f 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap
@@ -69,11 +69,6 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget for Advanced
>
-
@@ -155,11 +150,6 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget page 1`] = `
>
-
@@ -241,11 +231,6 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget page advanced
>
-
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.js b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.js
index de7fafda4..66ce9c6fd 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.js
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.js
@@ -86,27 +86,6 @@ export const hintsRowHooks = (id, hints, updateSettings) => {
};
};
-export const matlabCardHooks = (matLabApiKey, updateSettings) => {
- const [summary, setSummary] = module.state.summary({ message: '', values: {}, intl: false });
-
- useEffect(() => {
- if (_.isEmpty(matLabApiKey)) {
- setSummary({ message: messages.matlabNoKeySummary, values: {}, intl: true });
- } else {
- setSummary({ message: matLabApiKey, values: {}, intl: false });
- }
- }, [matLabApiKey]);
-
- const handleChange = (event) => {
- updateSettings({ matLabApiKey: event.target.value });
- };
-
- return {
- summary,
- handleChange,
- };
-};
-
export const resetCardHooks = (updateSettings) => {
const setReset = (value) => {
updateSettings({ showResetButton: value });
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.test.js b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.test.js
index 6946bae97..a93ddc294 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.test.js
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.test.js
@@ -125,35 +125,6 @@ describe('Problem settings hooks', () => {
});
});
- describe('Matlab card hooks', () => {
- test('test useEffect triggers set summary', () => {
- const apiKey = 'matlab_api_key';
- hooks.matlabCardHooks(apiKey, updateSettings);
- expect(state.setState[state.keys.summary]).not.toHaveBeenCalled();
- const [cb, prereqs] = useEffect.mock.calls[0];
- expect(prereqs).toStrictEqual([apiKey]);
- cb();
- expect(state.setState[state.keys.summary])
- .toHaveBeenCalledWith({ message: apiKey, values: {}, intl: false });
- });
- test('test useEffect triggers set summary no key', () => {
- hooks.matlabCardHooks('', updateSettings);
- expect(state.setState[state.keys.summary]).not.toHaveBeenCalled();
- const [cb, prereqs] = useEffect.mock.calls[0];
- expect(prereqs).toStrictEqual(['']);
- cb();
- expect(state.setState[state.keys.summary])
- .toHaveBeenCalledWith({ message: messages.matlabNoKeySummary, values: {}, intl: true });
- });
- test('test handleChange', () => {
- const apiKey = 'matlab_api_key';
- const value = 'new_matlab_api_key';
- output = hooks.matlabCardHooks(apiKey, updateSettings);
- output.handleChange({ target: { value } });
- expect(updateSettings).toHaveBeenCalledWith({ matLabApiKey: value });
- });
- });
-
describe('Reset card hooks', () => {
beforeEach(() => {
output = hooks.resetCardHooks(updateSettings);
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx
index 8f51a477e..303a7c757 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx
@@ -10,7 +10,6 @@ import ScoringCard from './settingsComponents/ScoringCard';
import ShowAnswerCard from './settingsComponents/ShowAnswerCard';
import HintsCard from './settingsComponents/HintsCard';
import ResetCard from './settingsComponents/ResetCard';
-import MatlabCard from './settingsComponents/MatlabCard';
import TimerCard from './settingsComponents/TimerCard';
import TypeCard from './settingsComponents/TypeCard';
import ToleranceCard from './settingsComponents/Tolerance';
@@ -125,9 +124,6 @@ export const SettingsWidget = ({
-
-
-
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.test.jsx
index 6cf2b9628..cbdc39bd7 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.test.jsx
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.test.jsx
@@ -13,7 +13,6 @@ jest.mock('./settingsComponents/GeneralFeedback', () => 'GeneralFeedback');
jest.mock('./settingsComponents/GroupFeedback', () => 'GroupFeedback');
jest.mock('./settingsComponents/Randomization', () => 'Randomization');
jest.mock('./settingsComponents/HintsCard', () => 'HintsCard');
-jest.mock('./settingsComponents/MatlabCard', () => 'MatlabCard');
jest.mock('./settingsComponents/ResetCard', () => 'ResetCard');
jest.mock('./settingsComponents/ScoringCard', () => 'ScoringCard');
jest.mock('./settingsComponents/ShowAnswerCard', () => 'ShowAnswerCard');
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/messages.js b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/messages.js
index 4e2c4545d..77b771f6c 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/messages.js
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/messages.js
@@ -47,31 +47,6 @@ const messages = defineMessages({
defaultMessage: '{hint} {count, plural, =0 {} other {(+# more)}}',
description: 'Summary text for hint settings',
},
- matlabSettingTitle: {
- id: 'authoring.problemeditor.settings.matlab.title',
- defaultMessage: 'MATLAB API Key',
- description: 'Matlab settings card title',
- },
- matlabSettingText1: {
- id: 'authoring.problemeditor.settings.matlab.text.one',
- defaultMessage: 'Enter the API key provided by MathWorks for accessing the MATLAB Hosted Service. This key is granted for exclusive use by this course for the specified duration.',
- description: 'Matlab settings card text 1',
- },
- matlabSettingText2: {
- id: 'authoring.problemeditor.settings.matlab.text.two',
- defaultMessage: 'Please do not share the API key with other courses and notify MathWorks immediately if you believe the key is exposed or compromised. To obtain a key for your course, or to report an issue please contact',
- description: 'Matlab settings card text 2',
- },
- matlabInputLabel: {
- id: 'authoring.problemeditor.settings.matlab.inputLabel',
- defaultMessage: 'API Key',
- description: 'Matlab text input label',
- },
- matlabNoKeySummary: {
- id: 'authoring.problemeditor.settings.matlab.noKeySummary',
- defaultMessage: 'None',
- description: 'Matlab no key summary',
- },
resetSettingsTitle: {
id: 'authoring.problemeditor.settings.reset.title',
defaultMessage: 'Show reset option',
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/MatlabCard.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/MatlabCard.jsx
deleted file mode 100644
index 331cab268..000000000
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/MatlabCard.jsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import React from 'react';
-import { injectIntl, FormattedMessage, intlShape } from '@edx/frontend-platform/i18n';
-import { Form, MailtoLink } from '@edx/paragon';
-import PropTypes from 'prop-types';
-import SettingsOption from '../SettingsOption';
-import messages from '../messages';
-import { matlabCardHooks } from '../hooks';
-
-export const MatlabCard = ({
- matLabApiKey,
- updateSettings,
- // inject
- intl,
-}) => {
- const { summary, handleChange } = matlabCardHooks(matLabApiKey, updateSettings);
-
- return (
-
-
-
-
-
-
-
-
-
-
- moocsupport@mathworks.com
-
-
-
-
-
-
-
- );
-};
-
-MatlabCard.propTypes = {
- matLabApiKey: PropTypes.string.isRequired,
- updateSettings: PropTypes.func.isRequired,
- intl: intlShape.isRequired,
-};
-
-export default injectIntl(MatlabCard);
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/MatlabCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/MatlabCard.test.jsx
deleted file mode 100644
index 60b151271..000000000
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/MatlabCard.test.jsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import React from 'react';
-import { shallow } from 'enzyme';
-import { formatMessage } from '../../../../../../../testUtils';
-import { matlabCardHooks } from '../hooks';
-import { MatlabCard } from './MatlabCard';
-import messages from '../messages';
-
-jest.mock('../hooks', () => ({
- matlabCardHooks: jest.fn(),
-}));
-
-describe('MatlabCard', () => {
- const matLabApiKey = 'matlab_api_key';
- const props = {
- matLabApiKey,
- updateSettings: jest.fn().mockName('args.updateSettings'),
- intl: { formatMessage },
- };
-
- describe('behavior', () => {
- it(' calls resetCardHooks when initialized', () => {
- const matlabCardHooksProps = {
- summary: { message: matLabApiKey, values: {}, intl: false },
- handleChange: jest.fn().mockName('matlabCardHooks.handleChange'),
- };
- matlabCardHooks.mockReturnValue(matlabCardHooksProps);
- shallow(
);
- expect(matlabCardHooks).toHaveBeenCalledWith(matLabApiKey, props.updateSettings);
- });
- });
-
- describe('snapshot', () => {
- test('snapshot: renders matlab setting card', () => {
- const matlabCardHooksProps = {
- summary: { message: matLabApiKey, values: {}, intl: false },
- handleChange: jest.fn().mockName('matlabCardHooks.handleChange'),
- };
- matlabCardHooks.mockReturnValue(matlabCardHooksProps);
- expect(shallow(
)).toMatchSnapshot();
- });
- test('snapshot: renders matlab setting card no key', () => {
- const matlabCardHooksProps = {
- summary: { message: messages.matlabNoKeySummary, values: {}, intl: true },
- handleChange: jest.fn().mockName('matlabCardHooks.handleChange'),
- };
- matlabCardHooks.mockReturnValue(matlabCardHooksProps);
- expect(shallow(
)).toMatchSnapshot();
- });
- });
-});
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/MatlabCard.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/MatlabCard.test.jsx.snap
deleted file mode 100644
index f4db5e6b5..000000000
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/MatlabCard.test.jsx.snap
+++ /dev/null
@@ -1,95 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`MatlabCard snapshot snapshot: renders matlab setting card 1`] = `
-
-
-
-
-
-
-
-
-
-
-
- moocsupport@mathworks.com
-
-
-
-
-
-
-
-`;
-
-exports[`MatlabCard snapshot snapshot: renders matlab setting card no key 1`] = `
-
-
-
-
-
-
-
-
-
-
-
- moocsupport@mathworks.com
-
-
-
-
-
-
-
-`;
diff --git a/src/editors/containers/ProblemEditor/data/ReactStateSettingsParser.js b/src/editors/containers/ProblemEditor/data/ReactStateSettingsParser.js
index 05a8f25c7..50046c923 100644
--- a/src/editors/containers/ProblemEditor/data/ReactStateSettingsParser.js
+++ b/src/editors/containers/ProblemEditor/data/ReactStateSettingsParser.js
@@ -9,7 +9,6 @@ class ReactStateSettingsParser {
let settings = {};
const stateSettings = this.problemState.settings;
- settings = popuplateItem(settings, 'matLabApiKey', 'matlab_api_key', stateSettings);
settings = popuplateItem(settings, 'number', 'max_attempts', stateSettings.scoring.attempts);
settings = popuplateItem(settings, 'weight', 'weight', stateSettings.scoring);
settings = popuplateItem(settings, 'on', 'showanswer', stateSettings.showAnswer);
diff --git a/src/editors/containers/ProblemEditor/data/SettingsParser.js b/src/editors/containers/ProblemEditor/data/SettingsParser.js
index 1e7c65464..68af5d47d 100644
--- a/src/editors/containers/ProblemEditor/data/SettingsParser.js
+++ b/src/editors/containers/ProblemEditor/data/SettingsParser.js
@@ -50,8 +50,6 @@ export const parseSettings = (metadata) => {
return settings;
}
- settings = popuplateItem(settings, 'matlab_api_key', 'matLabApiKey', metadata);
-
const scoring = parseScoringSettings(metadata);
if (!_.isEmpty(scoring)) {
settings = { ...settings, scoring };
diff --git a/src/editors/containers/ProblemEditor/data/SettingsParser.test.js b/src/editors/containers/ProblemEditor/data/SettingsParser.test.js
index 110487837..2f01f3f38 100644
--- a/src/editors/containers/ProblemEditor/data/SettingsParser.test.js
+++ b/src/editors/containers/ProblemEditor/data/SettingsParser.test.js
@@ -1,10 +1,10 @@
import { parseScoringSettings, parseSettings, parseShowAnswer } from './SettingsParser';
import {
checklistWithFeebackHints,
- dropdownWithFeedbackHints,
numericWithHints,
textInputWithHints,
- singleSelectWithHints, negativeAttempts,
+ singleSelectWithHints,
+ negativeAttempts,
} from './mockData/problemTestData';
describe('Test Settings to State Parser', () => {
@@ -14,14 +14,6 @@ describe('Test Settings to State Parser', () => {
expect(settings).toStrictEqual(settingsPayload);
});
- test('Test partial fields populated', () => {
- const settings = parseSettings(dropdownWithFeedbackHints.metadata);
- const { hints, ...settingsPayload } = dropdownWithFeedbackHints.state.settings;
- expect(settings).not.toStrictEqual(settingsPayload);
- const { randomization, matLabApiKey, ...settingsPayloadPartial } = settingsPayload;
- expect(settings).toStrictEqual(settingsPayloadPartial);
- });
-
test('Test score settings', () => {
const scoreSettings = parseScoringSettings(checklistWithFeebackHints.metadata);
expect(scoreSettings).toStrictEqual(checklistWithFeebackHints.state.settings.scoring);
diff --git a/src/editors/containers/ProblemEditor/data/mockData/problemTestData.js b/src/editors/containers/ProblemEditor/data/mockData/problemTestData.js
index a110aaa5a..3dba52653 100644
--- a/src/editors/containers/ProblemEditor/data/mockData/problemTestData.js
+++ b/src/editors/containers/ProblemEditor/data/mockData/problemTestData.js
@@ -73,7 +73,6 @@ export const checklistWithFeebackHints = {
},
},
timeBetween: 3,
- matLabApiKey: 'sample_matlab_api_key',
showAnswer: {
on: 'after_attempts',
afterAttempts: 2,
@@ -94,7 +93,6 @@ export const checklistWithFeebackHints = {
{{ (( A B D )) You can specify optional feedback for a combination of answers which appears after the specified set of answers is submitted. }}
{{ (( A B C D )) You can specify optional feedback for one, several, or all answer combinations. }}
`,
- matlab_api_key: 'sample_matlab_api_key',
max_attempts: 5,
show_reset_button: true,
showanswer: 'after_attempts',
@@ -149,7 +147,6 @@ export const dropdownWithFeedbackHints = {
},
},
timeBetween: 3,
- matLabApiKey: '',
showAnswer: {
on: 'after_attempts',
afterAttempts: 2,
@@ -222,7 +219,6 @@ export const numericWithHints = {
},
},
timeBetween: 0,
- matLabApiKey: '',
showAnswer: {
on: 'after_attempts',
afterAttempts: 1,
@@ -293,7 +289,6 @@ export const textInputWithHints = {
},
},
timeBetween: 0,
- matLabApiKey: '',
showAnswer: {
on: '',
afterAttempts: 1,
@@ -365,7 +360,6 @@ export const singleSelectWithHints = {
},
},
timeBetween: 0,
- matLabApiKey: '',
showAnswer: {
on: '',
afterAttempts: 1,
diff --git a/src/editors/data/redux/problem/reducers.js b/src/editors/data/redux/problem/reducers.js
index a313ce10c..8d8cfa317 100644
--- a/src/editors/data/redux/problem/reducers.js
+++ b/src/editors/data/redux/problem/reducers.js
@@ -27,7 +27,6 @@ const initialState = {
},
hints: [],
timeBetween: 0,
- matLabApiKey: '',
showAnswer: {
on: ShowAnswerTypesKeys.FINISHED,
afterAttempts: 0,
diff --git a/src/editors/data/services/cms/mockApi.js b/src/editors/data/services/cms/mockApi.js
index 9b3de20aa..bb407f4e0 100644
--- a/src/editors/data/services/cms/mockApi.js
+++ b/src/editors/data/services/cms/mockApi.js
@@ -47,7 +47,6 @@ export const fetchBlockById = ({ blockId, studioEndpointUrl }) => {
an incorrect answer
]]`,
attempts_before_showanswer_button: 7,
- matlab_api_key: 'sample_matlab_api_key',
max_attempts: 5,
show_reset_button: true,
showanswer: 'after_attempts',
@@ -271,7 +270,6 @@ export const fetchStudioView = ({ blockId, studioEndpointUrl }) => {
an incorrect answer
]]`,
attempts_before_showanswer_button: 7,
- matlab_api_key: 'numerical_input_matlab_api_key',
max_attempts: 5,
rerandomize: 'per_student',
show_reset_button: true,
diff --git a/src/editors/data/services/cms/types.js b/src/editors/data/services/cms/types.js
index 92d7e56fb..c63d87a6c 100644
--- a/src/editors/data/services/cms/types.js
+++ b/src/editors/data/services/cms/types.js
@@ -55,7 +55,6 @@ export const problemDataProps = {
}),
hints: PropTypes.arrayOf(PropTypes.string),
timeBetween: PropTypes.number,
- matLabApiKey: PropTypes.string,
showAnswer: PropTypes.shape({
on: PropTypes.instanceOf(ShowAnswerTypes),
afterAtempts: PropTypes.number,