Skip to content

Commit

Permalink
fix: default setting not updating with updated default settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Alipov committed Sep 11, 2024
1 parent 6255768 commit 3a8485b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ describe('EditProblemView hooks parseState', () => {
const expectedSettings = {
max_attempts: '',
weight: 1,
rerandomize: null,
showanswer: ShowAnswerTypesKeys.AFTER_SOME_NUMBER_OF_ATTEMPTS,
show_reset_button: false,
submission_wait_seconds: 0,
Expand Down Expand Up @@ -327,6 +328,9 @@ describe('EditProblemView hooks parseState', () => {
});
expect(settings).toEqual({
max_attempts: '',
rerandomize: null,
show_reset_button: false,
showanswer: 'after_attempts',
attempts_before_showanswer_button: 0,
submission_wait_seconds: 0,
weight: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class ReactStateSettingsParser {

settings = popuplateItem(settings, 'number', 'max_attempts', stateSettings.scoring.attempts, defaultSettings?.maxAttempts, true);
settings = popuplateItem(settings, 'weight', 'weight', stateSettings.scoring);
settings = popuplateItem(settings, 'on', 'showanswer', stateSettings.showAnswer, defaultSettings?.showanswer);
settings = popuplateItem(settings, 'on', 'showanswer', stateSettings.showAnswer, defaultSettings?.showanswer, true);
if (_.includes(numberOfAttemptsChoice, stateSettings.showAnswer.on)) {
settings = popuplateItem(settings, 'afterAttempts', 'attempts_before_showanswer_button', stateSettings.showAnswer);
}
settings = popuplateItem(settings, 'showResetButton', 'show_reset_button', stateSettings, defaultSettings?.showResetButton);
settings = popuplateItem(settings, 'showResetButton', 'show_reset_button', stateSettings, defaultSettings?.showResetButton, true);
settings = popuplateItem(settings, 'timeBetween', 'submission_wait_seconds', stateSettings);
settings = popuplateItem(settings, 'randomization', 'rerandomize', stateSettings, defaultSettings?.rerandomize);
settings = popuplateItem(settings, 'randomization', 'rerandomize', stateSettings, defaultSettings?.rerandomize, true);

return settings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const checklistWithFeebackHints = {
show_reset_button: true,
showanswer: 'after_attempts',
attempts_before_showanswer_button: 2,
rerandomize: null,
submission_wait_seconds: 3,
weight: 2.5,
},
Expand Down Expand Up @@ -169,6 +170,7 @@ export const dropdownWithFeedbackHints = {
show_reset_button: true,
showanswer: 'after_attempts',
attempts_before_showanswer_button: 2,
rerandomize: null,
submission_wait_seconds: 3,
weight: 2.5,
},
Expand Down

0 comments on commit 3a8485b

Please sign in to comment.