public void StartTest() { Shuffle(questions.QuestionsList); currentQuesIndex = 0; if (questions.QuestionsList.Count > 0) { CallBackMy.ShowQuestionEventHendler(questions.QuestionsList[currentQuesIndex], currentQuesIndex + 1, (QuestionLimit > questions.QuestionsList.Count ? questions.QuestionsList.Count : QuestionLimit)); } }
public void Next() { currentQuesIndex += 1; if (currentQuesIndex < questions.QuestionsList.Count && currentQuesIndex < QuestionLimit) { if (CallBackMy.ShowQuestionEventHendler != null) { CallBackMy.ShowQuestionEventHendler(questions.QuestionsList[currentQuesIndex], currentQuesIndex + 1, (QuestionLimit > questions.QuestionsList.Count?questions.QuestionsList.Count:QuestionLimit)); } } else { if (CallBackMy.ShowTestResult != null) { CallBackMy.ShowTestResult(Student.Name, Student.Group, ValidAnswer, (QuestionLimit > questions.QuestionsList.Count ? questions.QuestionsList.Count : QuestionLimit) - ValidAnswer); } } }
public void LoadQuestions(string path) { this.path = path; Question question = null; _inLoad = true; try { document.Load(path); Decrypt(Create3DES("MyPasswword"), document); XmlNode captionNode = document.DocumentElement.Attributes.GetNamedItem("caption"); if (captionNode != null) { caption = captionNode.Value; if (SetTestNameHandler != null) { SetTestNameHandler(caption); } } XmlNode questionlimitNode = document.DocumentElement.Attributes.GetNamedItem("questionlimit"); if (questionlimitNode != null) { int res = 10; if (Int32.TryParse(questionlimitNode.Value, out res)) { QuestionLimit = res; } else { QuestionLimit = 10; } if (SetQuestionLimitHandler != null) { SetQuestionLimitHandler(QuestionLimit); } } foreach (XmlNode node in document.DocumentElement) { foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "text") { question = questions.Add(childNode.InnerText); } if (childNode.Name == "answers") { foreach (XmlNode answerNode in childNode.ChildNodes) { if (answerNode.Name == "answer") { XmlNode attr = answerNode.Attributes.GetNamedItem("verity"); if (attr != null && question != null) { question.Add(answerNode.InnerText, bool.Parse(attr.Value)); } } } } } } if (CallBackMy.AddFormCaptionEnentHandler != null) { CallBackMy.AddFormCaptionEnentHandler(path); } _inLoad = false; } catch (XmlException e) { Console.WriteLine(e.ToString()); } }