Search in sources :

Example 11 with REVIEWS

use of com.ichi2.anki.CardBrowser.Column.REVIEWS in project Anki-Android by ankidroid.

the class Sched method deckDueList.

/*
      Deck list **************************************************************** *******************************
     */
/**
 * Returns [deckname, did, rev, lrn, new]
 */
@Override
@Nullable
public List<DeckDueTreeNode> deckDueList(@Nullable CancelListener cancelListener) {
    _checkDay();
    mCol.getDecks().checkIntegrity();
    List<Deck> decks = mCol.getDecks().allSorted();
    HashMap<String, Integer[]> lims = HashUtil.HashMapInit(decks.size());
    ArrayList<DeckDueTreeNode> deckNodes = new ArrayList<>(decks.size());
    for (Deck deck : decks) {
        if (isCancelled(cancelListener)) {
            return null;
        }
        String deckName = deck.getString("name");
        String p = Decks.parent(deckName);
        // new
        int nlim = _deckNewLimitSingle(deck, false);
        int rlim = _deckRevLimitSingle(deck, false);
        if (!TextUtils.isEmpty(p)) {
            Integer[] parentLims = lims.get(Decks.normalizeName(p));
            // 'temporary for diagnosis of bug #6383'
            Assert.that(parentLims != null, "Deck %s is supposed to have parent %s. It has not be found.", deckName, p);
            nlim = Math.min(nlim, parentLims[0]);
            // review
            rlim = Math.min(rlim, parentLims[1]);
        }
        int _new = _newForDeck(deck.getLong("id"), nlim);
        // learning
        int lrn = _lrnForDeck(deck.getLong("id"));
        // reviews
        int rev = _revForDeck(deck.getLong("id"), rlim);
        // save to list
        deckNodes.add(new DeckDueTreeNode(mCol, deck.getString("name"), deck.getLong("id"), rev, lrn, _new));
        // add deck as a parent
        lims.put(Decks.normalizeName(deck.getString("name")), new Integer[] { nlim, rlim });
    }
    return deckNodes;
}
Also used : ArrayList(java.util.ArrayList) Deck(com.ichi2.libanki.Deck) Nullable(androidx.annotation.Nullable)

Example 12 with REVIEWS

use of com.ichi2.anki.CardBrowser.Column.REVIEWS in project Anki-Android by ankidroid.

the class SchedV2 method deckDueList.

// Overridden
@Nullable
public List<DeckDueTreeNode> deckDueList(@Nullable CancelListener collectionTask) {
    _checkDay();
    mCol.getDecks().checkIntegrity();
    List<Deck> decks = mCol.getDecks().allSorted();
    HashMap<String, Integer[]> lims = HashUtil.HashMapInit(decks.size());
    ArrayList<DeckDueTreeNode> deckNodes = new ArrayList<>(decks.size());
    Decks.Node childMap = mCol.getDecks().childMap();
    for (Deck deck : decks) {
        if (isCancelled(collectionTask)) {
            return null;
        }
        String deckName = deck.getString("name");
        String p = Decks.parent(deckName);
        // new
        int nlim = _deckNewLimitSingle(deck, false);
        Integer plim = null;
        if (!TextUtils.isEmpty(p)) {
            Integer[] parentLims = lims.get(Decks.normalizeName(p));
            // 'temporary for diagnosis of bug #6383'
            Assert.that(parentLims != null, "Deck %s is supposed to have parent %s. It has not be found.", deckName, p);
            nlim = Math.min(nlim, parentLims[0]);
            // reviews
            plim = parentLims[1];
        }
        int _new = _newForDeck(deck.getLong("id"), nlim);
        // learning
        int lrn = _lrnForDeck(deck.getLong("id"));
        // reviews
        int rlim = _deckRevLimitSingle(deck, plim, false);
        int rev = _revForDeck(deck.getLong("id"), rlim, childMap);
        // save to list
        deckNodes.add(new DeckDueTreeNode(mCol, deck.getString("name"), deck.getLong("id"), rev, lrn, _new));
        // add deck as a parent
        lims.put(Decks.normalizeName(deck.getString("name")), new Integer[] { nlim, rlim });
    }
    return deckNodes;
}
Also used : Decks(com.ichi2.libanki.Decks) ArrayList(java.util.ArrayList) Deck(com.ichi2.libanki.Deck) Nullable(androidx.annotation.Nullable)

Example 13 with REVIEWS

use of com.ichi2.anki.CardBrowser.Column.REVIEWS in project Anki-Android by ankidroid.

the class SchedV2 method _earlyReviewIvl.

/**
 * next interval for card when answered early+correctly
 */
private int _earlyReviewIvl(@NonNull Card card, @Consts.BUTTON_TYPE int ease) {
    if (!card.isInDynamicDeck() || card.getType() != Consts.CARD_TYPE_REV || card.getFactor() == 0) {
        throw new RuntimeException("Unexpected card parameters");
    }
    if (ease <= 1) {
        throw new RuntimeException("Ease must be greater than 1");
    }
    long elapsed = card.getIvl() - (card.getODue() - mToday);
    @NonNull JSONObject conf = _revConf(card);
    double easyBonus = 1;
    // early 3/4 reviews shouldn't decrease previous interval
    double minNewIvl = 1;
    double factor;
    if (ease == Consts.BUTTON_TWO) {
        factor = conf.optDouble("hardFactor", 1.2);
        // hard cards shouldn't have their interval decreased by more than 50%
        // of the normal factor
        minNewIvl = factor / 2;
    } else if (ease == 3) {
        factor = card.getFactor() / 1000.0;
    } else {
        // ease == 4
        factor = card.getFactor() / 1000.0;
        double ease4 = conf.getDouble("ease4");
        // 1.3 -> 1.15
        easyBonus = ease4 - (ease4 - 1) / 2;
    }
    double ivl = Math.max(elapsed * factor, 1);
    // cap interval decreases
    ivl = Math.max(card.getIvl() * minNewIvl, ivl) * easyBonus;
    return _constrainedIvl(ivl, conf, 0, false);
}
Also used : JSONObject(com.ichi2.utils.JSONObject) NonNull(androidx.annotation.NonNull)

Example 14 with REVIEWS

use of com.ichi2.anki.CardBrowser.Column.REVIEWS in project Anki-Android by ankidroid.

the class OverviewStatsBuilderTest method testInfoHtmlStringLife.

@Test
@Config(qualifiers = "en")
public void testInfoHtmlStringLife() {
    OverviewStatsBuilder statsTester = new OverviewStatsBuilder(new WebView(getTargetContext()), getCol(), 42L, Stats.AxisType.TYPE_LIFE);
    String HTML = statsTester.createInfoHtmlString();
    assertEquals(HTML, "<center><style>\n" + "h1, h3 { margin-bottom: 0; margin-top: 1em; text-transform: capitalize; }\n" + ".pielabel { text-align:center; padding:0px; color:white; }\n" + "body {color:#FFFFFF;}\n" + "</style><h1>Today</h1>Studied <b>0 cards</b> in <b>0 minutes</b> today<br>Again count: <b>0</b><br>Learn: <b>0</b>, review: <b>0</b>, relearn: <b>0</b>, filtered: <b>0</b><br>No mature cards were studied today<h1>deck life</h1><h3>FORECAST</h3>Total: <b>0</b> reviews<br>Average: <b>0.0</b> reviews/day<br>Due tomorrow: <b>0</b><br><h3>REVIEW COUNT</h3>Days studied: <b>0%</b> (0 of 1)<br>Total: <b>0</b> reviews<br>Average for days studied: <b>0.0</b> reviews/day<br>If you studied every day: <b>0.0</b> reviews/day<br><h3>REVIEW TIME</h3>Days studied: <b>0%</b> (0 of 1)<br>Total: <b>0</b> minutes<br>Average for days studied: <b>0.0</b> minutes/day<br>If you studied every day: <b>0.0</b> minutes/day<br>Average answer time: <b>0.0s</b> (<b>0.00</b> cards/minute)<br><h3>ADDED</h3>Total: <b>0</b> cards<br>Average: <b>0.0</b> cards/day<br><h3>INTERVALS</h3>Average interval: <b>0.0</b> hours<br>Longest interval: <b>0.0</b> hours<h3>ANSWER BUTTONS</h3>Learning: <b>0.00%</b> correct (0 of 0)<br>Young: <b>0.00%</b> correct (0 of 0)<br>Mature: <b>0.00%</b> correct (0 of 0)<h3>CARD TYPES</h3>Total cards: <b>0</b><br>Total notes: <b>0</b><br>Lowest ease: <b>0%</b><br>Average ease: <b>0%</b><br>Highest ease: <b>0%</b></center>");
}
Also used : WebView(android.webkit.WebView) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 15 with REVIEWS

use of com.ichi2.anki.CardBrowser.Column.REVIEWS in project Anki-Android by ankidroid.

the class OverviewStatsBuilderTest method testInfoHtmlStringYear.

@Test
@Config(qualifiers = "en")
public void testInfoHtmlStringYear() {
    OverviewStatsBuilder statsTester = new OverviewStatsBuilder(new WebView(getTargetContext()), getCol(), 42L, Stats.AxisType.TYPE_YEAR);
    String HTML = statsTester.createInfoHtmlString();
    assertEquals(HTML, "<center><style>\n" + "h1, h3 { margin-bottom: 0; margin-top: 1em; text-transform: capitalize; }\n" + ".pielabel { text-align:center; padding:0px; color:white; }\n" + "body {color:#FFFFFF;}\n" + "</style><h1>Today</h1>Studied <b>0 cards</b> in <b>0 minutes</b> today<br>Again count: <b>0</b><br>Learn: <b>0</b>, review: <b>0</b>, relearn: <b>0</b>, filtered: <b>0</b><br>No mature cards were studied today<h1>1 year</h1><h3>FORECAST</h3>Total: <b>0</b> reviews<br>Average: <b>0.0</b> reviews/day<br>Due tomorrow: <b>0</b><br><h3>REVIEW COUNT</h3>Days studied: <b>0%</b> (0 of 365)<br>Total: <b>0</b> reviews<br>Average for days studied: <b>0.0</b> reviews/day<br>If you studied every day: <b>0.0</b> reviews/day<br><h3>REVIEW TIME</h3>Days studied: <b>0%</b> (0 of 365)<br>Total: <b>0</b> minutes<br>Average for days studied: <b>0.0</b> minutes/day<br>If you studied every day: <b>0.0</b> minutes/day<br>Average answer time: <b>0.0s</b> (<b>0.00</b> cards/minute)<br><h3>ADDED</h3>Total: <b>0</b> cards<br>Average: <b>0.0</b> cards/day<br><h3>INTERVALS</h3>Average interval: <b>0.0</b> hours<br>Longest interval: <b>0.0</b> hours<h3>ANSWER BUTTONS</h3>Learning: <b>0.00%</b> correct (0 of 0)<br>Young: <b>0.00%</b> correct (0 of 0)<br>Mature: <b>0.00%</b> correct (0 of 0)<h3>CARD TYPES</h3>Total cards: <b>0</b><br>Total notes: <b>0</b><br>Lowest ease: <b>0%</b><br>Average ease: <b>0%</b><br>Highest ease: <b>0%</b></center>");
}
Also used : WebView(android.webkit.WebView) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

Deck (com.ichi2.libanki.Deck)8 RobolectricTest (com.ichi2.anki.RobolectricTest)7 Test (org.junit.Test)7 Collection (com.ichi2.libanki.Collection)6 Nullable (androidx.annotation.Nullable)4 Card (com.ichi2.libanki.Card)4 Note (com.ichi2.libanki.Note)4 ArrayList (java.util.ArrayList)4 WebView (android.webkit.WebView)3 Config (org.robolectric.annotation.Config)3 NonNull (androidx.annotation.NonNull)2 DeckConfig (com.ichi2.libanki.DeckConfig)2 Model (com.ichi2.libanki.Model)2 JSONObject (com.ichi2.utils.JSONObject)2 HashMap (java.util.HashMap)2 Decks (com.ichi2.libanki.Decks)1