예제 #1
0
        }     // End QuestionAndAnswerForm_Load

        /// <summary>
        /// This method is called if the QA form's open QA file menu option is clicked
        /// It uses an open file dialog to get the file path to the desired qa file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openQAFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = @"C:\Users\Owner\OneDrive\Documents\Learning\_CSharpQAFiles\QAFiles";
            // Open qa File if it has data and create the qaDictionary
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                qaFilePath = ofd.FileName;
                AnswerQuestionsDataModel.setQAFilePath(qaFilePath);
                // Determine if the file exists
                if (File.Exists(qaFilePath))
                {
                    // Determine if there are data in the file and if so read it into the dictionary
                    var  fil    = new FileInfo(qaFilePath);
                    long length = fil.Length;
                    if (length != 0)
                    {
                        // Load File into dictionary
                        AnswerQuestionsDataModel.loadQAFileIntoDictionary(qaFilePath);
                        // Get dictionary
                        qaDictionary = AnswerQuestionsDataModel.QandADictionary;
                    }
                    else
                    {
                        // If the file exists, but is blank
                        // Get a blank dictionary
                        qaDictionary             = AnswerQuestionsDataModel.QandADictionary;
                        questionNumberValue.Text = qaDictionary.Count.ToString();
                        questionValue.Select();
                    }
                } // EndOpen qa File if it has data and create the qaDictionary
            }     // End Open file dialogue
        }         // End openQAFileToolStripMenuItem_Click
예제 #2
0
        }//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
예제 #3
0
        }// End quizToolStripMenuItem1_Click

        /// <summary>
        /// /The Question sequence Seriatim menu option clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void seriatimToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // questionSequenceSeriatem is already true
            questionSequenceSet         = true;
            delimitedQuestionNumbersStr = AnswerQuestionsDataModel.getQAList();
            if (questionSequenceSet && testTypeSet)
            {
                answerQuestions();
            }
        }// End seriatimToolStripMenuItem_Click
예제 #4
0
        }         // End openQAFileToolStripMenuItem_Click

        /// <summary>
        /// Called when the File-> Save file and Return to dashboard menu option is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveFileAndReturnToDashboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // send the current local value of the qaDictionary to QAFileDataModel's QandADictionary
            AnswerQuestionsDataModel.QandADictionary = qaDictionary;
            AnswerQuestionsDataModel.saveQAFile();
            this.Hide();
            this.Close();
            QADashboard dashboardForm = new QADashboard();

            dashboardForm.ShowDialog();
        }// End saveFileAndReturnToDashboardToolStripMenuItem_Click
예제 #5
0
        }// 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
예제 #6
0
        //--------------------------EVENT METHODS----------------------------------//

        /// <summary>
        /// This Method: 1) Opens a local copy of the qaDictionary
        ///     1.  If it is called as a result of using the QA Tree form's Create/Edit button
        ///         then the qaFileNameString is the file name.
        ///         a.  If the retrieved qaFilePath is blank and new dictionary is called else
        ///         b.  The dictionary associated with an extant qaFile is loadee
        ///     2.  If it is called by Openeing the form from the dashboard then the qaFileNameString
        ///         is blank and the method is skipped
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void QuestionAndAnswerForm_Load(object sender, EventArgs e)
        {
            string qaFileNameString = AnswerQuestionsDataModel.getQAFileNameStr();

            if (qaFileNameString != "")
            {
                string qaFilePath = AnswerQuestionsDataModel.getQAFilePath();
                if (qaFilePath == "")
                {
                    // Get a blank dictionary
                    qaDictionary             = AnswerQuestionsDataModel.QandADictionary;
                    questionNumberValue.Text = qaDictionary.Count.ToString();
                    questionValue.Select();
                    return;
                }
                AnswerQuestionsDataModel.loadQAFileIntoDictionary(AnswerQuestionsDataModel.getQAFilePath());
                qaDictionary = AnswerQuestionsDataModel.QandADictionary;
                selectEditTypeLable.Visible = true;
            } //End if (qaFileNameString != "")
        }     // End QuestionAndAnswerForm_Load
예제 #7
0
        }// End initializeVariables

        private void answerQuestions()
        {
            if (delimitedQuestionNumbersStr.Length == 0)
            {
                if (testTypeExam)
                {
                    updateExamData();
                }
                resetLocalVariables();

                // This is the last question
                instructionsLabel.Text = "This is the last question Save file and return to Dashboard or Repeat the Exercise!";

                return;
            }

            Tuple <int, string> currentValueTuple = AnswerQuestionsDataModel.returnDelimitedValue(delimitedQuestionNumbersStr);
            int currentQuestionNumInt             = currentValueTuple.Item1;

            currentQuestionNumStr       = currentQuestionNumInt.ToString();
            questionNumberValue.Text    = currentQuestionNumStr;
            delimitedQuestionNumbersStr = currentValueTuple.Item2;

            // get currentQALine
            string qaLine = AnswerQuestionsDataModel.currentQALine(currentQuestionNumInt);

            // example 0^When did Aristotle live?^384-322 BCE^^
            string[] qaComponentsArray = qaLine.Split('^');
            currentQuestion = qaComponentsArray[0];
            string newLine = Environment.NewLine;

            currentQuestion           = currentQuestion.Replace("~", newLine);
            correctAnswer             = qaComponentsArray[1];
            correctAnswer             = correctAnswer.Replace("~", newLine);
            currentImageURL           = qaComponentsArray[2];
            currentMp3URL             = qaComponentsArray[3];
            currentQuestionValue.Text = currentQuestion;
            currentQuestionValue.Focus();
        }// End answerQuestions()
예제 #8
0
        /// <summary>
        /// This form can be called from the QATreeForm's
        /// takeQAFileTestButton_Click( method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AnswerQuestionsForm_Load(object sender, EventArgs e)
        {
            string qaFilePath = AnswerQuestionsDataModel.getQAFilePath();
            // Get the int value at the end of the name
            string tempQAFilePathName = qaFilePath.Substring(0, qaFilePath.Length - 4);

            char[] tempQAFilePathNameArray = tempQAFilePathName.ToCharArray();
            keyIntStr = "";
            char lastChar = tempQAFilePathNameArray[tempQAFilePathNameArray.Length - 1];

            while (Char.IsDigit(lastChar))
            {
                keyIntStr = lastChar + keyIntStr;
                Array.Resize(ref tempQAFilePathNameArray, tempQAFilePathNameArray.Length - 1);
                lastChar = tempQAFilePathNameArray[tempQAFilePathNameArray.Length - 1];
            }
            // Convert this value to an integer
            keyToQAFileNameScoresDictionary = Int32.Parse(keyIntStr);

            AnswerQuestionsDataModel.loadQAFileIntoDictionary(qaFilePath);
            // Call initializeVariables() to initialize local variables
            initializeVariables();
        }// End void AnswerQuestionsForm_Load(