Esempio n. 1
0
        private void Save_Click(object sender, EventArgs e)
        {
            if (isTextboxEmpty())
            {
                MessageBox.Show("Vul eerst de lege velden in voordat u opslaat");
            }
            else
            {
                foreach (Panel p in questionFlowPanel.Controls)
                {
                    Question question = new Question();
                    string panelName = splitString(p.Name, true);

                    if (panelName == "multipleChoicePanel")
                    {
                        int questionType = 2;

                        switch (p.Controls.Count)
                        {
                            case 11:
                                questionType = 2;
                                break;
                            case 14:
                                questionType = 3;
                                break;
                            case 17:
                                questionType = 4;
                                break;
                            case 20:
                                questionType = 5;
                                break;
                            case 23:
                                questionType = 6;
                                break;
                        }
                        foreach (Control c in p.Controls)
                        {
                            string controlName = splitString(c.Name, true);
                            int controlNumber = Int32.Parse(splitString(c.Name, false));
                            if (controlName == "QuestionTextbox")
                            {
                                question = new Question(controlNumber, c.Text, questionType, questionlist);
                            }
                            if (controlName == "Answer1Textbox")
                            {
                                Control radioButton = null;
                                Boolean radioButtonValue = false;
                                foreach (Control cont in p.Controls)
                                {
                                    string contName = splitString(cont.Name, true);
                                    if (contName == "Answer1Radiobutton")
                                    {
                                        radioButton = cont;
                                    }
                                }
                                radioButtonValue = (radioButton as RadioButton).Checked;
                                Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue);
                                question.addOption(questionOption);
                            }
                            if (controlName == "Answer2Textbox")
                            {
                                Control radioButton = null;
                                Boolean radioButtonValue = false;
                                foreach (Control cont in p.Controls)
                                {
                                    string contName = splitString(cont.Name, true);
                                    if (contName == "Answer2Radiobutton")
                                    {
                                        radioButton = cont;
                                    }
                                }
                                radioButtonValue = (radioButton as RadioButton).Checked;
                                Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue);
                                question.addOption(questionOption);
                            }
                            if (controlName == "Answer3Textbox")
                            {
                                Control radioButton = null;
                                Boolean radioButtonValue = false;
                                foreach (Control cont in p.Controls)
                                {
                                    string contName = splitString(cont.Name, true);
                                    if (contName == "Answer3Radiobutton")
                                    {
                                        radioButton = cont;
                                    }
                                }
                                radioButtonValue = (radioButton as RadioButton).Checked;
                                Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue);
                                question.addOption(questionOption);
                            }
                            if (controlName == "Answer4Textbox")
                            {
                                Control radioButton = null;
                                Boolean radioButtonValue = false;
                                foreach (Control cont in p.Controls)
                                {
                                    string contName = splitString(cont.Name, true);
                                    if (contName == "Answer4Radiobutton")
                                    {
                                        radioButton = cont;
                                    }
                                }
                                radioButtonValue = (radioButton as RadioButton).Checked;
                                Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue);
                                question.addOption(questionOption);
                            }
                            if (controlName == "Answer5Textbox")
                            {
                                Control radioButton = null;
                                Boolean radioButtonValue = false;
                                foreach (Control cont in p.Controls)
                                {
                                    string contName = splitString(cont.Name, true);
                                    if (contName == "Answer5Radiobutton")
                                    {
                                        radioButton = cont;
                                    }
                                }
                                radioButtonValue = (radioButton as RadioButton).Checked;
                                Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue);
                                question.addOption(questionOption);
                            }
                            if (controlName == "Answer6Textbox")
                            {
                                Control radioButton = null;
                                Boolean radioButtonValue = false;
                                foreach (Control cont in p.Controls)
                                {
                                    string contName = splitString(cont.Name, true);
                                    if (contName == "Answer6Radiobutton")
                                    {
                                        radioButton = cont;
                                    }
                                }
                                radioButtonValue = (radioButton as RadioButton).Checked;
                                Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue);
                                question.addOption(questionOption);
                            }
                        }
                    }
                    if (panelName == "openQuestionPanel")
                    {
                        foreach (Control c in p.Controls)
                        {
                            string controlName = splitString(c.Name, true);
                            int controlNumber = Int32.Parse(splitString(c.Name, false));
                            if (controlName == "QuestionTextbox")
                            {
                                question = new Question(controlNumber, c.Text, 0, questionlist);
                            }
                            if (controlName == "AnswerTextbox")
                            {
                                Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, true);
                                question.addOption(questionOption);
                            }
                        }
                    }
                    if (panelName == "thesisPanel")
                    {
                        foreach (Control c in p.Controls)
                        {
                            string controlName = splitString(c.Name, true);
                            int controlNumber = Int32.Parse(splitString(c.Name, false));
                            if (controlName == "QuestionTextbox")
                            {
                                question = new Question(controlNumber, c.Text, 1, questionlist);
                            }
                            if (controlName == "Answer1Textbox")
                            {
                                Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, false);
                                question.addOption(questionOption);
                            }
                            if (controlName == "Answer2Textbox")
                            {
                                Questionoption questionOption = new Questionoption(2, c.Text, controlNumber, false);
                                question.addOption(questionOption);
                            }
                        }
                    }
                    bc.qc.create(question);
                }
                MessageBox.Show("Uw vragenlijst is toegevoegt");
                bc.cc.setOverviewPanel();
            }
        }
Esempio n. 2
0
        //save button
        public void SaveAll_Click(object sender, EventArgs e)
        {
            int AmountOfQuestions = bc.qc.getQuestions(index).Count();
            if (combobox.SelectedIndex == 0)
            {
                if (string.IsNullOrWhiteSpace(QuestionName.Text))
                {
                    MessageBox.Show("Vul eerst een vraag in");
                }
                else if (string.IsNullOrWhiteSpace(AnswerOpenQuestionTextbox.Text))
                {
                    MessageBox.Show("Vul eerst een antwoord in");
                }
                else
                {
                    question = new Question(AmountOfQuestions + 1, QuestionName.Text, 0, index);
                    Questionoption questionOption = new Questionoption(1, AnswerOpenQuestionTextbox.Text, AmountOfQuestions + 1, true);
                    question.addOption(questionOption);
                    bc.qc.create(question);
                    MessageBox.Show("De vraag is toegevoegd");
                    bc.qc.editListPanel(index);
                }
            }
            else if (combobox.SelectedIndex == 1)
            {
                if (string.IsNullOrWhiteSpace(QuestionName.Text))
                {
                    MessageBox.Show("Vul eerst een vraag in");
                }
                else if (string.IsNullOrWhiteSpace(Answer1TextboxThesis.Text) || string.IsNullOrWhiteSpace(Answer2TextboxThesis.Text))
                {
                    MessageBox.Show("Vul eerst een antwoord in");
                }
                else
                {
                    AmountOfQuestions += 1;
                    question = new Question(AmountOfQuestions + 1, QuestionName.Text, 1, index);
                    Questionoption questionOption = new Questionoption(1, Answer1TextboxThesis.Text, AmountOfQuestions, false);
                    question.addOption(questionOption);

                    Questionoption questionOption1 = new Questionoption(1, Answer2TextboxThesis.Text, AmountOfQuestions, false);
                    question.addOption(questionOption1);

                    bc.qc.create(question);
                    MessageBox.Show("De stelling is toegevoegd");
                    bc.qc.editListPanel(index);
                }
            }
            else if (combobox.SelectedIndex == 2)
            {
                if (string.IsNullOrWhiteSpace(QuestionName.Text))
                {
                    MessageBox.Show("Vul eerst een vraag in");
                }
                else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text))
                {
                    MessageBox.Show("Vul eerst alle antwoorden in");
                }
                else
                {
                    if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked)
                    {
                        AmountOfQuestions += 1;
                        question = new Question(AmountOfQuestions + 1, QuestionName.Text, 2, index);

                        Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked);
                        question.addOption(questionOption1);

                        Questionoption questionOption2 = new Questionoption(2, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked);
                        question.addOption(questionOption2);

                        bc.qc.create(question);
                        MessageBox.Show("De vraag is toegevoegd");
                        bc.qc.editListPanel(index);
                    }
                    else
                    {
                        MessageBox.Show("Selecteer eerst een juist antwoord");
                    }

                }
            }
            else if (combobox.SelectedIndex == 3)
            {
                if (string.IsNullOrWhiteSpace(QuestionName.Text))
                {
                    MessageBox.Show("Vul eerst een vraag in");
                }
                else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text) || string.IsNullOrWhiteSpace(Answer3Textbox.Text))
                {
                    MessageBox.Show("Vul eerst alle antwoorden in");
                }
                else
                {
                    if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked || Answer3Radiobuttons.Checked)
                    {
                        AmountOfQuestions += 1;
                        question = new Question(AmountOfQuestions + 1, QuestionName.Text, 3, index);

                        Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked);
                        question.addOption(questionOption1);

                        Questionoption questionOption2 = new Questionoption(1, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked);
                        question.addOption(questionOption2);

                        Questionoption questionOption3 = new Questionoption(1, Answer3Textbox.Text, AmountOfQuestions, Answer3Radiobuttons.Checked);
                        question.addOption(questionOption3);

                        bc.qc.create(question);
                        MessageBox.Show("De vraag is toegevoegd");
                        bc.qc.editListPanel(index);
                    }
                    else
                    {
                        MessageBox.Show("Selecteer eerst een juist antwoord");
                    }

                }
            }
            else if (combobox.SelectedIndex == 4)
            {
                if (string.IsNullOrWhiteSpace(QuestionName.Text))
                {
                    MessageBox.Show("Vul eerst een vraag in");
                }
                else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text) || string.IsNullOrWhiteSpace(Answer3Textbox.Text) || string.IsNullOrWhiteSpace(Answer4Textbox.Text))
                {
                    MessageBox.Show("Vul eerst alle antwoorden in");
                }
                else
                {
                    if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked || Answer3Radiobuttons.Checked || Answer4Radiobuttons.Checked)
                    {
                        AmountOfQuestions += 1;
                        question = new Question(AmountOfQuestions + 1, QuestionName.Text, 4, index);

                        Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked);
                        question.addOption(questionOption1);

                        Questionoption questionOption2 = new Questionoption(1, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked);
                        question.addOption(questionOption2);

                        Questionoption questionOption3 = new Questionoption(1, Answer3Textbox.Text, AmountOfQuestions, Answer3Radiobuttons.Checked);
                        question.addOption(questionOption3);

                        Questionoption questionOption4 = new Questionoption(1, Answer4Textbox.Text, AmountOfQuestions, Answer4Radiobuttons.Checked);
                        question.addOption(questionOption4);

                        bc.qc.create(question);
                        MessageBox.Show("De vraag is toegevoegd");
                        bc.qc.editListPanel(index);
                    }
                    else
                    {
                        MessageBox.Show("Selecteer eerst een juist antwoord");
                    }

                }
            }
            else if (combobox.SelectedIndex == 5)
            {
                if (string.IsNullOrWhiteSpace(QuestionName.Text))
                {
                    MessageBox.Show("Vul eerst een vraag in");
                }
                else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text) || string.IsNullOrWhiteSpace(Answer3Textbox.Text) || string.IsNullOrWhiteSpace(Answer4Textbox.Text) || string.IsNullOrWhiteSpace(Answer5Textbox.Text))
                {
                    MessageBox.Show("Vul eerst alle antwoorden in");
                }
                else
                {
                    if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked || Answer3Radiobuttons.Checked || Answer4Radiobuttons.Checked || Answer5Radiobuttons.Checked)
                    {
                        AmountOfQuestions += 1;
                        question = new Question(AmountOfQuestions + 1, QuestionName.Text, 5, index);

                        Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked);
                        question.addOption(questionOption1);

                        Questionoption questionOption2 = new Questionoption(1, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked);
                        question.addOption(questionOption2);

                        Questionoption questionOption3 = new Questionoption(1, Answer3Textbox.Text, AmountOfQuestions, Answer3Radiobuttons.Checked);
                        question.addOption(questionOption3);

                        Questionoption questionOption4 = new Questionoption(1, Answer4Textbox.Text, AmountOfQuestions, Answer4Radiobuttons.Checked);
                        question.addOption(questionOption4);

                        Questionoption questionOption5 = new Questionoption(1, Answer5Textbox.Text, AmountOfQuestions, Answer5Radiobuttons.Checked);
                        question.addOption(questionOption5);

                        bc.qc.create(question);
                        MessageBox.Show("De vraag is toegevoegd");
                        bc.qc.editListPanel(index);
                    }
                    else
                    {
                        MessageBox.Show("Selecteer eerst een juist antwoord");
                    }

                }
            }
            else if (combobox.SelectedIndex == 6)
            {
                if (string.IsNullOrWhiteSpace(QuestionName.Text))
                {
                    MessageBox.Show("Vul eerst een vraag in");
                }
                else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text) || string.IsNullOrWhiteSpace(Answer3Textbox.Text) || string.IsNullOrWhiteSpace(Answer4Textbox.Text) || string.IsNullOrWhiteSpace(Answer5Textbox.Text) || string.IsNullOrWhiteSpace(Answer6Textbox.Text))
                {
                    MessageBox.Show("Vul eerst alle antwoorden in");
                }
                else
                {
                    if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked || Answer3Radiobuttons.Checked || Answer4Radiobuttons.Checked || Answer5Radiobuttons.Checked || Answer6Radiobuttons.Checked)
                    {
                        AmountOfQuestions += 1;
                        question = new Question(AmountOfQuestions + 1, QuestionName.Text, 6, index);

                        Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked);
                        question.addOption(questionOption1);

                        Questionoption questionOption2 = new Questionoption(1, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked);
                        question.addOption(questionOption2);

                        Questionoption questionOption3 = new Questionoption(1, Answer3Textbox.Text, AmountOfQuestions, Answer3Radiobuttons.Checked);
                        question.addOption(questionOption3);

                        Questionoption questionOption4 = new Questionoption(1, Answer4Textbox.Text, AmountOfQuestions, Answer4Radiobuttons.Checked);
                        question.addOption(questionOption4);

                        Questionoption questionOption5 = new Questionoption(1, Answer5Textbox.Text, AmountOfQuestions, Answer5Radiobuttons.Checked);
                        question.addOption(questionOption5);

                        Questionoption questionOption6 = new Questionoption(1, Answer6Textbox.Text, AmountOfQuestions, Answer6Radiobuttons.Checked);
                        question.addOption(questionOption6);

                        bc.qc.create(question);
                        MessageBox.Show("De vraag is toegevoegd");
                        bc.qc.editListPanel(index);
                    }
                    else
                    {
                        MessageBox.Show("Selecteer eerst een juist antwoord");
                    }

                }
            }
        }
Esempio n. 3
0
 // Method to delete question by serializing object and sending it to the API
 public void delete(Question question)
 {
     var result = bc.jsonRequest("/question/delete", bc.serialize.Serialize(question));
 }
        public void FillTable()
        {
            foreach (Statistic stat in stats)
            {
                List<QuestionLog> ql = bc.stc.getQuestionLogs();
                question = bc.qc.get(stat.id);
                string answer = "";

                foreach(QuestionLog QuestionLog in ql)
                {
                    if ((bc.user.firstname + " " + bc.user.lastname) == QuestionLog.user)
                    {
                        if (question.id == QuestionLog.question)
                        {
                            answer = QuestionLog.answer;
                        }
                    }
                }
                // Table size, Count for nr in table
                y += 31;
                Table.Size = new Size(1450, y);
                count += 1;

                // Label for "Question"
                Label Nr = new Label();
                Nr.Font = new Font("Segoe print", 10F);
                Nr.Text = count + " ";
                Nr.Size = new Size(50, 30);
                Nr.BackColor = Color.White;
                Nr.Margin = new Padding(0);

                // Label for "QuestionExpanded"
                Label QuestionExpanded = new Label();
                QuestionExpanded.Font = new Font("Segoe print", 10F);
                QuestionExpanded.Text = stat.question;
                QuestionExpanded.Size = new Size(500, 30);
                QuestionExpanded.BackColor = Color.White;
                QuestionExpanded.Margin = new Padding(0);

                // Label for "CorrectAnswerInfo"
                Label CorrectAnswer = new Label();
                CorrectAnswer.Font = new Font("Segoe print", 10F);
                CorrectAnswer.Text = stat.answer; // Needs A/B/C/D from multi per choice by the correct antwoord > B. Larstig for example
                CorrectAnswer.Size = new Size(400, 30);
                CorrectAnswer.BackColor = Color.White;
                CorrectAnswer.Margin = new Padding(0);

                Label StudentAnswer = new Label();
                StudentAnswer.Font = new Font("Segoe print", 10F);
                StudentAnswer.Text = answer;
                StudentAnswer.Size = new Size(400, 30);
                StudentAnswer.BackColor = Color.White;
                StudentAnswer.Margin = new Padding(0);

                Label Type = new Label();
                Type.Font = new Font("Segoe print", 10F);
                if (question.type == 0)
                {
                    Type.Text = "Open vraag";
                }
                else if (question.type == 1)
                {
                    Type.Text = "Stelling";
                }
                else
                {
                    Type.Text = "Meerkeuze";
                }
                Type.Size = new Size(200, 30);
                Type.BackColor = Color.White;
                Type.Margin = new Padding(0);

                // Adds everything to the table
                Table.RowCount = Table.RowCount + 1;
                Table.Controls.Add(Nr, 0, Row);
                Table.Controls.Add(QuestionExpanded, 1, Row);
                Table.Controls.Add(CorrectAnswer, 2, Row);
                Table.Controls.Add(StudentAnswer, 3, Row);
                Table.Controls.Add(Type, 4, Row);
                // Row++ so you to the next row
                Row++;
            }
        }