/*
         * Starts the test set with the given information.
         * If the files are read successfully, starts the test.
         * Otherwise, displays an error dialog.
         */
        private void startTestSet(Info.CategoryInfo categoryInfo, Info.TestSetInfo testSetInfo, int numRounds, int numQuestionsPerRound)
        {
            // Read the test set
            TestSet testSet = TestFileReader.readTestSet(categoryInfo, testSetInfo);

            // If the test set files were read successfully
            if (testSet != null)
            {
                // Remove the bad questions
                testSet.removeIncompleteOrInvalidQuestions();

                // Randomize the questions
                testSet.randomizeQuestions();

                // Calculate the total number of questions
                int numQuestions = numRounds * numQuestionsPerRound;

                // If there are enough questions in the test set
                if (numQuestions <= testSet.numQuestionsAvailable())
                {
                    // Set the number of rounds and questions
                    testSet.numRounds            = numRounds;
                    testSet.numQuestionsPerRound = numQuestionsPerRound;

                    // Go to the test start page
                    contentWindow.Content = new TestStartPage(contentWindow, testSet);
                }

                // If there are not enough questions in the test set
                else
                {
                    MessageBox.Show(
                        "Only " + testSet.numQuestionsAvailable() + " questions are available for \"" + testSetInfo.testSetStringLong + "\"." +
                        " You have selected " + numQuestions + " questions.",
                        "Not Enough Questions Available",
                        MessageBoxButton.OK,
                        MessageBoxImage.Warning
                        );

                    updatePage();
                    setDefaults(categoryInfo, testSetInfo);
                }
            }

            // If the test set files were not read
            else
            {
                MessageBox.Show(
                    "The test files for \"" + testSetInfo.testSetStringLong + "\" could not be found." +
                    "\n\nMake sure that the test files are located in the Tests folder." +
                    " If this error persists, redownload the application.",
                    "Test Files Not Found",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error
                    );

                updatePage();
                setDefaults(categoryInfo);
            }
        }
        /*
         * Constructor.
         */
        public TestScorePage(Window contentWindow, TestSet testSet)
        {
            InitializeComponent();

            this.contentWindow = contentWindow;
            this.testSet       = testSet;

            updatePage();
        }
        /*
         * Constructor.
         */
        public TestQuestionPage(Window contentWindow, TestSet testSet)
        {
            InitializeComponent();

            this.contentWindow       = contentWindow;
            this.testSet             = testSet;
            this.currentTestQuestion = null;

            this.testSet.currentRoundQuestionIndex = 0;

            updatePage();
        }
Exemple #4
0
        /*
         * Constructor.
         */
        public TestAnswerPage(Window contentWindow, TestSet testSet, bool onlyShowWrongAnswers)
        {
            InitializeComponent();

            this.contentWindow        = contentWindow;
            this.testSet              = testSet;
            this.currentTestQuestion  = null;
            this.onlyShowWrongAnswers = onlyShowWrongAnswers;

            this.testSet.currentRoundQuestionIndex = 0;

            updatePage();
        }