Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "repeat until correct" option #147

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/features/quiz/QuizSession/QuizAnswer/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export const recordAnswerLogic = createLogic({
const isFinalQuestion = selectIsFinalQuestion(getState());
const { isCorrect } = selectAnswer(getState());
const previouslyIncorrect = selectCurrentPreviouslyIncorrect(getState());
const { repeatUntilCorrect } = selectUserSettings(getState());
stopAutoAdvance();

// only add to correct/incorrect totals on first attempt
Expand All @@ -316,7 +317,7 @@ export const recordAnswerLogic = createLogic({
setTimeout(() => history.push(`/${category}`), 1000);
}
dispatch(quiz.session.current.replace());
} else {
} else if (!repeatUntilCorrect) {
dispatch(quiz.session.current.rotate());
}

Expand Down Expand Up @@ -391,7 +392,9 @@ export const autoAdvanceLogic = createLogic({
type: quiz.question.advance,
warnTimeout: 11000,
process({ getState }, dispatch, done) {
const { autoAdvanceOnSuccessDelayMilliseconds } = selectUserSettings(getState());
const { autoAdvanceOnSuccessDelayMilliseconds, repeatUntilCorrect } = selectUserSettings(
getState()
);
const answerIgnored = selectAnswerIgnored(getState());

if (answerIgnored) {
Expand All @@ -403,7 +406,9 @@ export const autoAdvanceLogic = createLogic({
setTimeout(() => {
dispatch(quiz.answer.reset());
dispatch(quiz.info.reset());
dispatch(quiz.session.current.rotate());
if (!repeatUntilCorrect) {
dispatch(quiz.session.current.rotate());
}
done();
}, msDelay);
} else {
Expand Down
6 changes: 6 additions & 0 deletions app/features/settings/SettingsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export function SettingsForm({ minWk, maxWk, handleSubmit, submitting, submitSuc
normalize={infoLevelNameToNum}
note="Incorrect lessons are always high detail."
/>
<Field
name="repeatUntilCorrect"
label="Repeat quiz question until correct:"
component={ToggleField}
parse={Boolean}
/>
<SubSection>
<H4>Auto Advance</H4>
<Field
Expand Down
4 changes: 3 additions & 1 deletion app/features/user/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const selectUserSettings = createSelector(
'autoExpandAnswerOnFailure',
'infoDetailLevelOnSuccess',
'infoDetailLevelOnFailure',
'repeatUntilCorrect',
'autoAdvanceOnSuccess',
'autoAdvanceOnSuccessDelayMilliseconds',
'followMe',
Expand Down Expand Up @@ -75,7 +76,8 @@ export const selectFreshUser = createSelector(
selectReviewsCount,
getBy(['entities', 'reviews'], (x = {}) => Object.keys(x).length),
],
(nextReviewDate, lessonsCount, reviewsCount, reviewEntitiesCount) => !nextReviewDate && lessonsCount && !reviewsCount && !reviewEntitiesCount
(nextReviewDate, lessonsCount, reviewsCount, reviewEntitiesCount) =>
!nextReviewDate && lessonsCount && !reviewsCount && !reviewEntitiesCount
);

export const selectLastWkSyncDate = createSelector(
Expand Down