Example #1
0
        private void Testing_Load(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection(Information.connectionString);

            connection.Open();
            SqlCommand command = new SqlCommand();

            command.Connection = connection;
            string commandS = "";

            string textQshon;


            listQuestion.Clear();
            nameTable = Information.nameTest + "_" + Convert.ToString(Information.idTicer);

            try
            {
                commandS            = "SELECT * FROM " + nameTable;
                command.CommandText = commandS;
                SqlDataReader dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    textQshon    = dataReader["Text_question"].ToString();
                    typeQuestion = (int)dataReader["Type_question"];
                    answers      = dataReader["Answers"].ToString();

                    ClassQuestion question = new ClassQuestion(textQshon, typeQuestion, answers);
                    listQuestion.Add(question);
                }
                dataReader.Close();
                connection.Close();

                int cauntQeshon = listQuestion.Count();

                progressBar1.Maximum = cauntQeshon;

                curientNamber = 1;
                trueCaunt     = 0;

                openQeshon();
            }
            catch
            {
                MessageBox.Show(" Данный тест был удален, или произашла непредвиденая ошибка"
                                );
                connection.Close();
                return;
            }
        }
Example #2
0
        public void openQeshon()
        {
            ClassQuestion question = listQuestion[curientNamber - 1];

            this.textBox1.Text = question.textQuestion;
            typeQuestion       = question.typeQuestion;
            answers            = question.answers;
            answerMas          = answers.Split(';');
            Array.Resize(ref answerMas, answerMas.Length - 1);
            cauntAnswrs = answerMas.Length;
            splitContainer2.Panel1.Controls.Clear();
            trueAnswer = "";

            if (listQuestion[curientNamber - 1].typeQuestion == 1)
            {
                for (int i = 0; i < cauntAnswrs; i++)
                {
                    trueAnswer += answerMas[i][0];

                    Information.RadioButtonDynamic(splitContainer2.Panel1, 20, 40 + i * 30 + i * 10, 30, 30);
                    Information.LabelDynamic(splitContainer2.Panel1, 60, 40 + i * 30 + i * 10, splitContainer2.Panel1.Width - 70, 30, answerMas[i].Remove(0, 1));
                }
            }
            else if (listQuestion[curientNamber - 1].typeQuestion == 2)
            {
                for (int i = 0; i < cauntAnswrs; i++)
                {
                    trueAnswer += answerMas[i][0];

                    Information.CheckBoxDynamic(splitContainer2.Panel1, 20, 40 + i * 30 + i * 10, 30, 30);
                    Information.LabelDynamic(splitContainer2.Panel1, 60, 40 + i * 30 + i * 10, splitContainer2.Panel1.Width - 70, 30, answerMas[i].Remove(0, 1));
                }
            }
            else if (listQuestion[curientNamber - 1].typeQuestion == 3)
            {
                trueAnswer = answers;

                Information.TextBoxDynamic(splitContainer2.Panel1, 30, 40 + 30 + 10, splitContainer2.Panel1.Width - 70, 30);
            }
            else if (listQuestion[curientNamber - 1].typeQuestion == 4)
            {
                string[] answerForСonformity = new String[answerMas.Length * 2];
                string[] answer1             = new string[answerMas.Length];
                string[] answer2             = new string[answerMas.Length];
                for (int i = 0; i < answerMas.Length; i++)
                {
                    answerForСonformity = answerMas[i].Split('&');

                    answer1[i] = answerForСonformity[0];
                    answer2[i] = answerForСonformity[1];
                }

                answerForСonformity = answer1.Union(answer2).ToArray();

                for (int i = 0; i < cauntAnswrs; i++)
                {
                    int a = splitContainer2.Panel1.Width / 2;
                    Information.ComboBoxDynamic(splitContainer2.Panel1, 10, 40 + i * 30 + i * 10, a, 30, answerForСonformity);
                    Information.ComboBoxDynamic(splitContainer2.Panel1, a + 30, 40 + i * 30 + i * 10, a - 45, 30, answerForСonformity);
                }
            }
        }
Example #3
0
        private void buttonSave_Click(object sender, EventArgs e)//сохранить вопрос
        {
            bool   loog;
            string ans = "";

            if (textBox1.Text != "")
            {
                loog = true;
            }
            else
            {
                loog = false;
            }
            int caunter = 0;

            if (Information.taupOfTest == 1)
            {
                for (int i = 0; i < splitContainer3.Panel2.Controls.Count; i += 2)
                {
                    RadioButton rb = splitContainer3.Panel2.Controls[i] as RadioButton;
                    TextBox     tb = splitContainer3.Panel2.Controls[i + 1] as TextBox;

                    if (tb.Text != "")
                    {
                        if (rb.Checked)
                        {
                            ans += "+" + tb.Text + ";";
                            loog = loog & true;
                        }
                        else
                        {
                            ans += "-" + tb.Text + ";";
                        }
                        caunter++;
                    }
                }

                if (caunter < 2)
                {
                    loog = loog & false;
                }
            }
            else if (Information.taupOfTest == 2)
            {
                for (int i = 0; i < splitContainer3.Panel2.Controls.Count; i += 2)
                {
                    CheckBox cb = splitContainer3.Panel2.Controls[i] as CheckBox;
                    TextBox  tb = splitContainer3.Panel2.Controls[i + 1] as TextBox;

                    if (tb.Text != "")
                    {
                        if (cb.Checked)
                        {
                            ans += "+" + tb.Text + ";";
                            loog = loog & true;
                        }
                        else
                        {
                            ans += "-" + tb.Text + ";";
                        }

                        caunter++;
                    }
                }
                if (caunter < 2)
                {
                    loog = loog & false;
                }
            }
            else if (Information.taupOfTest == 3)
            {
                TextBox tb = splitContainer3.Panel2.Controls[0] as TextBox;
                if (tb.Text != "")
                {
                    ans += tb.Text + ";";
                    loog = loog & true;
                }
            }
            else if (Information.taupOfTest == 4)
            {
                for (int i = 0; i < splitContainer3.Panel2.Controls.Count; i += 2)
                {
                    TextBox tb1 = splitContainer3.Panel2.Controls[i] as TextBox;
                    TextBox tb2 = splitContainer3.Panel2.Controls[i + 1] as TextBox;

                    if (tb1.Text != "" && tb2.Text != "")
                    {
                        ans += tb1.Text + "&" + tb2.Text + ";";
                        loog = loog & true;

                        caunter++;
                    }
                }
                if (caunter < 2)
                {
                    loog = loog & false;
                }
            }
            if (!loog)
            {
                MessageBox.Show("вы не вели ответов",
                                "ошибка",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error
                                );
                return;
            }

            MessageBox.Show(ans);

            ClassQuestion question = new ClassQuestion(textBox1.Text, Information.taupOfTest, ans);

            listBox1.Items.Add(textBox1.Text);
            listQuestions.Add(question);
            cauntQechon++;
            toolStripStatusNumberOfQuestions.Text = "вопросов всего:" + Convert.ToString(cauntQechon);
            splitContainer3.Panel2.Controls.Clear();
            textBox1.Text = "";
            save          = false;
        }