Beispiel #1
0
 public JobScheduler(KlokanBatch batch, ProgressDialog progressDialog)
 {
     this.batch          = batch;
     testBatch           = null;
     this.progressDialog = progressDialog;
 }
Beispiel #2
0
 public JobScheduler(TestKlokanBatch testBatch, ProgressDialog progressDialog)
 {
     batch               = null;
     this.testBatch      = testBatch;
     this.progressDialog = progressDialog;
 }
Beispiel #3
0
        private void evaluateButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(Properties.Resources.PromptTextEvaluationStart, Properties.Resources.PromptCaptionEvaluationStart,
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            List <TestKlokanInstance> testInstances = new List <TestKlokanInstance>();

            // get all available test instances
            using (var testDB = new KlokanTestDBContext())
            {
                var allScansQuery = from scan in testDB.Scans
                                    select scan;

                foreach (var scan in allScansQuery)
                {
                    bool[,,] studentExpectedValues;
                    bool[,,] answerExpectedValues;
                    TableArrayHandling.DbSetToAnswers(new List <KlokanTestDBExpectedAnswer>(scan.ExpectedValues), out studentExpectedValues, out answerExpectedValues);

                    TestKlokanInstance testInstance = new TestKlokanInstance {
                        ScanId = scan.ScanId,
                        Image  = scan.Image,
                        StudentExpectedValues = studentExpectedValues,
                        AnswerExpectedValues  = answerExpectedValues
                    };

                    testInstances.Add(testInstance);
                }
            }

            if (testInstances.Count == 0)
            {
                MessageBox.Show(Properties.Resources.InfoTextNoTestItems, Properties.Resources.InfoCaptionNoTestItems,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            TestKlokanBatch testBatch = new TestKlokanBatch {
                Parameters    = chosenParameters,
                TestInstances = testInstances
            };

            ProgressDialog progressDialog = new ProgressDialog(new CancellationTokenSource());

            progressDialog.SetProgressLabel(ProgressBarState.Evaluating);

            var jobScheduler = new JobScheduler(testBatch, progressDialog);

            // new thread created, so that all tasks in it are planned in the threadpool and not in the WinForms synchronization context
            Thread thread = new Thread(jobScheduler.Run);

            thread.IsBackground = true;
            thread.Start();

            progressDialog.StartPosition = FormStartPosition.CenterScreen;
            progressDialog.ShowDialog();

            PopulateDataView();
            ShowAverageCorrectness();
        }