diff --git a/pylib/anki/cards.py b/pylib/anki/cards.py index 844c4f048..703cf13fb 100644 --- a/pylib/anki/cards.py +++ b/pylib/anki/cards.py @@ -163,21 +163,24 @@ class Card: def startTimer(self) -> None: self.timerStarted = time.time() + def currentDeckID(self) -> int: + return anki.decks.DeckID(self.odid or self.did) + def timeLimit(self) -> int: "Time limit for answering in milliseconds." - conf = self.col.decks.confForDid(self.odid or self.did) + conf = self.col.decks.confForDid(self.currentDeckID()) return conf["maxTaken"] * 1000 def shouldShowTimer(self) -> bool: - conf = self.col.decks.confForDid(self.odid or self.did) + conf = self.col.decks.confForDid(self.currentDeckID()) return conf["timer"] def replay_question_audio_on_answer_side(self) -> bool: - conf = self.col.decks.confForDid(self.odid or self.did) + conf = self.col.decks.confForDid(self.currentDeckID()) return conf.get("replayq", True) def autoplay(self) -> bool: - return self.col.decks.confForDid(self.odid or self.did)["autoplay"] + return self.col.decks.confForDid(self.currentDeckID())["autoplay"] def timeTaken(self) -> int: "Time taken to answer card, in integer MS." diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index fa0c8ddfe..bf9d31519 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -398,7 +398,7 @@ class Collection: or current notetype. """ if card := current_review_card: - home_deck = card.odid or card.did + home_deck = card.currentDeckID() else: home_deck = 0 diff --git a/pylib/anki/template.py b/pylib/anki/template.py index 131633b9d..ed3ce506d 100644 --- a/pylib/anki/template.py +++ b/pylib/anki/template.py @@ -172,7 +172,7 @@ class TemplateRenderContext: # add (most) special fields fields["Tags"] = self._note.stringTags().strip() fields["Type"] = self._note_type["name"] - fields["Deck"] = self._col.decks.name(self._card.odid or self._card.did) + fields["Deck"] = self._col.decks.name(self._card.currentDeckID()) fields["Subdeck"] = DeckManager.basename(fields["Deck"]) if self._template: fields["Card"] = self._template["name"] diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index e36062c0a..a93336c40 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -834,7 +834,7 @@ time = %(time)d; qconnect(a.triggered, func) def onOptions(self) -> None: - self.mw.onDeckConf(self.mw.col.decks.get(self.card.odid or self.card.did)) + self.mw.onDeckConf(self.mw.col.decks.get(self.card.currentDeckID())) def set_flag_on_current_card(self, desired_flag: int) -> None: # need to toggle off?