use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class Sched method _answerLrnCard.
/**
* @param ease 1=no, 2=yes, 3=remove
*/
@Override
protected void _answerLrnCard(@NonNull Card card, @Consts.BUTTON_TYPE int ease) {
JSONObject conf = _lrnConf(card);
@Consts.CARD_TYPE int type;
if (card.getODid() != 0 && !card.getWasNew()) {
type = Consts.CARD_TYPE_RELEARNING;
} else if (card.getType() == Consts.CARD_TYPE_REV) {
type = Consts.CARD_TYPE_REV;
} else {
type = Consts.CARD_TYPE_NEW;
}
boolean leaving = false;
// lrnCount was decremented once when card was fetched
int lastLeft = card.getLeft();
// immediate graduate?
if (ease == Consts.BUTTON_THREE) {
_rescheduleAsRev(card, conf, true);
leaving = true;
// graduation time?
} else if (ease == Consts.BUTTON_TWO && (card.getLeft() % 1000) - 1 <= 0) {
_rescheduleAsRev(card, conf, false);
leaving = true;
} else {
// one step towards graduation
if (ease == Consts.BUTTON_TWO) {
// decrement real left count and recalculate left today
int left = (card.getLeft() % 1000) - 1;
card.setLeft(_leftToday(conf.getJSONArray("delays"), left) * 1000 + left);
// failed
} else {
card.setLeft(_startingLeft(card));
boolean resched = _resched(card);
if (conf.has("mult") && resched) {
// review that's lapsed
card.setIvl(Math.max(Math.max(1, (int) (card.getIvl() * conf.getDouble("mult"))), conf.getInt("minInt")));
} else {
// new card; no ivl adjustment
// pass
}
if (resched && card.getODid() != 0) {
card.setODue(mToday + 1);
}
}
int delay = _delayForGrade(conf, card.getLeft());
if (card.getDue() < getTime().intTime()) {
// not collapsed; add some randomness
delay *= Utils.randomFloatInRange(1f, 1.25f);
}
card.setDue(getTime().intTime() + delay);
// due today?
if (card.getDue() < mDayCutoff) {
mLrnCount += card.getLeft() / 1000;
// if the queue is not empty and there's nothing else to do, make
// sure we don't put it at the head of the queue and end up showing
// it twice in a row
card.setQueue(Consts.QUEUE_TYPE_LRN);
if (!mLrnQueue.isEmpty() && revCount() == 0 && newCount() == 0) {
long smallestDue = mLrnQueue.getFirstDue();
card.setDue(Math.max(card.getDue(), smallestDue + 1));
}
_sortIntoLrn(card.getDue(), card.getId());
} else {
// the card is due in one or more days, so we need to use the day learn queue
long ahead = ((card.getDue() - mDayCutoff) / SECONDS_PER_DAY) + 1;
card.setDue(mToday + ahead);
card.setQueue(Consts.QUEUE_TYPE_DAY_LEARN_RELEARN);
}
}
_logLrn(card, ease, conf, leaving, type, lastLeft);
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class Sched method _getCard.
/**
* Getting the next card ****************************************************
* *******************************************
*/
/**
* Return the next due card, or null.
*/
@Override
@Nullable
protected Card _getCard() {
// learning card due?
@Nullable Card c = _getLrnCard();
if (c != null) {
return c;
}
// new first, or time for one?
if (_timeForNewCard()) {
c = _getNewCard();
if (c != null) {
return c;
}
}
// Card due for review?
c = _getRevCard();
if (c != null) {
return c;
}
// day learning card due?
c = _getLrnDayCard();
if (c != null) {
return c;
}
// New cards left?
c = _getNewCard();
if (c != null) {
return c;
}
// collapse or finish
return _getLrnCard(true);
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class Sched method _rescheduleLapse.
@Override
protected int _rescheduleLapse(@NonNull Card card) {
JSONObject conf;
conf = _lapseConf(card);
card.setLastIvl(card.getIvl());
if (_resched(card)) {
card.setLapses(card.getLapses() + 1);
card.setIvl(_nextLapseIvl(card, conf));
card.setFactor(Math.max(1300, card.getFactor() - 200));
card.setDue(mToday + card.getIvl());
// if it's a filtered deck, update odue as well
if (card.getODid() != 0) {
card.setODue(card.getDue());
}
}
// if suspended as a leech, nothing to do
int delay = 0;
if (_checkLeech(card, conf) && card.getQueue() == Consts.QUEUE_TYPE_SUSPENDED) {
return delay;
}
// if no relearning steps, nothing to do
if (conf.getJSONArray("delays").length() == 0) {
return delay;
}
// record rev due date for later
if (card.getODue() == 0) {
card.setODue(card.getDue());
}
delay = _delayForGrade(conf, 0);
card.setDue(delay + getTime().intTime());
card.setLeft(_startingLeft(card));
// queue 1
if (card.getDue() < mDayCutoff) {
mLrnCount += card.getLeft() / 1000;
card.setQueue(Consts.QUEUE_TYPE_LRN);
_sortIntoLrn(card.getDue(), card.getId());
} else {
// day learn queue
long ahead = ((card.getDue() - mDayCutoff) / SECONDS_PER_DAY) + 1;
card.setDue(mToday + ahead);
card.setQueue(Consts.QUEUE_TYPE_DAY_LEARN_RELEARN);
}
return delay;
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _getCard.
/**
* Getting the next card ****************************************************
* *******************************************
*/
/**
* Return the next due card, or null.
* Overridden: V1 does not allow dayLearnFirst
*/
@Nullable
protected Card _getCard() {
// learning card due?
@Nullable Card c = _getLrnCard();
if (c != null) {
return c;
}
// new first, or time for one?
if (_timeForNewCard()) {
c = _getNewCard();
if (c != null) {
return c;
}
}
// Day learning first and card due?
boolean dayLearnFirst = mCol.getConf().optBoolean("dayLearnFirst", false);
if (dayLearnFirst) {
c = _getLrnDayCard();
if (c != null) {
return c;
}
}
// Card due for review?
c = _getRevCard();
if (c != null) {
return c;
}
// day learning card due?
if (!dayLearnFirst) {
c = _getLrnDayCard();
if (c != null) {
return c;
}
}
// New cards left?
c = _getNewCard();
if (c != null) {
return c;
}
// collapse or finish
return _getLrnCard(true);
}
use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.
the class Collection method addNote.
/**
* Add a note to the collection. Return number of new cards.
*/
public int addNote(Note note) {
// check we have card models available, then save
ArrayList<JSONObject> cms = findTemplates(note);
if (cms.size() == 0) {
return 0;
}
note.flush();
// deck conf governs which of these are used
int due = nextID("pos");
// add cards
int ncards = 0;
for (JSONObject template : cms) {
_newCard(note, template, due);
ncards += 1;
}
return ncards;
}
Aggregations