private void btnGrade_Click(object sender, EventArgs e)
        {
            if (sender != null)
            {
                DialogResult dialogResult = MessageBox.Show("Do you want to exit and submit this test?", "Submit Test", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }
            ShowLoading();
            try
            {
                List <bool> points    = null;
                string      className = ("Checker." + this.Test.OfficeApp + "." + this.Test.Name + "_" + this.Test.OfficeVersion).Replace(" ", "_");

                switch (this.Test.OfficeApp)
                {
                case "Word":
                    BaseWordTest     wordTestChecker = this.CreateTestChecker(className) as BaseWordTest;
                    Word.Application wordApp         = this.Application as Word.Application;
                    Word.Document    document        = wordApp.ActiveDocument;
                    document.Save();

                    wordTestChecker.Document = document;
                    points = wordTestChecker.Points;

                    break;

                case "Excel":
                    Excel.Application excelApp = Application as Excel.Application;
                    excelApp.ActiveWorkbook.Close(true);

                    string        themeXmlContent  = Checker.Utils.Excel.GetThemeXmlContent(WorkingFilePaths());
                    BaseExcelTest excelTestChecker = this.CreateTestChecker(className) as BaseExcelTest;
                    excelTestChecker.ThemeXmlContent = themeXmlContent;

                    LoadFileOffice();
                    excelTestChecker.Workbook = (Application as Excel.Application).ActiveWorkbook;
                    points = excelTestChecker.Points;

                    break;

                case "PowerPoint":
                    break;
                }

                int correctedQuestions = points.FindAll(x => x == true).Count;
                this.Task.IsCompleted = true;
                this.Task.UsedTime    = this.ucTimer.Current;
                this.Task.Points.Add(points);
                double score = Math.Min(Math.Ceiling((double)(correctedQuestions * (1000f / points.Count))), 1000f);
                this.Task.Score = Convert.ToInt32(score);
                Repository.updateTask(this.Task);
                CloseLoading();
                MessageBox.Show($"Your Score: {this.Task.Score}\nCorrected Tasks: {correctedQuestions}/{points.Count}", "Your Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                log.Error("Grade - " + Test.ToString());
            }
        }
        private void btnGrade_Click(object sender, EventArgs e)
        {
            if (sender != null)
            {
                DialogResult dialogResult = MessageBox.Show("Do you want to exit and submit this test?", "Submit Test", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            ShowLoading();
            string correctedTasksPerProject = "";
            float  scorePerProject          = 1000f / this.Projects.Count;
            float  score = 0;

            try
            {
                switch (this.Test.OfficeApp)
                {
                case "Word":
                    Word.Application application = this.Application as Word.Application;
                    if (application.Documents.Count > 0)
                    {
                        application.ActiveDocument.Close(Word.Enums.WdSaveOptions.wdSaveChanges);
                    }

                    for (int i = 1; i <= this.Projects.Count; ++i)
                    {
                        float scorePerTask = scorePerProject / (this.Projects[i - 1].Count - 1);

                        string       className   = ("Checker." + this.Test.OfficeApp + "." + "Project_" + i.ToString() + "_" + this.Test.Name + "_" + this.Test.OfficeVersion).Replace(" ", "_");
                        BaseWordTest testChecker = this.CreateTestChecker(className) as BaseWordTest;

                        Word.Document document = application.Documents.Open(this.WorkingFilePaths(i - 1));
                        testChecker.Document = document;

                        var points = testChecker.Points;
                        this.Task.Points.Add(points);

                        score += scorePerTask * points.FindAll(x => x == true).Count;
                        correctedTasksPerProject += "\nProject " + i.ToString() + ": " + points.FindAll(x => x == true).Count.ToString() + "/" + points.Count.ToString();
                    }
                    break;

                case "Excel":
                    break;

                case "PowerPoint":
                    break;
                }

                this.Task.Score       = Convert.ToInt32(Math.Min(Math.Ceiling(score), 1000f));
                this.Task.IsCompleted = true;
                this.Task.UsedTime    = this.ucTimer.Current;

                Repository.updateTask(this.Task);
                CloseLoading();

                MessageBox.Show($"Your Score: {this.Task.Score}\n" + correctedTasksPerProject, "Your Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                log.Error("Grade - " + Test.ToString());
            }
        }