Example #1
0
 //method clear all list boxes ansd labels
 public void ClearAllText()
 {
     CorrectAnswerData.Clear();
     StudentAnswerData.Clear();
     IncorrectAnswerData.Clear();
     Result         = "";
     CorrectMarks   = "";
     IncorrectMarks = "";
     LabelColor     = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
 }
Example #2
0
        //method Compare two sets of question from saved files and show result
        public void Compare()
        {
            if (selectedFileName == "")
            {
                MessageBox.Show("Please Select a sample file");
                return;
            }
            else
            {
                string[] correctAnswerDataArray = File.ReadAllLines("correctAnswer.txt");
                string[] studentAnswerDataArray = File.ReadAllLines(selectedFileName);
                int      correctcount           = 0;
                int      incorrectcount         = 0;

                for (int i = 0; i < correctAnswerDataArray.Length; i++)
                {
                    CorrectAnswerData.Add(correctAnswerDataArray[i]);
                    StudentAnswerData.Add(studentAnswerDataArray[i]);
                    if (correctAnswerDataArray[i] == studentAnswerDataArray[i])
                    {
                        correctcount++;
                    }
                    else
                    {
                        incorrectcount++;
                        string[] spliteElementArray = studentAnswerDataArray[i].Split('.');
                        IncorrectAnswerData.Add(spliteElementArray[0]);
                    }
                }
                if (correctcount < PASSING_MARK)
                {
                    Result     = $"Sorry you didn't pass the exam.";
                    LabelColor = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
                }
                else
                {
                    Result     = $"Congratulations!! You have passed the exam.";
                    LabelColor = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
                }
                CorrectMarks   = $"Total number of correct answers= {correctcount}";
                IncorrectMarks = $"Total number of incorrect answers= {incorrectcount}";
            }
        }