}//End saveAndReturnToDashboardMenuItem_Click //--------------------UTILITY METHODS-------------------// /// <summary> /// The purpose of this method is to initialize all working variables /// when the form loads, or if it is reused without closing. /// </summary> private void initializeVariables() { //Get the current date time string for the cumulative results file currentDatetimeStr = DateTime.Now.ToString("yyyyMMddhhmm"); // Set/Reset incorrectAnswerNumStr incorrectAnswerNumStr = ""; // Get the initial count of correct answers numCorrectAnswers = AnswerQuestionsDataModel.getNumCorrectAnswers(); }// End initializeVariables
}// End answerQuestions() /// <summary> /// The purpose of this method is to save the results of an exam to /// the FileNameScores file and the culutative results file /// It is called by: /// 1. /// </summary> private void updateExamData() { double originalQuestionsNumInt = AnswerQuestionsDataModel.getNumCorrectAnswers(); string currentCorrectNumAnswersStr = numCorrectAnswers.ToString(); string orriginalNumOfQuestions = originalQuestionsNumInt.ToString(); string outputNumCorrectStr = $"{currentCorrectNumAnswersStr} out of {orriginalNumOfQuestions} were Correct!"; double originalQuestions = AnswerQuestionsDataModel.getNumCorrectAnswers(); double percentCorrect = (numCorrectAnswers / originalQuestionsNumInt) * 100; string percentCorrectStr = String.Format("{0:00.0}", percentCorrect); QAFileNameScoresModel.updateQAFileNameScoresExamResults(keyToQAFileNameScoresDictionary, outputNumCorrectStr); // Create cumulativeResultsOutputStr string cumulativeResultsOutputStr = currentDatetimeStr + ":" + percentCorrectStr + ":" + incorrectAnswerNumStr + "~"; QACumulativeResultsModel.updateCumulativeresultsDictionary(keyIntStr + "q", cumulativeResultsOutputStr); }// End updateExamData