(self)
Rate card based on recorded answer time
Rate card based on recorded answer time
Rate card based on recorded answer time
def autoRate(self):
    """Rate card based on recorded answer time"""
    if self.state == "question":  # reveal answer if on question side
        if anki21:
            self._showAnswer()
        else:
            self._showAnswerHack()
        return

    conf = self.mw.col.decks.confForDid(self.card.odid or self.card.did)
    limits = conf.get('autoRate', DEFAULT_LIMITS)

    elapsed = getattr(mw.reviewer, "_autoRateElapsed", None)
    if elapsed is None:
        tooltip("Error: Elapsed time not registered. This should not have happened.")
        return False

    key = 0
    for upper_limit in limits:
        key += 1
        if elapsed > upper_limit:
            break
    else:  # easy
        key += 1

    # determine ease based on button count
    # (will become obsolete with new Scheduler in Anki 2.1)
    count = self.mw.col.sched.answerButtons(self.card)
    ease = REMAP[count][key]

    answer_buttons = self._answerButtonList()
    rating = answer_buttons[ease - 1][1]

    color = COLORS.get(rating, None)
    if color:
        rating_string = "<span style='color: {}'>{}</span>".format(color, rating)
    else:  # support for add-ons that modify the answer button label
        rating_string = rating

    tooltip("""Answer time: {} s<br>Rating: <b>{}</b>""".format(elapsed, rating_string))

    self._answerCard(ease)
def autoRate ( self ) : if self . state == "question" : # reveal answer if on question side if anki21 : self . _showAnswer ( ) else : self . _showAnswerHack ( ) return conf = self . mw . col . decks . confForDid ( self . card . odid or self . card . did ) limits = conf . get ( 'autoRate' , DEFAULT_LIMITS ) elapsed = getattr ( mw . reviewer , "_autoRateElapsed" , None ) if elapsed is None : tooltip ( "Error: Elapsed time not registered. This should not have happened." ) return False key = 0 for upper_limit in limits : key += 1 if elapsed > upper_limit : break else : # easy key += 1 # determine ease based on button count # (will become obsolete with new Scheduler in Anki 2.1) count = self . mw . col . sched . answerButtons ( self . card ) ease = REMAP [ count ] [ key ] answer_buttons = self . _answerButtonList ( ) rating = answer_buttons [ ease - 1 ] [ 1 ] color = COLORS . get ( rating , None ) if color : rating_string = "<span style='color: {}'>{}</span>" . format ( color , rating ) else : # support for add-ons that modify the answer button label rating_string = rating tooltip ( """Answer time: {} s<br>Rating: <b>{}</b>""" . format ( elapsed , rating_string ) ) self . _answerCard ( ease )