use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class SchedV2Test method test_moveVersions.
@Test
public void test_moveVersions() throws Exception {
Collection col = getColV2();
col.changeSchedulerVer(1);
Note n = col.newNote();
n.setItem("Front", "one");
col.addNote(n);
// make it a learning card
col.reset();
Card c = col.getSched().getCard();
col.getSched().answerCard(c, 1);
// the move to v2 should reset it to new
col.changeSchedulerVer(2);
c.load();
assertEquals(QUEUE_TYPE_NEW, c.getQueue());
assertEquals(CARD_TYPE_NEW, c.getType());
// fail it again, and manually bury it
col.reset();
c = col.getSched().getCard();
col.getSched().answerCard(c, 1);
col.getSched().buryCards(new long[] { c.getId() });
c.load();
assertEquals(QUEUE_TYPE_MANUALLY_BURIED, c.getQueue());
// revert to version 1
col.changeSchedulerVer(1);
// card should have moved queues
c.load();
assertEquals(QUEUE_TYPE_SIBLING_BURIED, c.getQueue());
// and it should be new again when unburied
col.getSched().unburyCards();
c.load();
assertEquals(CARD_TYPE_NEW, c.getQueue());
assertEquals(QUEUE_TYPE_NEW, c.getType());
// make sure relearning cards transition correctly to v1
col.changeSchedulerVer(2);
// card with 100 day interval, answering again
col.getSched().reschedCards(new long[] { c.getId() }, 100, 100);
c.load();
c.setDue(0);
c.flush();
DeckConfig conf = col.getSched()._cardConf(c);
conf.getJSONObject("lapse").put("mult", 0.5);
col.getDecks().save(conf);
col.reset();
c = col.getSched().getCard();
col.getSched().answerCard(c, 1);
c.load();
assertEquals(50, c.getIvl());
// due should be correctly set when removed from learning early
col.changeSchedulerVer(1);
c.load();
assertEquals(QUEUE_TYPE_REV, c.getQueue());
assertEquals(CARD_TYPE_REV, c.getType());
assertEquals(50, c.getDue());
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class SchedV2Test method test_suspendv2.
@Test
public void test_suspendv2() throws Exception {
Collection col = getColV2();
Note note = col.newNote();
note.setItem("Front", "one");
col.addNote(note);
Card c = note.cards().get(0);
// suspending
col.reset();
assertNotNull(col.getSched().getCard());
col.getSched().suspendCards(new long[] { c.getId() });
col.reset();
assertNull(col.getSched().getCard());
// unsuspending
col.getSched().unsuspendCards(new long[] { c.getId() });
col.reset();
assertNotNull(col.getSched().getCard());
// should cope with rev cards being relearnt
c.setDue(0);
c.setIvl(100);
c.setType(CARD_TYPE_REV);
c.setQueue(QUEUE_TYPE_REV);
c.flush();
col.reset();
c = col.getSched().getCard();
col.getSched().answerCard(c, 1);
assertThat(c.getDue(), is(greaterThanOrEqualTo(col.getTime().intTime())));
long due = c.getDue();
assertEquals(QUEUE_TYPE_LRN, c.getQueue());
assertEquals(CARD_TYPE_RELEARNING, c.getType());
col.getSched().suspendCards(new long[] { c.getId() });
col.getSched().unsuspendCards(new long[] { c.getId() });
c.load();
assertEquals(QUEUE_TYPE_LRN, c.getQueue());
assertEquals(CARD_TYPE_RELEARNING, c.getType());
assertEquals(due, c.getDue());
// should cope with cards in cram decks
c.setDue(1);
c.flush();
col.getDecks().newDyn("tmp");
col.getSched().rebuildDyn();
c.load();
assertNotEquals(1, c.getDue());
assertNotEquals(1, c.getDid());
col.getSched().suspendCards(new long[] { c.getId() });
c.load();
assertNotEquals(1, c.getDue());
assertNotEquals(1, c.getDid());
assertEquals(1, c.getODue());
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class SchedV2Test method test_initial_repeat.
// hard on the first step should be the average of again and good,
// and it should be logged properly
@Test
@Ignore("Port anki@a9c93d933cadbf5d9c7e3e2b4f7a25d2c59da5d3")
public void test_initial_repeat() throws Exception {
Collection col = getColV2();
Note note = col.newNote();
note.setItem("Front", "one");
note.setItem("Back", "two");
col.addNote(note);
col.reset();
Card c = col.getSched().getCard();
col.getSched().answerCard(c, 2);
// should be due in ~ 5.5 mins
long expected = col.getTime().intTime() + (int) (5.5 * 60);
long due = c.getDue();
assertThat(expected - 10, is(lessThan(due)));
assertThat(due, is(lessThanOrEqualTo((long) (expected * 1.25))));
long ivl = col.getDb().queryLongScalar("select ivl from revlog");
assertEquals((long) (-5.5 * 60), ivl);
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class SchedV2Test method test_reviewsV2.
@Test
public void test_reviewsV2() throws Exception {
Collection col = getColV2();
// add a note
Note note = col.newNote();
note.setItem("Front", "one");
note.setItem("Back", "two");
col.addNote(note);
// set the card up as a review card, due 8 days ago
Card c = note.cards().get(0);
c.setType(CARD_TYPE_REV);
c.setQueue(QUEUE_TYPE_REV);
c.setDue(col.getSched().getToday() - 8);
c.setFactor(STARTING_FACTOR);
c.setReps(3);
c.setLapses(1);
c.setIvl(100);
c.startTimer();
c.flush();
// save it for later use as well
Card cardcopy = c.clone();
// try with an ease of 2
// //////////////////////////////////////////////////////////////////////////////////////////////////
c = cardcopy.clone();
c.flush();
col.reset();
col.getSched().answerCard(c, 2);
assertEquals(QUEUE_TYPE_REV, c.getQueue());
// the new interval should be (100) * 1.2 = 120
assertTrue(checkRevIvl(col, c, 120));
assertEquals(col.getSched().getToday() + c.getIvl(), c.getDue());
// factor should have been decremented
assertEquals(2350, c.getFactor());
// check counters
assertEquals(1, c.getLapses());
assertEquals(4, c.getReps());
// ease 3
// //////////////////////////////////////////////////////////////////////////////////////////////////
c = cardcopy.clone();
c.flush();
col.getSched().answerCard(c, 3);
// the new interval should be (100 + 8/2) * 2.5 = 260
assertTrue(checkRevIvl(col, c, 260));
assertEquals(col.getSched().getToday() + c.getIvl(), c.getDue());
// factor should have been left alone
assertEquals(STARTING_FACTOR, c.getFactor());
// ease 4
// //////////////////////////////////////////////////////////////////////////////////////////////////
c = cardcopy.clone();
c.flush();
col.getSched().answerCard(c, 4);
// the new interval should be (100 + 8) * 2.5 * 1.3 = 351
assertTrue(checkRevIvl(col, c, 351));
assertEquals(col.getSched().getToday() + c.getIvl(), c.getDue());
// factor should have been increased
assertEquals(2650, c.getFactor());
// leech handling
// //////////////////////////////////////////////////////////////////////////////////////////////////
DeckConfig conf = col.getDecks().getConf(1);
conf.getJSONObject("lapse").put("leechAction", LEECH_SUSPEND);
col.getDecks().save(conf);
c = cardcopy.clone();
c.setLapses(7);
c.flush();
/* todo hook
// steup hook
hooked = new [] {};
def onLeech(card):
hooked.append(1);
hooks.card_did_leech.append(onLeech);
col.getSched().answerCard(c, 1);
assertTrue(hooked);
assertEquals(QUEUE_TYPE_SUSPENDED, c.getQueue());
c.load();
assertEquals(QUEUE_TYPE_SUSPENDED, c.getQueue());
*/
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
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 = col.getSched().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, 1);
assertEquals(CARD_TYPE_LRN, c.getQueue());
assertEquals(QUEUE_TYPE_LRN, c.getType());
assertEquals(3003, c.getLeft());
col.getSched().answerCard(c, 3);
assertEquals(CARD_TYPE_LRN, c.getQueue());
assertEquals(QUEUE_TYPE_LRN, c.getType());
// create a dynamic deck and refresh it
long did = col.getDecks().newDyn("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, 3);
// 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)));
}
Aggregations