Beispiel #1
0
        /// <summary>Answer current card and fetch next one.</summary>
        /// <param name="grade">Answer grade</param>
        /// <returns>Whether any cards are available</returns>
        /// <exception cref="System.InvalidOperationException">No card available (Current is null).</exception>
        public Task <bool> AnswerAsync(Grade grade)
        {
            // Card sanity check
            Card card = Current;

            if (card == null)
            {
                throw new InvalidOperationException("Card unavailable");
            }

            // Compute evaluation time & create review log
            ReviewLog log = CreateLog(card);

            // Answer
            NextAction[CurrentList] = () => CurrentList.MoveNextAsync();
            CurrentList             = null;

            CardAction cardAction = card.Answer(grade);

            // Complete log with updated values
            CompleteLog(log, card, grade);

            // If this was a new card, add to learning list
            if (log.LastState == PracticeState.New)
            {
                ReviewCollectionLearn.AddManual(card);
            }

#pragma warning disable 4014
            // Save changes to Database
            UpdateCardAsync(log, card, cardAction);
#pragma warning restore 4014

            ReviewCollectionNew.DismissSiblings(card);
            ReviewCollectionLearn.DismissSiblings(card);
            ReviewCollectionDue.DismissSiblings(card);

            return(DoNextAsync());
        }