Beispiel #1
0
        public void grade()
        {
            Result    = "";
            Incorrect = 0;
            Correct   = 0;
            Wrong.Clear();

            string[] exam = new string[] { "B", "D", "A", "A", "C", "A", "B", "A", "C", "D", "B", "C", "D", "A", "D", "C", "C", "B", "D", "A" };
            if (input == "")
            {
                Result = "You should input right files!";
                return;
            }
            string text = File.ReadAllText(input);

            string[] answer = text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < exam.Length; i++)
            {
                string student_ans = answer[i];
                string exam_ans    = exam[i];
                if (student_ans == exam_ans)
                {
                    Correct++;
                }
                else
                {
                    Incorrect++;
                    Answer ans = new Answer();
                    ans.select = exam_ans;
                    int j = i + 1;
                    ans.number = j.ToString();
                    Wrong.Add(ans);
                }
            }

            if (Correct >= 15)
            {
                Result = "Congratulation! You are PASS!";
            }
            else
            {
                Result = "Sorry! You are FAIL!";
            }
        }
Beispiel #2
0
 private void AddWrongAnswers_Executed(object arg)
 {
     QDocument.ActivatedObject = Wrong;
     Wrong.Add("");
 }