use of com.ichi2.libanki.sched.DeckDueTreeNode in project AnkiChinaAndroid by ankichinateam.
the class DeckDueTreeNode method setChildren.
public void setChildren(@NonNull List<DeckDueTreeNode> children, boolean addRev) {
super.setChildren(children, addRev);
// tally up children counts
for (DeckDueTreeNode ch : children) {
mLrnCount += ch.getLrnCount();
mNewCount += ch.getNewCount();
if (addRev) {
mRevCount += ch.getRevCount();
}
}
// limit the counts to the deck's limits
JSONObject conf = getCol().getDecks().confForDid(getDid());
if (conf.getInt("dyn") == 0) {
JSONObject deck = getCol().getDecks().get(getDid());
limitNewCount(conf.getJSONObject("new").getInt("perDay") - deck.getJSONArray("newToday").getInt(1));
if (addRev) {
limitRevCount(conf.getJSONObject("rev").getInt("perDay") - deck.getJSONArray("revToday").getInt(1));
}
}
}
use of com.ichi2.libanki.sched.DeckDueTreeNode in project AnkiChinaAndroid by ankichinateam.
the class SchedTest method learnCardsAreNotFiltered.
@Test
public void learnCardsAreNotFiltered() {
// Replicates Anki commit: 13c54e02d8fd2b35f6c2f4b796fc44dec65043b8
addNoteUsingBasicModel("Hello", "World");
Sched sched = new Sched(getCol());
markNextCardAsGood(sched);
long dynDeck = addDynamicDeck("Hello");
// Act
sched.rebuildDyn(dynDeck);
// Assert
DeckDueTreeNode dynamicDeck = getCountsForDid(dynDeck);
assertThat("A learn card should not be moved into a dyn deck", dynamicDeck.getLrnCount(), is(0));
assertThat("A learn card should not be moved into a dyn deck", dynamicDeck.getNewCount(), is(0));
assertThat("A learn card should not be moved into a dyn deck", dynamicDeck.getRevCount(), is(0));
}
use of com.ichi2.libanki.sched.DeckDueTreeNode in project Anki-Android by ankidroid.
the class SchedV2Test method test_deckDueV2.
@Test
public void test_deckDueV2() throws Exception {
Collection col = getColV2();
// add a note with default deck
Note note = col.newNote();
note.setItem("Front", "one");
col.addNote(note);
// and one that's a child
note = col.newNote();
note.setItem("Front", "two");
long default1 = addDeck("Default::1");
note.model().put("did", default1);
col.addNote(note);
// make it a review card
Card c = note.cards().get(0);
c.setQueue(QUEUE_TYPE_REV);
c.setDue(0);
c.flush();
// add one more with a new deck
note = col.newNote();
note.setItem("Front", "two");
note.model().put("did", addDeck("foo::bar"));
col.addNote(note);
// and one that's a sibling
note = col.newNote();
note.setItem("Front", "three");
note.model().put("did", addDeck("foo::baz"));
col.addNote(note);
col.reset();
assertEquals(5, col.getDecks().allSortedNames().size());
DeckDueTreeNode tree = col.getSched().deckDueTree().get(0);
assertEquals("Default", tree.getLastDeckNameComponent());
// sum of child and parent
assertEquals(1, tree.getDid());
assertEquals(1, tree.getRevCount());
assertEquals(1, tree.getNewCount());
// child count is just review
DeckDueTreeNode child = tree.getChildren().get(0);
assertEquals("1", child.getLastDeckNameComponent());
assertEquals(default1, child.getDid());
assertEquals(1, child.getRevCount());
assertEquals(0, child.getNewCount());
// code should not fail if a card has an invalid deck
c.setDid(12345);
c.flush();
col.getSched().deckDueTree();
}
use of com.ichi2.libanki.sched.DeckDueTreeNode in project Anki-Android by ankidroid.
the class SchedV2Test method test_deckTree.
@Test
public void test_deckTree() throws Exception {
Collection col = getColV2();
addDeck("new::b::c");
addDeck("new2");
// new should not appear twice in tree
List<String> names = new ArrayList<>();
for (DeckDueTreeNode tree : col.getSched().deckDueTree()) {
names.add(tree.getLastDeckNameComponent());
}
names.remove("new");
assertFalse(names.contains("new"));
}
use of com.ichi2.libanki.sched.DeckDueTreeNode in project Anki-Android by ankidroid.
the class SchedV2Test method ensureDeckTree.
@Test
public void ensureDeckTree() {
for (String deckName : TEST_DECKS) {
addDeck(deckName);
}
AbstractSched sched = getCol().getSched();
List<DeckDueTreeNode> tree = sched.deckDueTree();
Assert.assertEquals("Tree has not the expected structure", expectedTree(getCol(), true), tree);
}
Aggregations