Skip to content

Commit 5f6ad7f

Browse files
authored
Add files via upload
1 parent e26f399 commit 5f6ad7f

File tree

2 files changed

+37
-43
lines changed

2 files changed

+37
-43
lines changed

meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name": "Progress Bar cards done cards left secondscard time spentleft and ETA", "mod": 1658214749, "min_point_version": 49, "max_point_version": 54, "branch_index": 0, "disabled": false, "config": {}, "conflicts": [], "update_enabled": true}
1+
{"name": "Progress Bar cards done cards left secondscard time spentleft and ETA", "mod": 1658218151, "min_point_version": 49, "max_point_version": 54, "branch_index": 0, "disabled": false, "config": {}, "conflicts": [], "update_enabled": true}

reviewer_progress_bar.py

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""
33
Anki Add-on: Progress Bar
4-
54
Shows progress in the Reviewer in terms of passed cards per session.
6-
75
Copyright: (c) Unknown author (nest0r/Ja-Dark?) 2017
86
(c) SebastienGllmt 2017 <https://github.com/SebastienGllmt/>
97
(c) liuzikai 2018-2020 <https://github.com/liuzikai>
@@ -299,13 +297,13 @@ def updatePB():
299297
sum(case when ease = 1 and type == 1 and lastIvl >= 100 then 1 else 0 end), /* xflunked_supermature */
300298
sum(time)/1000 /* xthetime */
301299
from revlog where id between ? and ?""",x,y)
302-
xthetime = xthetime or 0.01
303-
xcards = xcards or 0.01
304-
xfailed = xfailed or 0.01
305-
xflunked = xflunked or 0.01
306-
xpassed = xpassed or 0.01
307-
xpassed_supermature = xpassed_supermature or 0.01
308-
xflunked_supermature = xflunked_supermature or 0.01
300+
xthetime = xthetime or 0
301+
xcards = xcards or 0
302+
xfailed = xfailed or 0
303+
xflunked = xflunked or 0
304+
xpassed = xpassed or 0
305+
xpassed_supermature = xpassed_supermature or 0
306+
xflunked_supermature = xflunked_supermature or 0
309307

310308
xsecspeed = max(1, xthetime)/max(1, xcards)
311309

@@ -330,22 +328,22 @@ def updatePB():
330328
sum(case when ease = 1 and type == 1 then 1 else 0 end), /* yflunked */
331329
sum(case when ease > 1 and type == 1 then 1 else 0 end) /* ypassed */
332330
from revlog where id > ? """,x)
333-
ycards = ycards or 0.01
334-
yfailed = yfailed or 0.01
335-
yflunked = yflunked or 0.01
336-
ypassed = ypassed or 0.01
331+
ycards = ycards or 0
332+
yfailed = yfailed or 0
333+
yflunked = yflunked or 0
334+
ypassed = ypassed or 0
337335

338336
# YESTERDAY'S VALUES
339-
zTR = 1-float(xpassed/(float(xpassed+xflunked)))
340-
zagain = float(xfailed/xcards)
337+
zTR = 1-float(xpassed/(float((max(1,xpassed+xflunked)))))
338+
zagain = float(xfailed/max(1,xcards))
341339

342340
# TWO DAY AVERAGE VALUES
343-
yTR = 1-float(ypassed/(float(ypassed+yflunked)))
344-
xagain = float(yfailed/ycards)
341+
yTR = 1-float(ypassed/(float(max(1,ypassed+yflunked))))
342+
xagain = float(yfailed/max(1,ycards))
345343

346344
# TODAY'S VALUES
347-
xTR = 1-float(passed/(float(passed+flunked)))
348-
yagain = float(failed/cards)
345+
xTR = 1-float(passed/(float(max(1,passed+flunked))))
346+
yagain = float(failed/max(1,cards))
349347

350348
# TODAY'S VALUES
351349
xlrnWeight = float((1+(1*yagain*lrnSteps))/1)
@@ -695,13 +693,13 @@ def calcProgress(rev: int, lrn: int, new: int) -> int:
695693
sum(case when ease = 1 and type == 1 then 1 else 0 end), /* xflunked */
696694
sum(case when ease > 1 and type == 1 then 1 else 0 end) /* xpassed */
697695
from revlog where id > ?""",y)
698-
xcards = xcards or 0.01
699-
xfailed = xfailed or 0.01
700-
xflunked = xflunked or 0.01
701-
xpassed = xpassed or 0.01
696+
xcards = xcards or 0
697+
xfailed = xfailed or 0
698+
xflunked = xflunked or 0
699+
xpassed = xpassed or 0
702700

703-
TR = 1-float(xpassed/(float(xpassed+xflunked)))
704-
xagain = float(xfailed/xcards)
701+
TR = 1-float(xpassed/(float(max(1,xpassed+xflunked))))
702+
xagain = float(xfailed/max(1,xcards))
705703
lrnWeight = float((1+(1*xagain*lrnSteps))/1)
706704
newWeight = float((1+(1*xagain*lrnSteps))/1)
707705
revWeight = float((1+(1*TR*lrnSteps))/1)
@@ -726,13 +724,13 @@ def calcProgress(rev: int, lrn: int, new: int) -> int:
726724
sum(case when ease = 1 and type == 1 then 1 else 0 end), /* xflunked */
727725
sum(case when ease > 1 and type == 1 then 1 else 0 end) /* xpassed */
728726
from revlog where id > ?""",x)
729-
xcards = xcards or 0.01
730-
xfailed = xfailed or 0.01
731-
xflunked = xflunked or 0.01
732-
xpassed = xpassed or 0.01
727+
xcards = xcards or 0
728+
xfailed = xfailed or 0
729+
xflunked = xflunked or 0
730+
xpassed = xpassed or 0
733731

734-
TR = 1-float(xpassed/(float(xpassed+xflunked)))
735-
xagain = float(xfailed/xcards)
732+
TR = 1-float(xpassed/(float(max(1,xpassed+xflunked))))
733+
xagain = float(xfailed/(max(1,xcards)))
736734
lrnWeight = float((1+(1*xagain*lrnSteps))/1)
737735
newWeight = float((1+(1*xagain*lrnSteps))/1)
738736
revWeight = float((1+(1*TR*lrnSteps))/1)
@@ -758,13 +756,13 @@ def calcProgress(rev: int, lrn: int, new: int) -> int:
758756
sum(case when ease = 1 and type == 1 then 1 else 0 end), /* xflunked */
759757
sum(case when ease > 1 and type == 1 then 1 else 0 end) /* xpassed */
760758
from revlog where id between ? and ?""",x,y)
761-
xcards = xcards or 0.01
762-
xfailed = xfailed or 0.01
763-
xflunked = xflunked or 0.01
764-
xpassed = xpassed or 0.01
759+
xcards = xcards or 0
760+
xfailed = xfailed or 0
761+
xflunked = xflunked or 0
762+
xpassed = xpassed or 0
765763

766-
TR = 1-float(xpassed/(float(xpassed+xflunked)))
767-
xagain = float(xfailed/xcards)
764+
TR = 1-float(xpassed/(float(max(1,xpassed+xflunked))))
765+
xagain = float(xfailed/max(1,xcards))
768766
lrnWeight = float((1+(1*xagain*lrnSteps))/1)
769767
newWeight = float((1+(1*xagain*lrnSteps))/1)
770768
revWeight = float((1+(1*TR*lrnSteps))/1)
@@ -781,20 +779,16 @@ def calcProgress(rev: int, lrn: int, new: int) -> int:
781779
def updateCountsForAllDecks(updateTotal: bool) -> None:
782780
"""
783781
Update counts.
784-
785782
After adding, editing or deleting cards (afterStateChange hook), updateTotal should be set to True to update
786783
totalCount[] based on doneCount[] and remainCount[]. No card should have been answered before this hook is
787784
triggered, so the change in remainCount[] should be caused by editing collection and therefore goes into
788785
totalCount[].
789-
790786
When the user answer a card (showQuestion hook), updateTotal should be set to False to update doneCount[] based on
791787
totalCount[] and remainCount[]. No change to collection should have been made before this hook is
792788
triggered, so the change in remainCount[] should be caused by answering cards and therefore goes into
793789
doneCount[].
794-
795790
In the later case, remainCount[] may still increase based on the weights of New, Lrn and Rev cards (see comments
796791
of "Calculation weights" above), in which case totalCount[] may still get updated based on forceForward setting.
797-
798792
:param updateTotal: True for afterStateChange hook, False for showQuestion hook
799793
"""
800794

@@ -886,4 +880,4 @@ def restoreStylesheet(*args):
886880
EditCurrent.onReset = wrap(
887881
EditCurrent.onReset, changeStylesheet, "after")
888882
EditCurrent.onSave = wrap(
889-
EditCurrent.onSave, changeStylesheet, "after")
883+
EditCurrent.onSave, changeStylesheet, "afterwards")

0 commit comments

Comments
 (0)