コード例 #1
0
ファイル: DatabaseDetailForm.cs プロジェクト: radtek/Klokan
        private void reevaluateButton_Click(object sender, EventArgs e)
        {
            reevaluateButton.Enabled     = false;
            updateDatabaseButton.Enabled = true;

            points = TableArrayHandling.CountScore(chosenAnswers, correctAnswers);
            pointsValueLabel.Text = points.ToString();

            // draw both chosen and correct answers again
            ResetTableImages();

            FormTableHandling.DrawAnswers(table1PictureBox, chosenAnswers, 0, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(table2PictureBox, chosenAnswers, 1, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(table3PictureBox, chosenAnswers, 2, FormTableHandling.DrawCross, Color.Black);

            FormTableHandling.DrawAnswers(table1PictureBox, correctAnswers, 0, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(table2PictureBox, correctAnswers, 1, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(table3PictureBox, correctAnswers, 2, FormTableHandling.DrawCircle, Color.Red);
        }
コード例 #2
0
ファイル: Evaluator.cs プロジェクト: radtek/Klokan
        /// <summary>
        /// Evaluates answers contained in an image of an answer sheet against a set of correct answers.
        /// </summary>
        /// <param name="sheetFilename">The path to the image containing answers to be evaluated.</param>
        /// <param name="correctAnswers">Correct answers to evaluate against.</param>
        /// <param name="category">The category this sheet belongs to.</param>
        /// <param name="year">The year this sheet belongs to.</param>
        /// <exception cref="InvalidOperationException">Thrown when the correct answers haven't been loaded prior to the execution of this function.</exception>
        public Result Evaluate(string sheetFilename, bool[,,] correctAnswers, string category, int year)
        {
            if (correctAnswers == null)
            {
                throw new InvalidOperationException(Properties.Resources.ExceptionTextCorrectAnswersNotLoaded);
            }

            // get the answers from the sheet
            bool[,,] studentNumberAnswers;
            bool[,,] answers;
            if (ExtractAnswers(sheetFilename, out studentNumberAnswers, out answers) == false)
            {
                return(new Result(true));
            }

            // get the student number
            int studentNumber = StudentTableToNumber(studentNumberAnswers);

            // count the score
            int score = TableArrayHandling.CountScore(answers, correctAnswers);

            return(new Result(year, category, studentNumber, answers, correctAnswers, score, sheetFilename, false));
        }