コード例 #1
0
        private void finishQuizBtn_Click(object sender, EventArgs e)
        {
            Quiz myQuiz = CreateQuizControlHandler.GetQuiz();

            PrintQuizTemplates.PrintQuizController print = new PrintQuizTemplates.PrintQuizController(CreateQuizControlHandler.GetQuiz());
            MultipleChoiceDataSetTableAdapters.QuizTableAdapter quizTableAdapter = new MultipleChoiceDataSetTableAdapters.QuizTableAdapter();
            quizTableAdapter.InsertNewQuiz(LoginStatusData.userID, myQuiz.GetCreationDate(), myQuiz.GetQuizTitle(), myQuiz.GetSubject_id());
            //myQuiz.SetQuiz_id((int)quizTableAdapter.ReturnLastQuizId());
            int quiz_id = (int)quizTableAdapter.ReturnLastQuizId();

            MultipleChoiceDataSetTableAdapters.QuestionTableAdapter questionTableAdapter = new MultipleChoiceDataSetTableAdapters.QuestionTableAdapter();
            MultipleChoiceDataSetTableAdapters.AnswerTableAdapter   answerTableAdapter   = new MultipleChoiceDataSetTableAdapters.AnswerTableAdapter();
            foreach (Question q in myQuiz.getQuestions())
            {
                //Console.WriteLine(quiz_id);
                questionTableAdapter.InsertQuery(q.GetQuestion(), q.GetCrDate(), q.GetUser_id(), q.GetSubject(), quiz_id);
                q.SetQuestion_id((int)questionTableAdapter.ReturnLastQuestionId());

                foreach (Answer a in q.GetAnswers())
                {
                    answerTableAdapter.InsertNewAnswer(a.GetAnswer(), a.IsCorrect(), q.GetQuestion_id());
                }
            }
            Controls.Clear();
        }
コード例 #2
0
 private void GetAllQuizes()
 {
     quiz = new List <RetreivedQuiz>();
     MultipleChoiceDataSetTableAdapters.QuizTableAdapter     q    = new MultipleChoiceDataSetTableAdapters.QuizTableAdapter();
     MultipleChoiceDataSetTableAdapters.SubjectTableAdapter  sub  = new MultipleChoiceDataSetTableAdapters.SubjectTableAdapter();
     MultipleChoiceDataSetTableAdapters.QuestionTableAdapter ques = new MultipleChoiceDataSetTableAdapters.QuestionTableAdapter();
     foreach (MultipleChoiceDataSet.QuizRow row in q.GetData())
     {
         quiz.Add(new RetreivedQuiz(row.Quiz_id, row.Title, sub.GetSubjectName(row.Subject_id), (int)ques.countQuestions(row.Quiz_id)));
         Console.WriteLine(quiz.Last <RetreivedQuiz>().ToString());
     }
 }