Skip to content

Commit

Permalink
Feature Show Reminder before answer (ankitects#3064)
Browse files Browse the repository at this point in the history
In the deck config you can choose to show a reminder instead of showing
directly the answer at the end of the autoupdate time.
  • Loading branch information
Loudwig committed Apr 8, 2024
1 parent d24d23c commit 35a513b
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 103 deletions.
33 changes: 0 additions & 33 deletions cargo/format/rustc-ice-2024-04-04T14:23:25.351052Z-1805.txt

This file was deleted.

33 changes: 0 additions & 33 deletions cargo/format/rustc-ice-2024-04-04T14:23:29.652577Z-1942.txt

This file was deleted.

8 changes: 4 additions & 4 deletions ftl/core/deck-config.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ deck-config-answer-hard = Answer Hard
deck-config-answer-good = Answer Good
deck-config-days-to-simulate = Days to simulate
deck-config-desired-retention-below-optimal = Your desired retention is below optimal. Increasing it is recommended.
deck-config-after-question-show-answer = Show answer
deck-config-after-question-show-reminder = Show reminder
deck-config-after-question = After question
deck-config-after-question-tool-tip = The action to perform after the end of the time of the question. Either show answer and auto update or just show a reminder.
deck-config-question-action-show-answer = Show Answer
deck-config-question-action-show-reminder = Show Reminder
deck-config-question-action = Question action
deck-config-question-action-tool-tip = The action to perform after the end of the time of the question. Either show answer and auto update or just show a reminder.
## NO NEED TO TRANSLATE. This text is no longer used by Anki, and will be removed in the future.

deck-config-bury-siblings = Bury siblings
Expand Down
8 changes: 4 additions & 4 deletions proto/anki/deck_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ message DeckConfig {
ANSWER_ACTION_SHOW_REMINDER = 4;
}

enum AfterQuestion{
AFTER_QUESTION_SHOW_ANSWER = 0;
AFTER_QUESTION_SHOW_REMINDER = 1 ;
enum QuestionAction{
QUESTION_ACTION_SHOW_ANSWER = 0;
QUESTION_ACTION_SHOW_REMINDER = 1 ;
}

repeated float learn_steps = 1;
Expand Down Expand Up @@ -145,7 +145,7 @@ message DeckConfig {
bool disable_autoplay = 23;
uint32 cap_answer_time_to_secs = 24;
bool show_timer = 25;
AfterQuestion after_question = 36;
QuestionAction question_action = 36;
bool stop_timer_on_answer = 38;
float seconds_to_show_question = 41;
float seconds_to_show_answer = 42;
Expand Down
8 changes: 4 additions & 4 deletions qt/aqt/reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class AnswerAction(Enum):
ANSWER_HARD = 3
SHOW_REMINDER = 4

class AfterQuestion(Enum):
class QuestionAction(Enum):
SHOW_ANSWER = 0
SHOW_REMINDER = 1

Expand Down Expand Up @@ -428,11 +428,11 @@ def _on_show_answer_timeout(self) -> None:
self.auto_advance_enabled = False
return
try :
after_question = list(AfterQuestion)[conf["afterQuestion"]]
question_action = list(QuestionAction)[conf["questionAction"]]
except IndexError:
after_question = AfterQuestion.SHOW_ANSWER
question_action = QuestionAction.SHOW_ANSWER

if after_question == AfterQuestion.SHOW_ANSWER:
if question_action == QuestionAction.SHOW_ANSWER:
self._showAnswer()
else :
tooltip(tr.studying_question_time_elapsed())
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/deckconfig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub use anki_proto::deck_config::deck_config::config::NewCardInsertOrder;
pub use anki_proto::deck_config::deck_config::config::NewCardSortOrder;
pub use anki_proto::deck_config::deck_config::config::ReviewCardOrder;
pub use anki_proto::deck_config::deck_config::config::ReviewMix;
pub use anki_proto::deck_config::deck_config::config::AfterQuestion;
pub use anki_proto::deck_config::deck_config::config::QuestionAction;
pub use anki_proto::deck_config::deck_config::Config as DeckConfigInner;
pub use schema11::DeckConfSchema11;
pub use schema11::NewCardOrderSchema11;
Expand Down Expand Up @@ -68,7 +68,7 @@ const DEFAULT_DECK_CONFIG_INNER: DeckConfigInner = DeckConfigInner {
seconds_to_show_question: 0.0,
seconds_to_show_answer: 0.0,
answer_action: AnswerAction::BuryCard as i32,
after_question: AfterQuestion::ShowAnswer as i32,
question_action: QuestionAction::ShowAnswer as i32,
wait_for_audio: true,
skip_question_when_replaying_answer: false,
bury_new: false,
Expand Down
16 changes: 8 additions & 8 deletions rslib/src/deckconfig/schema11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct DeckConfSchema11 {
#[serde(default)]
answer_action: AnswerAction,
#[serde(default)]
after_question: AfterQuestion,
question_action: QuestionAction,
#[serde(default = "wait_for_audio_default")]
wait_for_audio: bool,
#[serde(default)]
Expand Down Expand Up @@ -112,7 +112,7 @@ pub enum AnswerAction {
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, Clone)]
#[repr(u8)]
#[derive(Default)]
pub enum AfterQuestion {
pub enum QuestionAction {
#[default]
ShowAnswer = 0,
ShowReminder = 1,
Expand Down Expand Up @@ -290,7 +290,7 @@ impl Default for DeckConfSchema11 {
seconds_to_show_question: 0.0,
seconds_to_show_answer: 0.0,
answer_action: AnswerAction::BuryCard,
after_question: AfterQuestion::ShowAnswer,
question_action: QuestionAction::ShowAnswer,
wait_for_audio: true,
replayq: true,
dynamic: false,
Expand Down Expand Up @@ -377,7 +377,7 @@ impl From<DeckConfSchema11> for DeckConfig {
stop_timer_on_answer: c.stop_timer_on_answer,
seconds_to_show_question: c.seconds_to_show_question,
seconds_to_show_answer: c.seconds_to_show_answer,
after_question: c.after_question as i32,
question_action: c.question_action as i32,
answer_action: c.answer_action as i32,
wait_for_audio: c.wait_for_audio,
skip_question_when_replaying_answer: !c.replayq,
Expand Down Expand Up @@ -444,9 +444,9 @@ impl From<DeckConfig> for DeckConfSchema11 {
4 => AnswerAction::ShowReminder,
_ => AnswerAction::BuryCard,
},
after_question: match i.after_question {
1 => AfterQuestion::ShowReminder,
_ => AfterQuestion::ShowAnswer,
question_action: match i.question_action {
1 => QuestionAction::ShowReminder,
_ => QuestionAction::ShowAnswer,
},
wait_for_audio: i.wait_for_audio,
replayq: !i.skip_question_when_replaying_answer,
Expand Down Expand Up @@ -526,7 +526,7 @@ static RESERVED_DECKCONF_KEYS: Set<&'static str> = phf_set! {
"stopTimerOnAnswer",
"secondsToShowQuestion",
"secondsToShowAnswer",
"afterQuestion",
"questionAction",
"answerAction",
"waitForAudio",
"sm2Retention",
Expand Down
18 changes: 9 additions & 9 deletions ts/routes/deck-options/AutoAdvance.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import TitledContainer from "$lib/components/TitledContainer.svelte";
import type { HelpItem } from "$lib/components/types";
import { answerChoices, afterQuestionChoices } from "./choices";
import { answerChoices, questionActionChoices } from "./choices";
import type { DeckOptionsState } from "./lib";
import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
Expand All @@ -44,9 +44,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
title: tr.deckConfigAnswerAction(),
help: tr.deckConfigAnswerActionTooltip(),
},
afterQuestion : {
title: tr.deckConfigAfterQuestion(),
help: tr.deckConfigAfterQuestionToolTip(),
questionAction : {
title: tr.deckConfigQuestionAction(),
help: tr.deckConfigQuestionActionToolTip(),
},
};
const helpSections = Object.values(settings) as HelpItem[];
Expand Down Expand Up @@ -136,15 +136,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</Item>
<Item>
<EnumSelectorRow
bind:value={$config.afterQuestion}
defaultValue={defaults.afterQuestion}
choices={afterQuestionChoices()}
bind:value={$config.questionAction}
defaultValue={defaults.questionAction}
choices={questionActionChoices()}
>
<SettingTitle
on:click={() =>
openHelpModal(Object.keys(settings).indexOf("afterQuestion"))}
openHelpModal(Object.keys(settings).indexOf("questionAction"))}
>
{settings.afterQuestion.title}
{settings.questionAction.title}
</SettingTitle>
</EnumSelectorRow>
</Item>
Expand Down
12 changes: 6 additions & 6 deletions ts/routes/deck-options/choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
DeckConfig_Config_NewCardSortOrder,
DeckConfig_Config_ReviewCardOrder,
DeckConfig_Config_ReviewMix,
DeckConfig_Config_AfterQuestion,
DeckConfig_Config_QuestionAction,
} from "@generated/anki/deck_config_pb";
import * as tr from "@generated/ftl";

Expand Down Expand Up @@ -187,15 +187,15 @@ export function answerChoices(): Choice<DeckConfig_Config_AnswerAction>[] {
];
}

export function afterQuestionChoices(): Choice<DeckConfig_Config_AfterQuestion>[] {
export function questionActionChoices(): Choice<DeckConfig_Config_QuestionAction>[] {
return [
{
label: tr.deckConfigAfterQuestionShowAnswer(),
value: DeckConfig_Config_AfterQuestion.SHOW_ANSWER,
label: tr.deckConfigQuestionActionShowAnswer(),
value: DeckConfig_Config_QuestionAction.SHOW_ANSWER,
},
{
label: tr.deckConfigAfterQuestionShowReminder(),
value: DeckConfig_Config_AfterQuestion.SHOW_REMINDER,
label: tr.deckConfigQuestionActionShowReminder(),
value: DeckConfig_Config_QuestionAction.SHOW_REMINDER,
},
];
}

0 comments on commit 35a513b

Please sign in to comment.