From ca48ca155d1a15dfffaa14e1308038e3e09853b6 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 7 Jan 2009 08:51:16 +0900 Subject: [PATCH] add countdown timer, tweak study options page, fix bug with last 10 mins --- ankiqt/ui/main.py | 31 ++++++++++++++++--------------- ankiqt/ui/status.py | 11 +++++++---- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 720f5109b..530c5c398 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -978,13 +978,15 @@ day = :d""", d=yesterday) dchange = str(dchange) h['repsToday'] = '%s' % dtoday h['repsTodayChg'] = '(%s)' % dchange + start = self.deck.sessionStartTime or time.time() - 600 + start2 = self.deck.lastSessionStart or start - 600 last10 = self.deck.s.scalar( - "select count(*) from reviewHistory where time > :t", - t=time.time()-600) + "select count(*) from reviewHistory where time >= :t", + t=start) last20 = self.deck.s.scalar( "select count(*) from reviewHistory where " - "time > :t and time < :t2", - t=time.time()-1200, t2=time.time()-600) + "time >= :t and time < :t2", + t=start2, t2=start) change = last10 - last20 if change >= 0: change = "+%d" % change @@ -995,28 +997,28 @@ day = :d""", d=yesterday) ttoday = s['dReviewTime'] change = ttoday - tyest if change >= 0: - change = "+%s" % anki.utils.fmtTimeSpan(change, short=True) + change = "+%s" % anki.utils.fmtTimeSpan(change, short=True, point=1) else: - change = anki.utils.fmtTimeSpan(change, short=True) + change = anki.utils.fmtTimeSpan(change, short=True, point=1) h['timeToday'] = '%s' % ( - anki.utils.fmtTimeSpan(ttoday, short=True)) + anki.utils.fmtTimeSpan(ttoday, short=True, point=1)) h['timeTodayChg'] = '(%s)' % change self.mainWin.optionsLabel.setText(top + _("""\

- - - + - + + +
Reps done today:%(repsToday)s%(repsTodayChg)s
Reps in last 10 mins:%(repsIn10)s
Reps (10 mins):  %(repsIn10)s %(repsIn10Chg)s
Total time today:%(timeToday)s
Reps (today):%(repsToday)s%(repsTodayChg)s
Time (today):%(timeToday)s      %(timeTodayChg)s
- - - + + +
Lapsed due:%(lapsed)s
Retained due:%(ret)s
New due:%(new)s
Failed:%(lapsed)s
Review:   %(ret)s
New:%(new)s
""") % h) # start reviewing button self.mainWin.buttonStack.setCurrentIndex(3) @@ -1948,4 +1950,3 @@ Consider backing up your media directory first.""")) def setupMisc(self): if time.time() - self.config['created'] < 60 and self.deck: self.config['created'] = self.deck.created - print (time.time() - self.deck.created) / 60.0 / 60.0 / 24.0 diff --git a/ankiqt/ui/status.py b/ankiqt/ui/status.py index 5e592ddaf..aec754bd2 100644 --- a/ankiqt/ui/status.py +++ b/ankiqt/ui/status.py @@ -233,10 +233,13 @@ You should aim to answer each question within
return if self.main.state in ("showQuestion", "showAnswer"): if self.main.currentCard: - t = self.main.currentCard.thinkingTime() - if t < 60: - self.timer.setText('00:%02d' % t) + if self.main.deck.sessionStartTime: + t = time.time() - self.main.deck.sessionStartTime + t = self.main.deck.sessionTimeLimit - t else: - self.timer.setText('01:00') + t = self.main.currentCard.thinkingTime() + if t < 0: + t = 0 + self.timer.setText('%02d:%02d' % (t/60, t%60)) return self.timer.setText("00:00")