Skip to content

Commit

Permalink
chore: rename grading strategy -> grading method
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanttV committed Feb 19, 2024
1 parent f61d254 commit 39ebc84
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ export const scoringCardHooks = (scoring, updateSettings, defaultValue) => {
updateSettings({ scoring: { ...scoring, weight } });
};

const handleGradingStrategyChange = (event) => {
const handleGradingMethodChange = (event) => {
const { value } = event.target;
updateSettings({ scoring: { ...scoring, gradingStrategy: value } });
updateSettings({ scoring: { ...scoring, gradingMethod: value } });
};

return {
Expand All @@ -177,7 +177,7 @@ export const scoringCardHooks = (scoring, updateSettings, defaultValue) => {
handleMaxAttemptChange,
handleOnChange,
handleWeightChange,
handleGradingStrategyChange,
handleGradingMethodChange,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('Problem settings hooks', () => {
unlimited: false,
number: 5,
},
gradingStrategy: 'last_score',
gradingMethod: 'last_score',
};
const defaultValue = 1;
test('test scoringCardHooks initializes display value when attempts.number is null', () => {
Expand Down Expand Up @@ -269,10 +269,10 @@ describe('Problem settings hooks', () => {
output.handleWeightChange({ target: { value } });
expect(updateSettings).toHaveBeenCalledWith({ scoring: { ...scoring, weight: parseFloat(value) } });
});
test('test handleGradingStrategyChange', () => {
test('test handleGradingMethodChange', () => {
const value = 'first_score';
output.handleGradingStrategyChange({ target: { value } });
expect(updateSettings).toHaveBeenCalledWith({ scoring: { ...scoring, gradingStrategy: value } });
output.handleGradingMethodChange({ target: { value } });
expect(updateSettings).toHaveBeenCalledWith({ scoring: { ...scoring, gradingMethod: value } });
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ SettingsWidget.propTypes = {
showanswer: PropTypes.string,
showResetButton: PropTypes.bool,
rerandomize: PropTypes.string,
gradingStrategy: PropTypes.string,
gradingMethod: PropTypes.string,
}).isRequired,
// eslint-disable-next-line
settings: PropTypes.any.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('SettingsWidget', () => {
maxAttempts: 2,
showanswer: 'finished',
showResetButton: false,
gradingStrategy: 'last_score',
gradingMethod: 'last_score',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ const messages = defineMessages({
defaultMessage: 'Points',
description: 'Scoring weight input label',
},
scoringGradingStrategyInputLabel: {
id: 'authoring.problemeditor.settings.scoring.gradingStrategy.inputLabel',
defaultMessage: 'Grading Strategy',
description: 'Grading strategy input label',
scoringGradingMethodInputLabel: {
id: 'authoring.problemeditor.settings.scoring.gradingMethod.inputLabel',
defaultMessage: 'Grading Method',
description: 'Grading method input label',
},
gradingStrategySummary: {
id: 'authoring.problemeditor.settings.scoring.gradingStrategy',
defaultMessage: '{gradingStrategy}',
description: 'Summary text for scoring grading strategy',
gradingMethodSummary: {
id: 'authoring.problemeditor.settings.scoring.gradingMethod',
defaultMessage: '{gradingMethod}',
description: 'Summary text for scoring grading method',
},
unlimitedAttemptsSummary: {
id: 'authoring.problemeditor.settings.scoring.unlimited',
Expand All @@ -114,7 +114,7 @@ const messages = defineMessages({
},
scoringSettingsLabel: {
id: 'authoring.problemeditor.settings.scoring.label',
defaultMessage: 'Specify grading strategy, point weight and the number of answer attempts',
defaultMessage: 'Specify grading method, point weight and the number of answer attempts',
description: 'Descriptive text for scoring settings',
},
attemptsHint: {
Expand All @@ -127,10 +127,10 @@ const messages = defineMessages({
defaultMessage: 'If a value is not set, the problem is worth one point',
description: 'Summary text for scoring weight',
},
gradingStrategyHint: {
id: 'authoring.problemeditor.settings.scoring.gradingStrategy.hint',
defaultMessage: 'Define the grading strategy for this problem. By default, it is the score of the last submission made by the student.',
description: 'Summary text for scoring grading strategy',
gradingMethodHint: {
id: 'authoring.problemeditor.settings.scoring.gradingMethod.hint',
defaultMessage: 'Define the grading method for this problem. By default, it is the score of the last submission made by the student.',
description: 'Summary text for scoring grading method',
},
showAnswerSettingsTitle: {
id: 'authoring.problemeditor.settings.showAnswer.title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { selectors } from '../../../../../../data/redux';
import SettingsOption from '../SettingsOption';
import messages from '../messages';
import { scoringCardHooks } from '../hooks';
import { GradingStrategy, GradingStrategyKeys } from '../../../../../../data/constants/problem';
import { GradingMethod, GradingMethodKeys } from '../../../../../../data/constants/problem';

export const ScoringCard = ({
scoring,
Expand All @@ -25,20 +25,20 @@ export const ScoringCard = ({
handleUnlimitedChange,
handleMaxAttemptChange,
handleWeightChange,
handleGradingStrategyChange,
handleGradingMethodChange,
handleOnChange,
attemptDisplayValue,
} = scoringCardHooks(scoring, updateSettings, defaultValue);

const getScoringSummary = (weight, attempts, unlimited, gradingStrategy) => {
const getScoringSummary = (weight, attempts, unlimited, gradingMethod) => {
let summary = intl.formatMessage(messages.weightSummary, { weight });
summary += ` ${String.fromCharCode(183)} `;
summary += unlimited
? intl.formatMessage(messages.unlimitedAttemptsSummary)
: intl.formatMessage(messages.attemptsSummary, { attempts: attempts || defaultValue });
summary += ` ${String.fromCharCode(183)} `;
summary += intl.formatMessage(messages.gradingStrategySummary, {
gradingStrategy: intl.formatMessage(GradingStrategy[gradingStrategy]),
summary += intl.formatMessage(messages.gradingMethodSummary, {
gradingMethod: intl.formatMessage(GradingMethod[gradingMethod]),
});
return summary;
};
Expand All @@ -51,7 +51,7 @@ export const ScoringCard = ({
scoring.weight,
scoring.attempts.number,
scoring.attempts.unlimited,
scoring.gradingStrategy,
scoring.gradingMethod,
)
}
className="scoringCard"
Expand All @@ -62,24 +62,24 @@ export const ScoringCard = ({
<Form.Group>
<Form.Control
as="select"
value={scoring.gradingStrategy}
onChange={handleGradingStrategyChange}
floatingLabel={intl.formatMessage(messages.scoringGradingStrategyInputLabel)}
value={scoring.gradingMethod}
onChange={handleGradingMethodChange}
floatingLabel={intl.formatMessage(messages.scoringGradingMethodInputLabel)}
>
{Object.values(GradingStrategyKeys).map((gradingStrategy) => {
const optionDisplayName = GradingStrategy[gradingStrategy];
{Object.values(GradingMethodKeys).map((gradingMethod) => {
const optionDisplayName = GradingMethod[gradingMethod];
return (
<option
key={gradingStrategy}
value={gradingStrategy}
key={gradingMethod}
value={gradingMethod}
>
{intl.formatMessage(optionDisplayName)}
</option>
);
})}
</Form.Control>
<Form.Control.Feedback>
<FormattedMessage {...messages.gradingStrategyHint} />
<FormattedMessage {...messages.gradingMethodHint} />
</Form.Control.Feedback>
</Form.Group>
<Form.Group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('ScoringCard', () => {
unlimited: false,
number: 5,
},
gradingStrategy: 'last_score',
gradingMethod: 'last_score',
updateSettings: jest.fn().mockName('args.updateSettings'),
intl: { formatMessage },
};
Expand All @@ -30,7 +30,7 @@ describe('ScoringCard', () => {
handleMaxAttemptChange: jest.fn().mockName('scoringCardHooks.handleMaxAttemptChange'),
handleWeightChange: jest.fn().mockName('scoringCardHooks.handleWeightChange'),
handleOnChange: jest.fn().mockName('scoringCardHooks.handleOnChange'),
handleGradingStrategyChange: jest.fn().mockName('scoringCardHooks.handleGradingStrategyChange'),
handleGradingMethodChange: jest.fn().mockName('scoringCardHooks.handleGradingMethodChange'),
local: 5,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ exports[`ScoringCard snapshot snapshot: scoring setting card 1`] = `
className="mb-4"
>
<FormattedMessage
defaultMessage="Specify grading strategy, point weight and the number of answer attempts"
defaultMessage="Specify grading method, point weight and the number of answer attempts"
description="Descriptive text for scoring settings"
id="authoring.problemeditor.settings.scoring.label"
/>
</div>
<Form.Group>
<Form.Control
as="select"
floatingLabel="Grading Strategy"
onChange={[MockFunction scoringCardHooks.handleGradingStrategyChange]}
floatingLabel="Grading Method"
onChange={[MockFunction scoringCardHooks.handleGradingMethodChange]}
value="last_score"
>
<option
Expand Down Expand Up @@ -51,9 +51,9 @@ exports[`ScoringCard snapshot snapshot: scoring setting card 1`] = `
</Form.Control>
<Form.Control.Feedback>
<FormattedMessage
defaultMessage="Define the grading strategy for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading strategy"
id="authoring.problemeditor.settings.scoring.gradingStrategy.hint"
defaultMessage="Define the grading method for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading method"
id="authoring.problemeditor.settings.scoring.gradingMethod.hint"
/>
</Form.Control.Feedback>
</Form.Group>
Expand Down Expand Up @@ -127,16 +127,16 @@ exports[`ScoringCard snapshot snapshot: scoring setting card max attempts 1`] =
className="mb-4"
>
<FormattedMessage
defaultMessage="Specify grading strategy, point weight and the number of answer attempts"
defaultMessage="Specify grading method, point weight and the number of answer attempts"
description="Descriptive text for scoring settings"
id="authoring.problemeditor.settings.scoring.label"
/>
</div>
<Form.Group>
<Form.Control
as="select"
floatingLabel="Grading Strategy"
onChange={[MockFunction scoringCardHooks.handleGradingStrategyChange]}
floatingLabel="Grading Method"
onChange={[MockFunction scoringCardHooks.handleGradingMethodChange]}
value="last_score"
>
<option
Expand Down Expand Up @@ -166,9 +166,9 @@ exports[`ScoringCard snapshot snapshot: scoring setting card max attempts 1`] =
</Form.Control>
<Form.Control.Feedback>
<FormattedMessage
defaultMessage="Define the grading strategy for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading strategy"
id="authoring.problemeditor.settings.scoring.gradingStrategy.hint"
defaultMessage="Define the grading method for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading method"
id="authoring.problemeditor.settings.scoring.gradingMethod.hint"
/>
</Form.Control.Feedback>
</Form.Group>
Expand Down Expand Up @@ -242,16 +242,16 @@ exports[`ScoringCard snapshot snapshot: scoring setting card zero zero weight 1`
className="mb-4"
>
<FormattedMessage
defaultMessage="Specify grading strategy, point weight and the number of answer attempts"
defaultMessage="Specify grading method, point weight and the number of answer attempts"
description="Descriptive text for scoring settings"
id="authoring.problemeditor.settings.scoring.label"
/>
</div>
<Form.Group>
<Form.Control
as="select"
floatingLabel="Grading Strategy"
onChange={[MockFunction scoringCardHooks.handleGradingStrategyChange]}
floatingLabel="Grading Method"
onChange={[MockFunction scoringCardHooks.handleGradingMethodChange]}
value="last_score"
>
<option
Expand Down Expand Up @@ -281,9 +281,9 @@ exports[`ScoringCard snapshot snapshot: scoring setting card zero zero weight 1`
</Form.Control>
<Form.Control.Feedback>
<FormattedMessage
defaultMessage="Define the grading strategy for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading strategy"
id="authoring.problemeditor.settings.scoring.gradingStrategy.hint"
defaultMessage="Define the grading method for this problem. By default, it is the score of the last submission made by the student."
description="Summary text for scoring grading method"
id="authoring.problemeditor.settings.scoring.gradingMethod.hint"
/>
</Form.Control.Feedback>
</Form.Group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ReactStateSettingsParser {

settings = popuplateItem(settings, 'number', 'max_attempts', stateSettings.scoring.attempts, true);
settings = popuplateItem(settings, 'weight', 'weight', stateSettings.scoring);
settings = popuplateItem(settings, 'gradingStrategy', 'grading_strategy', stateSettings.scoring);
settings = popuplateItem(settings, 'gradingMethod', 'grading_method', stateSettings.scoring);
settings = popuplateItem(settings, 'on', 'showanswer', stateSettings.showAnswer);
settings = popuplateItem(settings, 'afterAttempts', 'attempts_before_showanswer_button', stateSettings.showAnswer);
settings = popuplateItem(settings, 'showResetButton', 'show_reset_button', stateSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const parseScoringSettings = (metadata, defaultSettings) => {

scoring = popuplateItem(scoring, 'weight', 'weight', metadata);

scoring = popuplateItem(scoring, 'grading_strategy', 'gradingStrategy', metadata);
scoring = popuplateItem(scoring, 'grading_method', 'gradingMethod', metadata);

return scoring;
};
Expand Down
22 changes: 11 additions & 11 deletions src/editors/data/constants/problem.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,28 +216,28 @@ export const RandomizationTypes = StrictDict({
},
});

export const GradingStrategyKeys = StrictDict({
export const GradingMethodKeys = StrictDict({
LAST_SCORE: 'last_score',
HIGHEST_SCORE: 'highest_score',
AVERAGE_SCORE: 'average_score',
FIRST_SCORE: 'first_score',
});

export const GradingStrategy = StrictDict({
[GradingStrategyKeys.LAST_SCORE]: {
id: 'authoring.problemeditor.settings.gradingstrategy.last_score',
export const GradingMethod = StrictDict({
[GradingMethodKeys.LAST_SCORE]: {
id: 'authoring.problemeditor.settings.gradingmethod.last_score',
defaultMessage: 'Last Score',
},
[GradingStrategyKeys.HIGHEST_SCORE]: {
id: 'authoring.problemeditor.settings.gradingstrategy.highest_score',
[GradingMethodKeys.HIGHEST_SCORE]: {
id: 'authoring.problemeditor.settings.gradingmethod.highest_score',
defaultMessage: 'Highest Score',
},
[GradingStrategyKeys.AVERAGE_SCORE]: {
id: 'authoring.problemeditor.settings.gradingstrategy.average_score',
[GradingMethodKeys.AVERAGE_SCORE]: {
id: 'authoring.problemeditor.settings.gradingmethod.average_score',
defaultMessage: 'Average Score',
},
[GradingStrategyKeys.FIRST_SCORE]: {
id: 'authoring.problemeditor.settings.gradingstrategy.first_score',
[GradingMethodKeys.FIRST_SCORE]: {
id: 'authoring.problemeditor.settings.gradingmethod.first_score',
defaultMessage: 'First Score',
},
});
Expand All @@ -252,5 +252,5 @@ export const settingsOlxAttributes = [
'@_show_reset_button',
'@_submission_wait_seconds',
'@_attempts_before_showanswer_button',
'@_grading_strategy',
'@_grading_method',
];
4 changes: 2 additions & 2 deletions src/editors/data/redux/problem/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash-es';
import { createSlice } from '@reduxjs/toolkit';
import { indexToLetterMap } from '../../../containers/ProblemEditor/data/OLXParser';
import { StrictDict } from '../../../utils';
import { GradingStrategyKeys, ProblemTypeKeys, RichTextProblems } from '../../constants/problem';
import { GradingMethodKeys, ProblemTypeKeys, RichTextProblems } from '../../constants/problem';
import { ToleranceTypes } from '../../../containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Tolerance/constants';

const nextAlphaId = (lastId) => String.fromCharCode(lastId.charCodeAt(0) + 1);
Expand All @@ -24,7 +24,7 @@ const initialState = {
unlimited: false,
number: null,
},
gradingStrategy: GradingStrategyKeys.LAST_SCORE,
gradingMethod: GradingMethodKeys.LAST_SCORE,
},
hints: [],
timeBetween: 0,
Expand Down

0 comments on commit 39ebc84

Please sign in to comment.