Exemplo n.º 1
0
        public Question NextQuestion()
        {
            QuizStats      stats       = CalcStats();
            Question       newQuestion = null;
            QuestionStatus targetStatus;
            int            targetIndex;
            int            count = 20;

            do
            {
                if (stats.CountRight > 0 && random.NextDouble() < 0.3)
                {
                    // 30% chance to review one we know.
                    targetStatus = QuestionStatus.Right;
                    targetIndex  = random.Next(stats.CountRight);
                }
                else if (stats.CountWrong + stats.CountPartial < 3 && stats.CountUnseen > 0 && random.NextDouble() < 0.5)
                {
                    // If we have < 3 that we don't know, add a new one in.
                    targetStatus = QuestionStatus.NotSeen;
                    targetIndex  = random.Next(stats.CountUnseen);
                }
                else if (random.Next(2 * stats.CountWrong + stats.CountPartial) < 2 * stats.CountWrong)
                {
                    // Choose a question we don't know yet, with wrong weighted twice as partial.
                    targetStatus = QuestionStatus.Wrong;
                    targetIndex  = random.Next(stats.CountWrong);
                }
                else
                {
                    targetStatus = QuestionStatus.Partial;
                    targetIndex  = random.Next(stats.CountPartial);
                }

                foreach (Question q in questions)
                {
                    QuestionStatus status = q.Status;
                    if (status == targetStatus)
                    {
                        if (targetIndex == 0)
                        {
                            newQuestion = q;
                            break;
                        }
                        else
                        {
                            --targetIndex;
                        }
                    }
                }

                if (newQuestion == null)
                {
                    newQuestion = questions[random.Next(questions.Count)];
                }
            } while (newQuestion == lastQuestion && count-- > 0);  // Don't repeat the same question in a row unless we must.

            lastQuestion = newQuestion;
            return(newQuestion);
        }
Exemplo n.º 2
0
 private void UpdateStatusGrid(QuizStats stats)
 {
     statusGrid.ColumnDefinitions[0].Width = new GridLength(stats.CountUnseen, GridUnitType.Star);
     statusGrid.ColumnDefinitions[1].Width = new GridLength(stats.CountWrong, GridUnitType.Star);
     statusGrid.ColumnDefinitions[2].Width = new GridLength(stats.CountPartial, GridUnitType.Star);
     statusGrid.ColumnDefinitions[3].Width = new GridLength(stats.CountRight, GridUnitType.Star);
 }
Exemplo n.º 3
0
        void Done()
        {
            quizGrid.Visibility = Visibility.Hidden;
            doneGrid.Visibility = Visibility.Visible;
            QuizStats stats = quiz.CalcStats();

            resultsText.Text = string.Format("Known: {0}\r\nPartially Known: {1}\r\nNot known: {2}\r\nNot seen: {3}", stats.CountRight, stats.CountPartial, stats.CountWrong, stats.CountUnseen);
        }
Exemplo n.º 4
0
        public QuizStats CalcStats()
        {
            QuizStats stats = new QuizStats();

            foreach (Question q in questions) {
                QuestionStatus status = q.Status;
                switch (status) {
                    case QuestionStatus.NotSeen: stats.CountUnseen++; break;
                    case QuestionStatus.Wrong: stats.CountWrong++; break;
                    case QuestionStatus.Partial: stats.CountPartial++; break;
                    case QuestionStatus.Right: stats.CountRight++; break;
                }
            }

            stats.Total = questions.Count;
            return stats;
        }
Exemplo n.º 5
0
        void PresentNextQuestion()
        {
            if (timeLimit != default(TimeSpan) && DateTime.Now > finishTime)
            {
                Done();
                return;
            }

            quiz.SaveAnswers();

            QuizStats stats = quiz.CalcStats();

            UpdateStatusGrid(stats);

            // statusLabel.Content = string.Format("{0} of {1} known", stats.CountRight, stats.Total);

            question = quiz.NextQuestion();

            ShowQuestion();
            AllowAnswerEntry();
        }
Exemplo n.º 6
0
        public QuizStats CalcStats()
        {
            QuizStats stats = new QuizStats();

            foreach (Question q in questions)
            {
                QuestionStatus status = q.Status;
                switch (status)
                {
                case QuestionStatus.NotSeen: stats.CountUnseen++; break;

                case QuestionStatus.Wrong: stats.CountWrong++; break;

                case QuestionStatus.Partial: stats.CountPartial++; break;

                case QuestionStatus.Right: stats.CountRight++; break;
                }
            }

            stats.Total = questions.Count;
            return(stats);
        }