示例#1
0
        private void discardButton_Click(object sender, EventArgs e)
        {
            ResetTableImages();

            // draw the original answers
            FormTableHandling.DrawAnswers(studentTablePictureBox, expectedValuesStudentTable, 0, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable1PictureBox, expectedValuesAnswerTable, 0, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable2PictureBox, expectedValuesAnswerTable, 1, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable3PictureBox, expectedValuesAnswerTable, 2, FormTableHandling.DrawCross, Color.Black);

            bool[,,] computedValuesStudentTable;
            bool[,,] computedValuesAnswerTable;

            List <KlokanTestDBComputedAnswer> computedValues = new List <KlokanTestDBComputedAnswer>(scanItem.ComputedValues);

            TableArrayHandling.DbSetToAnswers(computedValues, out computedValuesStudentTable, out computedValuesAnswerTable);

            FormTableHandling.DrawAnswers(studentTablePictureBox, computedValuesStudentTable, 0, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable1PictureBox, computedValuesAnswerTable, 0, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable2PictureBox, computedValuesAnswerTable, 1, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable3PictureBox, computedValuesAnswerTable, 2, FormTableHandling.DrawCircle, Color.Red);

            editButton.Enabled    = true;
            applyButton.Enabled   = false;
            discardButton.Enabled = false;
            viewMode = true;
        }
示例#2
0
        /// <summary>
        /// Gets data from the scan item field and shows it.
        /// </summary>
        private void PopulateForm()
        {
            // load scan
            scanPictureBox.Image = ImageHandling.GetBitmap(scanItem.Image);

            // load the answers
            List <KlokanTestDBExpectedAnswer> expectedValues = new List <KlokanTestDBExpectedAnswer>(scanItem.ExpectedValues);

            TableArrayHandling.DbSetToAnswers(expectedValues, out expectedValuesStudentTable, out expectedValuesAnswerTable);

            FormTableHandling.DrawAnswers(studentTablePictureBox, expectedValuesStudentTable, 0, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable1PictureBox, expectedValuesAnswerTable, 0, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable2PictureBox, expectedValuesAnswerTable, 1, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable3PictureBox, expectedValuesAnswerTable, 2, FormTableHandling.DrawCross, Color.Black);

            bool[,,] computedValuesStudentTable;
            bool[,,] computedValuesAnswerTable;

            List <KlokanTestDBComputedAnswer> computedValues = new List <KlokanTestDBComputedAnswer>(scanItem.ComputedValues);

            TableArrayHandling.DbSetToAnswers(computedValues, out computedValuesStudentTable, out computedValuesAnswerTable);

            FormTableHandling.DrawAnswers(studentTablePictureBox, computedValuesStudentTable, 0, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable1PictureBox, computedValuesAnswerTable, 0, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable2PictureBox, computedValuesAnswerTable, 1, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable3PictureBox, computedValuesAnswerTable, 2, FormTableHandling.DrawCircle, Color.Red);
        }
示例#3
0
 private void studentTablePictureBox_Click(object sender, EventArgs e)
 {
     if (!viewMode)
     {
         FormTableHandling.HandleTableImageClicks(e as MouseEventArgs, studentTablePictureBox, 0, expectedValuesStudentTableTemp);
     }
 }
示例#4
0
 private void answerTable3PictureBox_Click(object sender, EventArgs e)
 {
     if (!viewMode)
     {
         FormTableHandling.HandleTableImageClicks(e as MouseEventArgs, answerTable3PictureBox, 2, expectedValuesAnswerTableTemp);
     }
 }
示例#5
0
 private void table3PictureBox_Click(object sender, EventArgs e)
 {
     // if in edit mode
     if (editButton.Enabled == false)
     {
         FormTableHandling.HandleTableImageClicks(e as MouseEventArgs, table3PictureBox, 2, chosenAnswersTemp);
     }
 }
示例#6
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            if (addMode && (scanFilePath == null || scanFilePath == ""))
            {
                MessageBox.Show(Properties.Resources.ErrorTextNoFileSelected, Properties.Resources.ErrorCaptionGeneral,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!TableArrayHandling.CheckAnswers(expectedValuesStudentTableTemp, 0))
            {
                MessageBox.Show(Properties.Resources.ErrorTextStudentNumberNotSelected, Properties.Resources.ErrorCaptionGeneral,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            for (int i = 0; i < 3; i++)
            {
                if (!TableArrayHandling.CheckAnswers(expectedValuesAnswerTableTemp, i))
                {
                    MessageBox.Show(Properties.Resources.ErrorTextExpectedAnswersNotSelected, Properties.Resources.ErrorCaptionGeneral,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            // apply the changes
            expectedValuesStudentTable = expectedValuesStudentTableTemp;
            expectedValuesAnswerTable  = expectedValuesAnswerTableTemp;

            // draw the computed answers for comparison (if there are any)
            bool[,,] computedValuesStudentTable;
            bool[,,] computedValuesAnswerTable;

            List <KlokanTestDBComputedAnswer> computedValues = new List <KlokanTestDBComputedAnswer>(scanItem.ComputedValues);

            TableArrayHandling.DbSetToAnswers(computedValues, out computedValuesStudentTable, out computedValuesAnswerTable);

            FormTableHandling.DrawAnswers(studentTablePictureBox, computedValuesStudentTable, 0, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable1PictureBox, computedValuesAnswerTable, 0, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable2PictureBox, computedValuesAnswerTable, 1, FormTableHandling.DrawCircle, Color.Red);
            FormTableHandling.DrawAnswers(answerTable3PictureBox, computedValuesAnswerTable, 2, FormTableHandling.DrawCircle, Color.Red);

            updateButton.Enabled  = true;
            editButton.Enabled    = true;
            applyButton.Enabled   = false;
            discardButton.Enabled = false;
            viewMode = true;
        }
示例#7
0
        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);
        }
示例#8
0
        private void discardButton_Click(object sender, EventArgs e)
        {
            applyButton.Enabled   = false;
            discardButton.Enabled = false;
            editButton.Enabled    = true;

            studentNumberTextBox.Hide();
            studentNumberValueLabel.Show();

            // draw the original answers
            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);
        }
示例#9
0
        private void editButton_Click(object sender, EventArgs e)
        {
            viewMode              = false;
            applyButton.Enabled   = true;
            discardButton.Enabled = true;
            updateButton.Enabled  = false;
            editButton.Enabled    = false;

            ResetTableImages();

            // draw only the expected answers because only those can be edited
            FormTableHandling.DrawAnswers(studentTablePictureBox, expectedValuesStudentTable, 0, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable1PictureBox, expectedValuesAnswerTable, 0, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable2PictureBox, expectedValuesAnswerTable, 1, FormTableHandling.DrawCross, Color.Black);
            FormTableHandling.DrawAnswers(answerTable3PictureBox, expectedValuesAnswerTable, 2, FormTableHandling.DrawCross, Color.Black);

            // create a copy of currently chosen answers for editing
            expectedValuesStudentTableTemp = new bool[1, 5, 10];
            Array.Copy(expectedValuesStudentTable, expectedValuesStudentTableTemp, 1 * 5 * 10);

            expectedValuesAnswerTableTemp = new bool[3, 8, 5];
            Array.Copy(expectedValuesAnswerTable, expectedValuesAnswerTableTemp, 3 * 8 * 5);
        }
示例#10
0
        /// <param name="categoryBatch">
        /// The batch needs to have a name set, so that it can be displayed in this form.
        /// The batch is then going to be edited in this form and changes will be saved if the DialogResult is OK.
        /// </param>
        public CategoryEditForm(KlokanCategoryBatch categoryBatch)
        {
            InitializeComponent();

            formCaptionBase    = this.Text;
            sheetLabelTextBase = sheetLabel.Text;

            this.Text       = formCaptionBase + " (" + categoryBatch.CategoryName + ")";
            sheetLabel.Text = sheetLabelTextBase + " (0):";

            this.categoryBatch = categoryBatch;

            // show the content of the batch if there is something there already,
            if (categoryBatch.CorrectAnswers != null)
            {
                correctAnswers = categoryBatch.CorrectAnswers;

                FormTableHandling.DrawAnswers(table1PictureBox, correctAnswers, 0, FormTableHandling.DrawCross, Color.Black);
                FormTableHandling.DrawAnswers(table2PictureBox, correctAnswers, 1, FormTableHandling.DrawCross, Color.Black);
                FormTableHandling.DrawAnswers(table3PictureBox, correctAnswers, 2, FormTableHandling.DrawCross, Color.Black);
            }
            // otherwise initialize default values
            else
            {
                correctAnswers = new bool[3, 8, 5];
            }

            if (categoryBatch.SheetFilenames != null && categoryBatch.SheetFilenames.Count > 0)
            {
                answerSheetFilenames           = categoryBatch.SheetFilenames;
                answerSheetsListBox.DataSource = answerSheetFilenames;
            }
            else
            {
                answerSheetFilenames = new List <string>();
            }
        }
示例#11
0
        private void editButton_Click(object sender, EventArgs e)
        {
            editButton.Enabled           = false;
            applyButton.Enabled          = true;
            discardButton.Enabled        = true;
            reevaluateButton.Enabled     = false;
            updateDatabaseButton.Enabled = false;

            // make the student number field editable
            studentNumberTextBox.Text = studentNumber.ToString();
            studentNumberValueLabel.Hide();
            studentNumberTextBox.Show();

            // draw only chosen answers as only those can be edited
            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);

            // create a copy of currently chosen answers for editing
            chosenAnswersTemp = new bool[3, 8, 5];
            Array.Copy(chosenAnswers, chosenAnswersTemp, 3 * 8 * 5);
        }
示例#12
0
        /// <summary>
        /// Extract answer sheet data from the database and display it in the form.
        /// Returns false if data could not be loaded.
        /// </summary>
        private bool PopulateForm()
        {
            using (var db = new KlokanDBContext())
            {
                // load sheet data
                var sheetQuery = from sheet in db.AnswerSheets
                                 where sheet.AnswerSheetId == answerSheetId
                                 select sheet;

                KlokanDBAnswerSheet answerSheet = sheetQuery.FirstOrDefault();
                if (answerSheet == null)
                {
                    MessageBox.Show(Properties.Resources.ErrorTextSheetNotFoundInDatabase, Properties.Resources.ErrorCaptionGeneral,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                var instanceQuery = from instance in db.Instances
                                    where instance.InstanceId == answerSheet.InstanceId
                                    select instance;

                KlokanDBInstance currentInstance = instanceQuery.FirstOrDefault();
                if (answerSheet == null)
                {
                    MessageBox.Show(Properties.Resources.ErrorTextSheetNotFoundInDatabase, Properties.Resources.ErrorCaptionGeneral,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                studentNumber = answerSheet.StudentNumber;

                // show sheet data
                studentNumberValueLabel.Text = answerSheet.StudentNumber.ToString();
                idValueLabel.Text            = answerSheet.AnswerSheetId.ToString();
                yearValueLabel.Text          = currentInstance.Year.ToString();
                categoryValueLabel.Text      = currentInstance.Category.ToString();
                pointsValueLabel.Text        = answerSheet.Points.ToString();

                // load scan
                scanPictureBox.Image = ImageHandling.GetBitmap(answerSheet.Scan);

                // load answers and draw them
                var chosenAnswersQuery = from chosenAnswer in db.ChosenAnswers
                                         where chosenAnswer.AnswerSheetId == answerSheetId
                                         select chosenAnswer;

                var chosenAnswersList = chosenAnswersQuery.ToList();
                if (chosenAnswersList.Count == 0)
                {
                    MessageBox.Show(Properties.Resources.ErrorTextSheetNotFoundInDatabase, Properties.Resources.ErrorCaptionGeneral,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                TableArrayHandling.DbSetToAnswers(chosenAnswersList, out chosenAnswers);

                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);

                var correctAnswersQuery = from correctAnswer in db.CorrectAnswers
                                          where correctAnswer.InstanceId == answerSheet.InstanceId
                                          select correctAnswer;

                var correctAnswersList = correctAnswersQuery.ToList();
                if (correctAnswersList.Count == 0)
                {
                    MessageBox.Show(Properties.Resources.ErrorTextSheetNotFoundInDatabase, Properties.Resources.ErrorCaptionGeneral,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                TableArrayHandling.DbSetToAnswers(correctAnswersQuery.ToList(), out correctAnswers);

                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);
            }

            return(true);
        }
示例#13
0
 private void table3PictureBox_Click(object sender, EventArgs e)
 {
     FormTableHandling.HandleTableImageClicks(e as MouseEventArgs, table3PictureBox, 2, correctAnswers);
 }