public override Card GetNextCard(TrialPerformance trialPerformance) { InitCardDataIfNeeded(); if (_previousCardIntervalData != null) { RecordPreviousTrial(trialPerformance); } if (_activeCards.Count <= 0 && _inactiveCards.Count <= 0) { return(null); } if (ShouldActivateNewCard()) // TODO Should this really happen if the user fails? Should we have a staleness metric like back in the good old days? { ActivateNewCard(); } Card nextCard = _activeCards[0].card; _previousCardIntervalData = _activeCards[0]; _activeCards.Remove(_previousCardIntervalData); // TODO slow? return(nextCard); }
private void AddHistoryEntryToDatabase(Card card, TrialPerformance trialPerformance) { int successInt = (int)trialPerformance; // TODO change bool in sqlite database to string version of bool... string insertHistoryEntryQuery = String.Format("insert into CardHistories (DateTime, Success, Card) values ('{0}', {1}, {2})", DateTime.Now.Ticks, successInt, card.ID); ExecuteSimpleQuery(insertHistoryEntryQuery); }
private void RecordPreviousTrial(TrialPerformance trialPerformance) { if (_previousCardIntervalData == null) { throw new InvalidOperationException("Tried to record trial data without first getting a card. GetNextCard first!"); } _previousCardIntervalData = CalculateCardIntervalData(_previousCardIntervalData.card); // HACK HACK FIXME TODO does this even work? int insertAt = 0; for (int i = 0; i < _activeCards.Count; i++) { insertAt = i + 1; // TODO FIXME This is a bug that nicely allows us to not see failed cards twice in a row but schedules things off by one if (_previousCardIntervalData.interval >= _activeCards[i].interval) { continue; } else { break; } } _activeCards.Insert(insertAt, _previousCardIntervalData); _database.AddHistoryEntry(_previousCardIntervalData.card, trialPerformance); }
public CardHistoryEntry[] GetHistory(int cardID) { List <CardHistoryEntry> historyEntries = new List <CardHistoryEntry>(); string getHistoryQuery = string.Format("select * from CardHistories where Card='{0}'", cardID); SQLiteDataReader dataReader = ExecuteReaderQuery(getHistoryQuery); while (dataReader.Read()) { DateTime dateTime = new DateTime(Convert.ToInt64(dataReader["DateTime"])); TrialPerformance trialPerformance = (TrialPerformance)Convert.ToInt32(dataReader["Success"]); var historyEntry = new CardHistoryEntry(dateTime, trialPerformance); historyEntries.Add(historyEntry); } return(historyEntries.ToArray()); }
public abstract Card GetNextCard(TrialPerformance trialPerformance);
public void AddHistoryEntry(TrialPerformance trialPerformance) // TODO Violating SRP? Move history management to another class? { var entry = new CardHistoryEntry(DateTime.Now, trialPerformance); HistoryEntries.Add(entry); }
private void GetNextCard(TrialPerformance trialPerformance) { _currentCard = _myDeck.GetNextCard(_database, trialPerformance); ShowingFront = true; RefreshTextDisplay(); }
public void AddHistoryEntry(Card card, TrialPerformance trialPerformance) { AddHistoryEntryToDatabase(card, trialPerformance); }
public Card GetNextCard(Database database, TrialPerformance trialPerformance) { return(_cardServer.GetNextCard(trialPerformance)); }
public CardHistoryEntry(DateTime entryTime, TrialPerformance trialPerformance) { EntryTime = entryTime; TrialPerformance = trialPerformance; }