Exemplo n.º 1
0
        public RepeatSession GetOrGenerateCurrentSession(RepeatSessionType _Type)
        {
            RepeatSession session;

            if (Data.CurrentSessions.TryGetValue(_Type, out session) && session != null)
            {
                return(Data.CurrentSessions[_Type]);
            }

            session = new RepeatSession(_Type);
            Random random = new Random();

            switch (_Type)
            {
            case RepeatSessionType.FULL_REPEAT:
            case RepeatSessionType.FULL_REPEAT_REVERSED:
                foreach (Word word in Data.GetLearntWords().OrderBy(_W => random.Next()))
                {
                    session.AddWord(word);
                }
                break;

            case RepeatSessionType.REPEAT_FORGOTTEN:
                RepeatSession lastFullSession = Data.CompletedSessions.
                                                LastOrDefault(_S => _S.RepeatSessionType == RepeatSessionType.FULL_REPEAT);

                if (lastFullSession == null)
                {
                    return(null);
                }

                foreach (var word in lastFullSession.Words.Where(_W => _W.IsForgotten).OrderBy(_W => random.Next()))
                {
                    session.AddWord(word.English);
                }

                break;

            case RepeatSessionType.DAILY_REPEAT:
                foreach (var word in Data.GetDailyRepeatWords())
                {
                    session.AddWord(word.English);
                }
                break;

            case RepeatSessionType.DAILY_REPEAT_RANDOM:
                foreach (var word in Data.GetDailyRepeatWords().OrderBy(_W => random.Next()))
                {
                    session.AddWord(word.English);
                }
                break;

            case RepeatSessionType.ACTIVE_LEARN:
                return(null);
            }

            Data.CurrentSessions[_Type] = session;
            SaveDataToCache();
            return(session);
        }
Exemplo n.º 2
0
        public RepeatSession GetActiveLearnSession()
        {
            RepeatSession session = new RepeatSession(RepeatSessionType.ACTIVE_LEARN);

            foreach (var word in Data.GetActiveLearnWords())
            {
                session.AddWord(word.English);
            }

            return(session);
        }