diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 49b53f53a..e0326d838 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -171,7 +171,9 @@ ijqq AntoineQ1 jthulhu Escape0707 +Loudwig Wu Yi-Wei + ******************** The text of the 3 clause BSD license follows: diff --git a/ftl/core/deck-config.ftl b/ftl/core/deck-config.ftl index 3335ea512..ba54214c2 100644 --- a/ftl/core/deck-config.ftl +++ b/ftl/core/deck-config.ftl @@ -237,6 +237,10 @@ deck-config-seconds-to-show-question = Seconds to show question for deck-config-seconds-to-show-question-tooltip-2 = When auto advance is activated, the number of seconds to wait before revealing the answer. Set to 0 to disable. deck-config-seconds-to-show-answer = Seconds to show answer for deck-config-seconds-to-show-answer-tooltip-2 = When auto advance is activated, the number of seconds to wait before applying the answer action. Set to 0 to disable. +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 question is shown, and time has elapsed. deck-config-answer-action = Answer action deck-config-answer-action-tooltip = The action to perform on the current card before automatically advancing to the next one. deck-config-wait-for-audio-tooltip = Wait for audio to finish before automatically revealing answer or next question diff --git a/ftl/core/studying.ftl b/ftl/core/studying.ftl index 8c642d9d5..ed3f8eb30 100644 --- a/ftl/core/studying.ftl +++ b/ftl/core/studying.ftl @@ -56,4 +56,5 @@ studying-minute = [one] { $count } minute. *[other] { $count } minutes. } +studying-question-time-elapsed = Question time elapsed studying-answer-time-elapsed = Answer time elapsed diff --git a/proto/anki/deck_config.proto b/proto/anki/deck_config.proto index f44fbb366..fbd1158f8 100644 --- a/proto/anki/deck_config.proto +++ b/proto/anki/deck_config.proto @@ -100,7 +100,10 @@ message DeckConfig { ANSWER_ACTION_ANSWER_HARD = 3; ANSWER_ACTION_SHOW_REMINDER = 4; } - + enum QuestionAction { + QUESTION_ACTION_SHOW_ANSWER = 0; + QUESTION_ACTION_SHOW_REMINDER = 1; + } repeated float learn_steps = 1; repeated float relearn_steps = 2; @@ -144,6 +147,7 @@ message DeckConfig { bool stop_timer_on_answer = 38; float seconds_to_show_question = 41; float seconds_to_show_answer = 42; + QuestionAction question_action = 36; AnswerAction answer_action = 43; bool wait_for_audio = 44; bool skip_question_when_replaying_answer = 26; diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index 58b0cde87..70afc54cf 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -137,6 +137,11 @@ class AnswerAction(Enum): SHOW_REMINDER = 4 +class QuestionAction(Enum): + SHOW_ANSWER = 0 + SHOW_REMINDER = 1 + + class Reviewer: def __init__(self, mw: AnkiQt) -> None: self.mw = mw @@ -423,7 +428,15 @@ class Reviewer: ): self.auto_advance_enabled = False return - self._showAnswer() + try: + question_action = list(QuestionAction)[conf["questionAction"]] + except IndexError: + question_action = QuestionAction.SHOW_ANSWER + + if question_action == QuestionAction.SHOW_ANSWER: + self._showAnswer() + else: + tooltip(tr.studying_question_time_elapsed()) def autoplay(self, card: Card) -> bool: print("use card.autoplay() instead of reviewer.autoplay(card)") diff --git a/rslib/src/deckconfig/mod.rs b/rslib/src/deckconfig/mod.rs index 271a3c514..d11bc43f3 100644 --- a/rslib/src/deckconfig/mod.rs +++ b/rslib/src/deckconfig/mod.rs @@ -11,6 +11,7 @@ pub use anki_proto::deck_config::deck_config::config::LeechAction; pub use anki_proto::deck_config::deck_config::config::NewCardGatherPriority; 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::QuestionAction; 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 as DeckConfigInner; @@ -66,6 +67,7 @@ const DEFAULT_DECK_CONFIG_INNER: DeckConfigInner = DeckConfigInner { stop_timer_on_answer: false, seconds_to_show_question: 0.0, seconds_to_show_answer: 0.0, + question_action: QuestionAction::ShowAnswer as i32, answer_action: AnswerAction::BuryCard as i32, wait_for_audio: true, skip_question_when_replaying_answer: false, diff --git a/rslib/src/deckconfig/schema11.rs b/rslib/src/deckconfig/schema11.rs index 8775c3442..2219802b0 100644 --- a/rslib/src/deckconfig/schema11.rs +++ b/rslib/src/deckconfig/schema11.rs @@ -82,6 +82,8 @@ pub struct DeckConfSchema11 { #[serde(default)] seconds_to_show_answer: f32, #[serde(default)] + question_action: QuestionAction, + #[serde(default)] answer_action: AnswerAction, #[serde(default = "wait_for_audio_default")] wait_for_audio: bool, @@ -94,6 +96,14 @@ pub struct DeckConfSchema11 { #[serde(flatten)] other: HashMap, } +#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, Clone)] +#[repr(u8)] +#[derive(Default)] +pub enum QuestionAction { + #[default] + ShowAnswer = 0, + ShowReminder = 1, +} #[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, Clone)] #[repr(u8)] @@ -278,6 +288,7 @@ impl Default for DeckConfSchema11 { stop_timer_on_answer: false, seconds_to_show_question: 0.0, seconds_to_show_answer: 0.0, + question_action: QuestionAction::ShowAnswer, answer_action: AnswerAction::BuryCard, wait_for_audio: true, replayq: true, @@ -365,6 +376,7 @@ impl From 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, + 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, @@ -431,6 +443,10 @@ impl From for DeckConfSchema11 { 4 => AnswerAction::ShowReminder, _ => AnswerAction::BuryCard, }, + 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, dynamic: false, @@ -509,6 +525,7 @@ static RESERVED_DECKCONF_KEYS: Set<&'static str> = phf_set! { "stopTimerOnAnswer", "secondsToShowQuestion", "secondsToShowAnswer", + "questionAction", "answerAction", "waitForAudio", "sm2Retention", diff --git a/ts/routes/deck-options/AutoAdvance.svelte b/ts/routes/deck-options/AutoAdvance.svelte index f68974383..fcad12f3f 100644 --- a/ts/routes/deck-options/AutoAdvance.svelte +++ b/ts/routes/deck-options/AutoAdvance.svelte @@ -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 } from "./choices"; + import { answerChoices, questionActionChoices } from "./choices"; import type { DeckOptionsState } from "./lib"; import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte"; @@ -44,6 +44,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html title: tr.deckConfigAnswerAction(), help: tr.deckConfigAnswerActionTooltip(), }, + questionAction: { + title: tr.deckConfigQuestionAction(), + help: tr.deckConfigQuestionActionToolTip(), + }, }; const helpSections = Object.values(settings) as HelpItem[]; @@ -130,5 +134,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html + + + + openHelpModal(Object.keys(settings).indexOf("questionAction"))} + > + {settings.questionAction.title} + + + diff --git a/ts/routes/deck-options/choices.ts b/ts/routes/deck-options/choices.ts index 5f84af617..1622704c5 100644 --- a/ts/routes/deck-options/choices.ts +++ b/ts/routes/deck-options/choices.ts @@ -7,6 +7,7 @@ import { DeckConfig_Config_NewCardGatherPriority, DeckConfig_Config_NewCardInsertOrder, DeckConfig_Config_NewCardSortOrder, + DeckConfig_Config_QuestionAction, DeckConfig_Config_ReviewCardOrder, DeckConfig_Config_ReviewMix, } from "@generated/anki/deck_config_pb"; @@ -184,3 +185,15 @@ export function answerChoices(): Choice[] { }, ]; } +export function questionActionChoices(): Choice[] { + return [ + { + label: tr.deckConfigQuestionActionShowAnswer(), + value: DeckConfig_Config_QuestionAction.SHOW_ANSWER, + }, + { + label: tr.deckConfigQuestionActionShowReminder(), + value: DeckConfig_Config_QuestionAction.SHOW_REMINDER, + }, + ]; +}