Skip to content

Commit

Permalink
Hotfix: V2 card queue now rebuilds properly after burying cards (#304)
Browse files Browse the repository at this point in the history
* Hotfix: V2 card queue now rebuilds properly after burying cards
* Fixed Morphman stats in Stats page (#300)
  • Loading branch information
mortii authored Aug 18, 2023
1 parent 0c21a90 commit 399d8fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
13 changes: 6 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import anki.stats
from anki import hooks
from anki.collection import Collection
from anki.lang import _ # TODO: deprecated?

from .morph.util import * # TODO: replace this star
Expand Down Expand Up @@ -44,18 +43,18 @@ def main():
from .morph.browser import browseMorph
from .morph.browser import alreadyKnownTagger

gui_hooks.collection_did_load.append(replace_reviewer_functions)
gui_hooks.profile_did_open.append(replace_reviewer_functions)

# See more detailed morph stats by holding 'Shift'-key while pressing 'Stats' in toolbar
# TODO: maybe move it somewhere less hidden if possible? E.g.a separate toolbar button
gui_hooks.profile_did_open.append(add_morph_stats_to_ease_graph)

# This stores the focus morphs seen today, necessary for the respective skipping option to work
gui_hooks.reviewer_did_answer_card.append(mark_morph_seen)

# Adds the 'K: V:' to the toolbar
gui_hooks.top_toolbar_did_init_links.append(add_morph_stats_to_toolbar)

# See more detailed morph stats by holding 'Shift'-key while pressing 'Stats' in toolbar
# TODO: maybe move it somewhere less hidden if possible? E.g.a separate toolbar button
gui_hooks.stats_dialog_will_show(add_morph_stats_to_ease_graph)

gui_hooks.profile_will_close.append(tear_down_actions_and_submenu)


Expand All @@ -82,7 +81,7 @@ def mark_morph_seen(reviewer: Reviewer, card, ease):
reviewing_utils.mark_morph_seen(card.note())


def replace_reviewer_functions(collection: Collection) -> None:
def replace_reviewer_functions() -> None:
# This skips the cards the user specified in preferences GUI
Reviewer.nextCard = hooks.wrap(Reviewer.nextCard, reviewing_utils.my_next_card, "around")

Expand Down
35 changes: 15 additions & 20 deletions morph/reviewing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,30 @@ def mark_morph_seen(note: Note) -> None:
def my_next_card(self: Reviewer, _old) -> None:
skipped_cards = SkippedCards()

self.previous_card = self.card
self.card = None
self._v3 = None

# NB! If the deck you are studying has sub-decks then new cards will by default only be gathered from the first
# sub-deck until it is empty before looking for new cards in the next sub-deck. If you instead want to get
# new i+1 cards from all sub-decks do the following:
# 1. Activate the v3 scheduler in: Tools -> Review -> Scheduler -> V3 scheduler
# 2. Deck that has sub-decks: Deck options -> Display Order -> New card gather order -> Ascending position

if self.mw.col.sched.version < 3:
self._get_next_v1_v2_card()
else:
self._get_next_v3_card()
while True:
self.previous_card = self.card
self.card = None
self._v3 = None

self._previous_card_info.set_card(self.previous_card)
self._card_info.set_card(self.card)
if self.mw.col.sched.version < 3:
self.mw.col.reset() # rebuilds the queue
self._get_next_v1_v2_card()
else:
self._get_next_v3_card()

if not self.card:
self.mw.moveToState("overview")
return
self._previous_card_info.set_card(self.previous_card)
self._card_info.set_card(self.card)

if not self.card:
self.mw.moveToState("overview")
return

while True:
if self.card.type != CARD_TYPE_NEW:
break # ignore non-new cards

Expand Down Expand Up @@ -105,11 +106,6 @@ def my_next_card(self: Reviewer, _old) -> None:

self.mw.col.sched.buryCards([self.card.id], manual=False)

if self.mw.col.sched.version < 3:
self._get_next_v1_v2_card()
else:
self._get_next_v3_card()

if self._reps is None:
self._initWeb()

Expand Down Expand Up @@ -180,7 +176,6 @@ def highlight(txt: str, field, filter: str, ctx) -> str:
"""When a field is marked with the 'focusMorph' command, we format it by
wrapping all the morphemes in <span>s with attributes set to its maturity"""

print("morphHighlight filter %s" % filter)
if filter != "morphHighlight":
return txt

Expand Down

0 comments on commit 399d8fc

Please sign in to comment.