feat: remove matlab api widget and refs (#331)
This commit is contained in:
@@ -69,11 +69,6 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget for Advanced
|
||||
>
|
||||
<TimerCard />
|
||||
</div>
|
||||
<div
|
||||
className="my-3"
|
||||
>
|
||||
<MatlabCard />
|
||||
</div>
|
||||
<div
|
||||
className="my-3"
|
||||
>
|
||||
@@ -155,11 +150,6 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget page 1`] = `
|
||||
>
|
||||
<TimerCard />
|
||||
</div>
|
||||
<div
|
||||
className="my-3"
|
||||
>
|
||||
<MatlabCard />
|
||||
</div>
|
||||
<div
|
||||
className="my-3"
|
||||
>
|
||||
@@ -241,11 +231,6 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget page advanced
|
||||
>
|
||||
<TimerCard />
|
||||
</div>
|
||||
<div
|
||||
className="my-3"
|
||||
>
|
||||
<MatlabCard />
|
||||
</div>
|
||||
<div
|
||||
className="my-3"
|
||||
>
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 = ({
|
||||
<div className="my-3">
|
||||
<TimerCard timeBetween={settings.timeBetween} updateSettings={updateSettings} />
|
||||
</div>
|
||||
<div className="my-3">
|
||||
<MatlabCard matLabApiKey={settings.matLabApiKey} updateSettings={updateSettings} />
|
||||
</div>
|
||||
<div className="my-3">
|
||||
<SwitchToAdvancedEditorCard problemType={problemType} />
|
||||
</div>
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 (
|
||||
<SettingsOption
|
||||
title={intl.formatMessage(messages.matlabSettingTitle)}
|
||||
summary={summary.intl ? intl.formatMessage(summary.message, { ...summary.values }) : summary.message}
|
||||
none={!matLabApiKey}
|
||||
>
|
||||
<div className="halfSpacedMessage">
|
||||
<span>
|
||||
<FormattedMessage {...messages.matlabSettingText1} />
|
||||
</span>
|
||||
</div>
|
||||
<div className="spacedMessage">
|
||||
<span>
|
||||
<FormattedMessage {...messages.matlabSettingText2} />
|
||||
<MailtoLink to="moocsupport@mathworks.com">
|
||||
moocsupport@mathworks.com
|
||||
</MailtoLink>
|
||||
</span>
|
||||
</div>
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
value={matLabApiKey}
|
||||
onChange={handleChange}
|
||||
floatingLabel={intl.formatMessage(messages.matlabInputLabel)}
|
||||
/>
|
||||
</Form.Group>
|
||||
</SettingsOption>
|
||||
);
|
||||
};
|
||||
|
||||
MatlabCard.propTypes = {
|
||||
matLabApiKey: PropTypes.string.isRequired,
|
||||
updateSettings: PropTypes.func.isRequired,
|
||||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
export default injectIntl(MatlabCard);
|
||||
@@ -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(<MatlabCard {...props} />);
|
||||
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(<MatlabCard {...props} />)).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(<MatlabCard {...props} matLabApiKey="" />)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,95 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`MatlabCard snapshot snapshot: renders matlab setting card 1`] = `
|
||||
<SettingsOption
|
||||
className=""
|
||||
extraSections={Array []}
|
||||
hasExpandableTextArea={false}
|
||||
none={false}
|
||||
summary="matlab_api_key"
|
||||
title="MATLAB API Key"
|
||||
>
|
||||
<div
|
||||
className="halfSpacedMessage"
|
||||
>
|
||||
<span>
|
||||
<FormattedMessage
|
||||
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"
|
||||
id="authoring.problemeditor.settings.matlab.text.one"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="spacedMessage"
|
||||
>
|
||||
<span>
|
||||
<FormattedMessage
|
||||
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"
|
||||
id="authoring.problemeditor.settings.matlab.text.two"
|
||||
/>
|
||||
|
||||
<MailtoLink
|
||||
to="moocsupport@mathworks.com"
|
||||
>
|
||||
moocsupport@mathworks.com
|
||||
</MailtoLink>
|
||||
</span>
|
||||
</div>
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
floatingLabel="API Key"
|
||||
onChange={[MockFunction matlabCardHooks.handleChange]}
|
||||
value="matlab_api_key"
|
||||
/>
|
||||
</Form.Group>
|
||||
</SettingsOption>
|
||||
`;
|
||||
|
||||
exports[`MatlabCard snapshot snapshot: renders matlab setting card no key 1`] = `
|
||||
<SettingsOption
|
||||
className=""
|
||||
extraSections={Array []}
|
||||
hasExpandableTextArea={false}
|
||||
none={true}
|
||||
summary="None"
|
||||
title="MATLAB API Key"
|
||||
>
|
||||
<div
|
||||
className="halfSpacedMessage"
|
||||
>
|
||||
<span>
|
||||
<FormattedMessage
|
||||
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"
|
||||
id="authoring.problemeditor.settings.matlab.text.one"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="spacedMessage"
|
||||
>
|
||||
<span>
|
||||
<FormattedMessage
|
||||
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"
|
||||
id="authoring.problemeditor.settings.matlab.text.two"
|
||||
/>
|
||||
|
||||
<MailtoLink
|
||||
to="moocsupport@mathworks.com"
|
||||
>
|
||||
moocsupport@mathworks.com
|
||||
</MailtoLink>
|
||||
</span>
|
||||
</div>
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
floatingLabel="API Key"
|
||||
onChange={[MockFunction matlabCardHooks.handleChange]}
|
||||
value=""
|
||||
/>
|
||||
</Form.Group>
|
||||
</SettingsOption>
|
||||
`;
|
||||
@@ -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);
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -27,7 +27,6 @@ const initialState = {
|
||||
},
|
||||
hints: [],
|
||||
timeBetween: 0,
|
||||
matLabApiKey: '',
|
||||
showAnswer: {
|
||||
on: ShowAnswerTypesKeys.FINISHED,
|
||||
afterAttempts: 0,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user