use of com.ichi2.anki.CardBrowser.Column.DUE in project Anki-Android by ankidroid.
the class SchedV2Test method test_button_spacingV2.
@Test
public void test_button_spacingV2() throws Exception {
Collection col = getColV2();
Note note = col.newNote();
note.setItem("Front", "one");
col.addNote(note);
// 1 day ivl review card due now
Card c = note.cards().get(0);
c.setType(CARD_TYPE_REV);
c.setQueue(QUEUE_TYPE_REV);
c.setDue(col.getSched().getToday());
c.setReps(1);
c.setIvl(1);
c.startTimer();
c.flush();
col.reset();
// Upstream, there is no space in 2d
assertEquals("2 d", without_unicode_isolation(col.getSched().nextIvlStr(getTargetContext(), c, BUTTON_TWO)));
assertEquals("3 d", without_unicode_isolation(col.getSched().nextIvlStr(getTargetContext(), c, BUTTON_THREE)));
assertEquals("4 d", without_unicode_isolation(col.getSched().nextIvlStr(getTargetContext(), c, BUTTON_FOUR)));
// if hard factor is <= 1, then hard may not increase
DeckConfig conf = col.getDecks().confForDid(1);
conf.getJSONObject("rev").put("hardFactor", 1);
col.getDecks().save(conf);
assertEquals("1 d", without_unicode_isolation(col.getSched().nextIvlStr(getTargetContext(), c, BUTTON_TWO)));
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project Anki-Android by ankidroid.
the class SchedV2Test method test_learn_collapsedV2.
@Test
public void test_learn_collapsedV2() throws Exception {
Collection col = getColV2();
// add 2 notes
Note note = col.newNote();
note.setItem("Front", "1");
col.addNote(note);
note = col.newNote();
note.setItem("Front", "2");
col.addNote(note);
// set as a learn card and rebuild queues
col.getDb().execute("update cards set queue=0, type=0");
col.reset();
// should get '1' first
Card c = getCard();
assertTrue(c.q().endsWith("1"));
// pass it so it's due in 10 minutes
col.getSched().answerCard(c, BUTTON_THREE);
// get the other card
c = getCard();
assertTrue(c.q().endsWith("2"));
// fail it so it's due in 1 minute
col.getSched().answerCard(c, BUTTON_ONE);
// we shouldn't get the same card again
c = getCard();
assertFalse(c.q().endsWith("2"));
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project Anki-Android by ankidroid.
the class SchedV2Test method test_filt_keep_lrn_state.
@Test
public void test_filt_keep_lrn_state() throws Exception {
Collection col = getColV2();
Note note = col.newNote();
note.setItem("Front", "one");
col.addNote(note);
// fail the card outside filtered deck
Card c = getCard();
DeckConfig conf = col.getSched()._cardConf(c);
conf.getJSONObject("new").put("delays", new JSONArray(new double[] { 1, 10, 61 }));
col.getDecks().save(conf);
col.getSched().answerCard(c, BUTTON_ONE);
assertEquals(CARD_TYPE_LRN, c.getQueue());
assertEquals(QUEUE_TYPE_LRN, c.getType());
assertEquals(3003, c.getLeft());
col.getSched().answerCard(c, BUTTON_THREE);
assertEquals(CARD_TYPE_LRN, c.getQueue());
assertEquals(QUEUE_TYPE_LRN, c.getType());
// create a dynamic deck and refresh it
long did = addDynamicDeck("Cram");
col.getSched().rebuildDyn(did);
col.reset();
// card should still be in learning state
c.load();
assertEquals(CARD_TYPE_LRN, c.getQueue());
assertEquals(QUEUE_TYPE_LRN, c.getType());
assertEquals(2002, c.getLeft());
// should be able to advance learning steps
col.getSched().answerCard(c, BUTTON_THREE);
// should be due at least an hour in the future
assertThat(c.getDue() - col.getTime().intTime(), is(greaterThan(60 * 60L)));
// emptying the deck preserves learning state
col.getSched().emptyDyn(did);
c.load();
assertEquals(CARD_TYPE_LRN, c.getQueue());
assertEquals(QUEUE_TYPE_LRN, c.getType());
assertEquals(1001, c.getLeft());
assertThat(c.getDue() - col.getTime().intTime(), is(greaterThan(60 * 60L)));
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project Anki-Android by ankidroid.
the class SchedV2Test method test_negativeDueFilter.
// cards with a due date earlier than the collection should retain
// their due date when removed
@Test
public void test_negativeDueFilter() throws Exception {
Collection col = getColV2();
// card due prior to collection date
Note note = col.newNote();
note.setItem("Front", "one");
note.setItem("Back", "two");
col.addNote(note);
Card c = note.cards().get(0);
c.setDue(-5);
c.setQueue(QUEUE_TYPE_REV);
c.setIvl(5);
c.flush();
// into and out of filtered deck
long did = addDynamicDeck("Cram");
col.getSched().rebuildDyn(did);
col.getSched().emptyDyn(did);
col.reset();
c.load();
assertEquals(-5, c.getDue());
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project Anki-Android by ankidroid.
the class SchedV2Test method test_preview.
@Test
public void test_preview() throws Exception {
// add cards
Collection col = getColV2();
Note note = col.newNote();
note.setItem("Front", "one");
col.addNote(note);
Card c = note.cards().get(0);
Card orig = c.clone();
Note note2 = col.newNote();
note2.setItem("Front", "two");
col.addNote(note2);
// cram deck
long did = addDynamicDeck("Cram");
Deck cram = col.getDecks().get(did);
cram.put("resched", false);
col.getDecks().save(cram);
col.getSched().rebuildDyn(did);
col.reset();
// grab the first card
c = getCard();
assertEquals(2, col.getSched().answerButtons(c));
assertEquals(600, col.getSched().nextIvl(c, BUTTON_ONE));
assertEquals(0, col.getSched().nextIvl(c, BUTTON_TWO));
// failing it will push its due time back
long due = c.getDue();
col.getSched().answerCard(c, BUTTON_ONE);
assertNotEquals(c.getDue(), due);
// the other card should come next
Card c2 = getCard();
assertNotEquals(c2.getId(), c.getId());
// passing it will remove it
col.getSched().answerCard(c2, BUTTON_TWO);
assertEquals(QUEUE_TYPE_NEW, c2.getQueue());
assertEquals(0, c2.getReps());
assertEquals(CARD_TYPE_NEW, c2.getType());
// the other card should appear again
c = getCard();
assertEquals(orig.getId(), c.getId());
// emptying the filtered deck should restore card
col.getSched().emptyDyn(did);
c.load();
assertEquals(QUEUE_TYPE_NEW, c.getQueue());
assertEquals(0, c.getReps());
assertEquals(CARD_TYPE_NEW, c.getType());
}
Aggregations