Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
 public abstract Card GetNextCard(TrialPerformance trialPerformance);
Ejemplo n.º 6
0
        public void AddHistoryEntry(TrialPerformance trialPerformance) // TODO Violating SRP? Move history management to another class?
        {
            var entry = new CardHistoryEntry(DateTime.Now, trialPerformance);

            HistoryEntries.Add(entry);
        }
Ejemplo n.º 7
0
 private void GetNextCard(TrialPerformance trialPerformance)
 {
     _currentCard = _myDeck.GetNextCard(_database, trialPerformance);
     ShowingFront = true;
     RefreshTextDisplay();
 }
Ejemplo n.º 8
0
 public void AddHistoryEntry(Card card, TrialPerformance trialPerformance)
 {
     AddHistoryEntryToDatabase(card, trialPerformance);
 }
Ejemplo n.º 9
0
 public Card GetNextCard(Database database, TrialPerformance trialPerformance)
 {
     return(_cardServer.GetNextCard(trialPerformance));
 }
Ejemplo n.º 10
0
 public CardHistoryEntry(DateTime entryTime, TrialPerformance trialPerformance)
 {
     EntryTime        = entryTime;
     TrialPerformance = trialPerformance;
 }