/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1); Apps app = AppInstance.app; if (app.Type.Contains("Spellings")) { puzzle = SpellingsModel.getInstance(); ScoreText.Text = "You have completed the Spellings Puzzle: " + puzzle.getPuzzleName(); TotalCorrect.Text = "Total Correct: " + puzzle.getTotalCorrect(); TotalWrong.Text = "Total Wrong: " + puzzle.getTotalWrong(); TotalUnanswered.Text = "Total Unanswered: " + (puzzle.getSpellingsList().Count - (puzzle.getTotalWrong() + puzzle.getTotalCorrect())); SpellingsModel.clearInstance(); } else if (app.Type.Contains("Quiz")) { quiz = QuizModel.getInstance(); ScoreText.Text = "You have completed the Quiz: " + quiz.getQuizName(); TotalCorrect.Text = "Total Correct: " + quiz.getTotalCorrect(); TotalWrong.Text = "Total Wrong: " + quiz.getTotalWrong(); TotalUnanswered.Text = "Total Unanswered: " + (quiz.getQueAnsList().Count - (quiz.getTotalWrong() + quiz.getTotalCorrect())); QuizModel.clearInstance(); } this.navigationHelper.OnNavigatedTo(e); }
/// <summary> /// It reads the Quiz App-Template, from the .buildmlearn file. /// </summary> /// <param name="fileName">Name of the file</param> public static void readQuizFile(string fileName) { try { QuizModel model = QuizModel.getInstance(); List <Question> mQuestionList = new List <Question>(); XmlDocument doc = new XmlDocument(); doc.LoadXml(XDocument.Load("Assets/Apps/" + fileName + ".xml").ToString()); model.setQuizName(doc.GetElementsByTagName("title").ElementAt(0).InnerText.Trim()); model.setQuizDescription(doc.GetElementsByTagName("description").ElementAt(0).InnerText.Trim()); string[] author = doc.GetElementsByTagName("author").ElementAt(0).InnerText.Split('\n'); model.setQuizAuthor(author[1].Trim()); model.setQuizAuthorEmail(author[2].Trim()); model.setQuizVersion(doc.GetElementsByTagName("version").ElementAt(0).InnerText.Trim()); XmlNodeList questions = doc.GetElementsByTagName("item"); for (int i = 0; i < questions.Length; i++) { Question q = new Question(); string[] ar = questions.ElementAt(i).InnerText.Split('\n'); List <string> options = new List <string>(); options.Add(ar[2].Trim()); options.Add(ar[3].Trim()); options.Add(ar[4].Trim()); options.Add(ar[5].Trim()); q.setOptionNumber(Convert.ToInt16(ar[6].Trim())); q.setAnswerOption(options); q.setQuestion(ar[1].Trim()); mQuestionList.Add(q); } model.setQueAnsList(mQuestionList); } catch (Exception) { } }