Example #1
0
        public Card Generate(Card card)
        {
            card.Id           = TimeGenerator.RandomId(CardIds);
            card.LastModified = Math.Max(card.Id, TimeGenerator.RandomTime());

            bool          lapsing;
            PracticeState state;

            ComputeNextCardType(out state, out lapsing);

            switch (state)
            {
            case PracticeState.Due:
                DueCount--;
                return(SetupDueCard(card, lapsing));

            case PracticeState.Learning:
                LearnCount--;
                return(SetupLearningCard(card, lapsing));

            case PracticeState.New:
                NewCount--;
                return(SetupNewCard(card));
            }

            throw new InvalidOperationException();
        }
Example #2
0
        private Card SetupLearningCard(Card card, bool lapsing)
        {
            card.PracticeState = PracticeState.Learning;
            card.Due           = TimeGenerator.RandomTime(card.LearningOrLapsingSteps.Last());

            if (lapsing)
            {
                SetupLapse(card);
                SetupSpacedRepetitionDatas(card);
            }

            return(card);
        }
Example #3
0
        private Card SetupDueCard(Card card, bool lapsing)
        {
            card.PracticeState = PracticeState.Due;
            card.Due           = Math.Max(card.Id, TimeGenerator.RandomTime());

            if (lapsing)
            {
                SetupLapse(card);
            }

            SetupSpacedRepetitionDatas(card);

            return(card);
        }