Example #1
0
        protected override void PrepareWord()
        {
            Random      rnd         = new Random();
            List <Word> newWordList = new List <Word>();

            foreach (var word in LessonWordsAll.OrderBy(x => rnd.Next()).Take(5))
            {
                newWordList.Add(Word.CopyFrom(word));
            }
            if (LessonWords.Count > 0)
            {
                int index = rnd.Next(LessonWords.Count());
                CurrentWord = Word.CopyFrom(LessonWords[index]);
                LessonWords.RemoveAt(index);
                if (!newWordList.Contains(CurrentWord))
                {
                    newWordList.Add(CurrentWord);
                }
            }
            CurrentWordsToChoose.Clear();
            foreach (Word w in newWordList.OrderBy(item => rnd.Next()))
            {
                CurrentWordsToChoose.Add(w);
            }
        }
 protected override void PrepareWord()
 {
     CurrentWordToEdit = "";
     if (LessonWords.Count > 0)
     {
         Random rnd   = new Random();
         int    index = rnd.Next(LessonWords.Count());
         CurrentWord = Word.CopyFrom(LessonWords[index]);
         LessonWords.RemoveAt(index);
     }
 }
Example #3
0
 private void StartActualLesson()
 {
     StartStopButtonText = "Stop";
     ShowLessonPanel     = true;
     ShowResultPanel     = true;
     IsLessonRunning     = true;
     LessonStartingTime  = DateTime.Now;
     LessonDispatcherTimer.Start();
     using (var db = Database.Instance.GetConnection())
     {
         LessonWords.Clear();
         LessonWordsAll.Clear();
         CurrentUserLessonHistory.Clear();
         foreach (Word w in db.Table <Word>().Where(w => w.LessonId == CurrentLesson.Id))
         {
             LessonWords.Add(w);
             LessonWordsAll.Add(w);
             var     fetchedHistory = db.Table <History>().Where(h => h.UserId == CurrentUser.Id && h.WordId == w.Id);
             History wordHistory    = null;
             if (fetchedHistory.Count() == 0)
             {
                 wordHistory = new History()
                 {
                     UserId = CurrentUser.Id, WordId = w.Id
                 };
             }
             else
             {
                 wordHistory = fetchedHistory.First();
             }
             CurrentUserLessonHistory[w] = wordHistory;
         }
     }
     PrepareWord();
     CorrectAnswers = 0;
     SkippedAnswers = 0;
     WrongAnswers   = 0;
 }