Beispiel #1
0
        /// <summary>
        /// handles save click event.
        /// Prompts user for conformation and then saves and goes back to quizzes vies
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Are you sure you want to save changes to this quiz?", "Saving", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                //if first time were saving this quiz, we need to add it to the course as well
                bool addToCourse = (GlobalData.currentQuiz.Id == 0);

                //save it first
                QuizController.SaveQuiz(GlobalData.currentQuiz);

                //now add it to course if we determined it was first save
                if (addToCourse)
                {
                    CourseController.AddQuiz(GlobalData.currentCourse, GlobalData.currentQuiz);
                }

                //now delete all questions that are no longer part of this quiz
                foreach (QuestionData qDelete in questionsToDeleteOnSave)
                {
                    QuestionController.DeleteQuestion(qDelete);
                }

                //return to quizzes view
                GoBackToQuizzesView();
            }
        }