Esempio n. 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();
        }
Esempio n. 2
0
        private void SaveLastQuestion()
        {
            lastQuestionBool = true;
            List <Answer> ans = getAnswers();
            Quiz          myq = CreateQuizControlHandler.GetQuiz();

            lastQuestion = new Question(questionNameTextBox.Text, myq.GetUser_id(), myq.GetSubject_id(), myq.GetCreationDate());
            foreach (Answer an in ans)
            {
                lastQuestion.AddAnswer(an);
            }
        }
Esempio n. 3
0
        //ορίζουμε την παρακάτω μέθοδο που καλείται όταν πατηθεί ένα από τα κουμπιά που μετακινούν τα panel
        private void movePanelsBtn_Click(object sender, EventArgs e)
        {
            //ως tag ορίζουμε την κίνηση των panel που θα γίνει(τιμές που παίρνει: -5,5)
            panelPos = Convert.ToInt32(((Button)sender).Tag);
            //ξεχωρίζουμε τα button που κάλεσαν το event για περαιτέρω επεξεργασία(αποθήκευση τιμών κλπ)
            string name = ((Button)sender).Name;

            if (name.Equals("stepOneNextBtn"))
            {
                int s_id;
                try
                {
                    s_id = (int)tagTreeView.SelectedNode.Tag;
                }
                catch
                {
                    s_id = 0;
                }
                if (quizNameTextBox.Text != "" && s_id > 0)
                {
                    //αν είναι κενό το όνομα δεν συνεχίζεται

                    CreateQuizControlHandler.SetQuiz(quizNameTextBox.Text, s_id, Login.Login.userID);
                    SetEnabledPanels(1);
                }
            }
            else if (name.Equals("backBtn"))
            {
                if (MessageBox.Show("Do you want to delete this QUIZ ?", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    CreateQuizControlHandler.SetQuiz();
                    currentQuestion = 0;
                    NewEmptyQuestion();
                    CheckQuestionNum();
                    lastQuestion     = new Question();
                    lastQuestionBool = false;
                    SetEnabledPanels(0);
                }
            }
            else if (name.Equals("finishQuestionsBtn"))
            {
                if (FinishButton())
                {
                    SetEnabledPanels(2);
                }
            }
            else if (name.Equals("backBtn2"))
            {
                SetEnabledPanels(1);
            }
        }
Esempio n. 4
0
 public void prevQBtn_click(object sender, EventArgs e)
 {
     if (currentQuestion > CreateQuizControlHandler.CountQuests())
     {
         SaveLastQuestion();
     }
     else
     {
         CreateQuizControlHandler.ChangeQuestionIn(currentQuestion - 1, questionNameTextBox.Text, getAnswers());
     }
     currentQuestion -= 1;
     CheckQuestionNum();
     SetQuestionPanelVar(CreateQuizControlHandler.GetQuestion(currentQuestion - 1).GetQuestion(), CreateQuizControlHandler.GetQuestion(currentQuestion - 1).GetAnswers(), currentQuestion);
 }
Esempio n. 5
0
        private void NewEmptyQuestion()
        {
            int allQ = CreateQuizControlHandler.CountQuests();

            if (allQ <= currentQuestion)
            {
                if (currentQuestion != allQ)
                {
                    CreateQuizControlHandler.AddNewQuestion(questionNameTextBox.Text, getAnswers());
                }
                currentQuestion += 1;
                List <Answer> nullAns = new List <Answer>();
                SetQuestionPanelVar("", nullAns, currentQuestion);
            }
        }
Esempio n. 6
0
        public void nextQBtn_Click(object sender, EventArgs e)
        {
            int allQ = CreateQuizControlHandler.CountQuests();

            CreateQuizControlHandler.ChangeQuestionIn(currentQuestion - 1, questionNameTextBox.Text, getAnswers());
            currentQuestion += 1;
            CheckQuestionNum();
            if (currentQuestion > allQ)
            {
                SetQuestionPanelVar(lastQuestion.GetQuestion(), lastQuestion.GetAnswers(), currentQuestion);
            }
            else
            {
                SetQuestionPanelVar(CreateQuizControlHandler.GetQuestion(currentQuestion - 1).GetQuestion(), CreateQuizControlHandler.GetQuestion(currentQuestion - 1).GetAnswers(), currentQuestion);
            }
        }
Esempio n. 7
0
        public void deleteQBtn_Click(object sender, EventArgs e)
        {
            int allQ = CreateQuizControlHandler.CountQuests();

            if (allQ != 0)
            {
                if (allQ < currentQuestion)
                {
                    lastQuestionBool = false;
                    lastQuestion     = new Question();
                    currentQuestion -= 1;
                }
                else
                {
                    currentQuestion -= 1;
                    CreateQuizControlHandler.RemoveQuestion(currentQuestion);
                }
                if (currentQuestion == 0)
                {
                    currentQuestion = 1;
                    if (allQ <= 1)
                    {
                        if (!lastQuestionBool)
                        {
                            List <Answer> nullAns = new List <Answer>();
                            SetQuestionPanelVar("", nullAns, 1);
                        }
                        else
                        {
                            SetQuestionPanelVar(lastQuestion.GetQuestion(), lastQuestion.GetAnswers(), currentQuestion);
                        }
                    }
                    else
                    {
                        Console.WriteLine("asd");
                        SetQuestionPanelVar(CreateQuizControlHandler.GetQuestion(currentQuestion - 1).GetQuestion(), CreateQuizControlHandler.GetQuestion(currentQuestion - 1).GetAnswers(), currentQuestion);
                    }
                }
                else
                {
                    SetQuestionPanelVar(CreateQuizControlHandler.GetQuestion(currentQuestion - 1).GetQuestion(), CreateQuizControlHandler.GetQuestion(currentQuestion - 1).GetAnswers(), currentQuestion);
                }
                CheckQuestionNum();
            }
        }
Esempio n. 8
0
        private bool FinishButton()
        {
            int allQ = CreateQuizControlHandler.CountQuests();

            if (MessageBox.Show("Do you want to finish this QUIZ ?", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (allQ < currentQuestion)
                {
                    SaveLastQuestion();
                    List <Answer> ans = getAnswers();
                    if (ans.Count == 0 || !ListIsCompleted(getAnswers()) || questionNameTextBox.Text == "")
                    {
                        MessageBox.Show("Please don't leave empty spaces");
                        return(false);
                    }
                    CreateQuizControlHandler.AddNewQuestion(lastQuestion.GetQuestion(), ans);
                }
                return(true);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 9
0
        private void CheckQuestionNum()
        {
            Console.WriteLine(lastQuestionBool);
            int allQ = CreateQuizControlHandler.CountQuests();

            Console.WriteLine(allQ + " " + currentQuestion);
            if (allQ == 0)
            {
                prevQuBtn.Enabled = false;
                nextQuBtn.Enabled = false;
            }
            else if (currentQuestion > allQ)
            {
                prevQuBtn.Enabled = true;
                nextQuBtn.Enabled = false;
            }
            else
            {
                if (currentQuestion == allQ)
                {
                    nextQuBtn.Enabled = lastQuestionBool;
                }
                else
                {
                    nextQuBtn.Enabled = true;
                }
                if (currentQuestion == 1)
                {
                    prevQuBtn.Enabled = false;
                }
                else
                {
                    prevQuBtn.Enabled = true;
                }
            }
        }