コード例 #1
0
ファイル: Quiz.cs プロジェクト: petergolde/VirtualEmily
 public void RecordAnswer(Question question, bool correct)
 {
     question.RecordAnswer(correct);
 }
コード例 #2
0
ファイル: Quiz.cs プロジェクト: petergolde/VirtualEmily
        public void LoadAnswers(TermKind from, TermKind to)
        {
            FromTerm = from;
            ToTerm = to;

            questions.Clear();
            string[] input = new string[0];

            if (File.Exists(AnswerDataFileName)) {
                input = File.ReadAllLines(AnswerDataFileName);
            }

            for (int i = 0; i < questionData.Count; ++i) {
                QuestionData qd = questionData[i];
                Question q = new Question();

                GetQuestionAnswerData(from, qd, out q.QuestionStyle, out q.QuestionString);
                GetQuestionAnswerData(to, qd, out q.AnswerStyle, out q.AnswerString);

                if (i < input.Length) {
                    q.LoadAnswers(input[i]);
                }

                questions.Add(q);
            }
        }
コード例 #3
0
ファイル: Quiz.cs プロジェクト: petergolde/VirtualEmily
        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;
        }