use of com.ichi2.anki.CardBrowser.Column.ANSWER in project AnkiChinaAndroid by ankichinateam.
the class SchedTest method test_new_v1.
public void test_new_v1() throws Exception {
Collection col = getColV1();
col.reset();
assertEquals(0, col.getSched().newDue());
// add a note
Note note = col.newNote();
note.setItem("Front", "one");
note.setItem("Back", "two");
col.addNote(note);
col.reset();
assertEquals(1, col.getSched().counts()[0]);
// fetch it
Card c = col.getSched().getCard();
assertNotNull(c);
assertEquals(QUEUE_TYPE_NEW, c.getQueue());
assertEquals(CARD_TYPE_NEW, c.getType());
// if we answer it, it should become a learn card
long t = col.getTime().intTime();
col.getSched().answerCard(c, 1);
assertEquals(QUEUE_TYPE_LRN, c.getQueue());
assertEquals(CARD_TYPE_LRN, c.getType());
assertThat(c.getDue(), is(greaterThanOrEqualTo(t)));
// disabled for now, as the learn fudging makes this randomly fail
// // the default order should ensure siblings are not seen together, and
// // should show all cards
// Model m = col.getModels().current(); Models mm = col.getModels()
// JSONObject t = mm.newTemplate("Reverse")
// t['qfmt'] = "{{Back}}"
// t['afmt'] = "{{Front}}"
// mm.addTemplateModChanged(m, t)
// mm.save(m)
// note = col.newNote()
// note['Front'] = u"2"; note['Back'] = u"2"
// col.addNote(note)
// note = col.newNote()
// note['Front'] = u"3"; note['Back'] = u"3"
// col.addNote(note)
// col.reset()
// qs = ("2", "3", "2", "3")
// for (int n = 0; n < 4; n++) {
// c = col.getSched().getCard()
// assertTrue(qs[n] in c.q())
// col.getSched().answerCard(c, 2)
// }
}
use of com.ichi2.anki.CardBrowser.Column.ANSWER in project Anki-Android by ankidroid.
the class SchedTest method test_new_v1.
public void test_new_v1() throws Exception {
Collection col = getColV1();
col.reset();
assertEquals(0, col.getSched().newCount());
// add a note
Note note = col.newNote();
note.setItem("Front", "one");
note.setItem("Back", "two");
col.addNote(note);
col.reset();
assertEquals(1, col.getSched().counts().getNew());
// fetch it
Card c = getCard();
assertNotNull(c);
assertEquals(QUEUE_TYPE_NEW, c.getQueue());
assertEquals(CARD_TYPE_NEW, c.getType());
// if we answer it, it should become a learn card
long t = col.getTime().intTime();
col.getSched().answerCard(c, BUTTON_ONE);
assertEquals(QUEUE_TYPE_LRN, c.getQueue());
assertEquals(CARD_TYPE_LRN, c.getType());
assertThat(c.getDue(), is(greaterThanOrEqualTo(t)));
// disabled for now, as the learn fudging makes this randomly fail
// // the default order should ensure siblings are not seen together, and
// // should show all cards
// Model m = col.getModels().current(); Models mm = col.getModels()
// JSONObject t = mm.newTemplate("Reverse")
// t['qfmt'] = "{{Back}}"
// t['afmt'] = "{{Front}}"
// mm.addTemplateModChanged(m, t)
// mm.save(m)
// note = col.newNote()
// note['Front'] = u"2"; note['Back'] = u"2"
// col.addNote(note)
// note = col.newNote()
// note['Front'] = u"3"; note['Back'] = u"3"
// col.addNote(note)
// col.reset()
// qs = ("2", "3", "2", "3")
// for (int n = 0; n < 4; n++) {
// c = getCard()
// assertTrue(qs[n] in c.q())
// col.getSched().answerCard(c, 2)
// }
}
use of com.ichi2.anki.CardBrowser.Column.ANSWER in project Anki-Android by ankidroid.
the class SchedV2Test method test_counts_idxV2.
@Test
public void test_counts_idxV2() throws Exception {
Collection col = getColV2();
Note note = col.newNote();
note.setItem("Front", "one");
note.setItem("Back", "two");
col.addNote(note);
col.reset();
assertEquals(new Counts(1, 0, 0), col.getSched().counts());
Card c = getCard();
// counter's been decremented but idx indicates 1
assertEquals(new Counts(0, 0, 0), col.getSched().counts());
assertEquals(NEW, col.getSched().countIdx(c));
// answer to move to learn queue
col.getSched().answerCard(c, BUTTON_ONE);
assertEquals(new Counts(0, 1, 0), col.getSched().counts());
// fetching again will decrement the count
c = getCard();
assertEquals(new Counts(0, 0, 0), col.getSched().counts());
assertEquals(LRN, col.getSched().countIdx(c));
// answering should add it back again
col.getSched().answerCard(c, BUTTON_ONE);
assertEquals(new Counts(0, 1, 0), col.getSched().counts());
}
use of com.ichi2.anki.CardBrowser.Column.ANSWER in project Anki-Android by ankidroid.
the class AbstractFlashcardViewer method answerCard.
protected void answerCard(@Consts.BUTTON_TYPE int ease) {
if (mInAnswer) {
return;
}
mIsSelecting = false;
int buttonNumber = getCol().getSched().answerButtons(mCurrentCard);
// Detect invalid ease for current card (e.g. by using keyboard shortcut or gesture).
if (buttonNumber < ease) {
return;
}
// Temporarily sets the answer indicator dots appearing below the toolbar
mPreviousAnswerIndicator.displayAnswerIndicator(ease, buttonNumber);
mSoundPlayer.stopSounds();
mCurrentEase = ease;
new SchedulerService.AnswerAndGetCard(mCurrentCard, mCurrentEase).runWithHandler(answerCardHandler(true));
}
use of com.ichi2.anki.CardBrowser.Column.ANSWER in project Anki-Android by ankidroid.
the class AbstractFlashcardViewer method displayCardQuestion.
protected void displayCardQuestion(boolean reload) {
Timber.d("displayCardQuestion()");
sDisplayAnswer = false;
mBackButtonPressedToReturn = false;
setInterface();
mTypeAnswer.setInput("");
mTypeAnswer.updateInfo(mCurrentCard, getResources());
if (!mCurrentCard.isEmpty() && mTypeAnswer.validForEditText()) {
// Show text entry based on if the user wants to write the answer
mAnswerField.setVisibility(View.VISIBLE);
LanguageHintService.applyLanguageHint(mAnswerField, mTypeAnswer.getLanguageHint());
} else {
mAnswerField.setVisibility(View.GONE);
}
CardHtml content = mHtmlGenerator.generateHtml(mCurrentCard, reload, Side.FRONT);
updateCard(content);
hideEaseButtons();
mAutomaticAnswer.onDisplayQuestion();
// If Card-based TTS is enabled, we "automatic display" after the TTS has finished as we don't know the duration
if (!mTTS.isEnabled()) {
mAutomaticAnswer.scheduleAutomaticDisplayAnswer(mUseTimerDynamicMS);
}
Timber.i("AbstractFlashcardViewer:: Question successfully shown for card id %d", mCurrentCard.getId());
}
Aggregations