private void lstViewQuestion_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //MessageBox.Show(lstViewQuestion.SelectedItems[0].Tag.ToString());
            if (lstViewQuestion.SelectedItems[0] != null)
            {
                if (Save == false)
                {
                    tq = new TextQuestion();
                }
                if (lstViewQuestion.SelectedItems[0].Index != kolvoQuest && Save == false)
                {
                    tq.num = kolvoQuest;
                    tq.type_question = cBSelect.Text;
                    if (Picture == false)
                        tq.question = rtBQuestion.Text;
                    else
                        tq.question = PicturePath;
                    tq.answ1 = txtBox1.Text;
                    tq.price = Int32.Parse(NumberList.Value.ToString());
                    if (cBSelect.Text != "Свободный ответ")
                    {
                        tq.answ2 = txtBox2.Text;
                        tq.answ3 = txtBox3.Text;
                        tq.answ4 = txtBox4.Text;
                    }
                    if (cBSelect.SelectedIndex == 0)
                        if (rad1.Checked == true)
                        {
                            tq.rightans[0] = txtBox1.Text;
                            rad1.Checked = false;
                        }
                        else
                            if (rad2.Checked == true)
                            {
                                tq.rightans[0] = txtBox2.Text;
                                rad2.Checked = false;
                            }
                            else
                                if (rad3.Checked == true)
                                {
                                    tq.rightans[0] = txtBox3.Text;
                                    rad3.Checked = false;
                                }
                                else
                                {
                                    if (rad4.Checked == true)
                                    {
                                        tq.rightans[0] = txtBox4.Text;
                                        rad4.Checked = false;
                                    }
                                }
                    if (cBSelect.SelectedIndex == 1)
                    {
                        if (cB1.Checked == true)
                        {
                            tq.rightans[0] = txtBox1.Text;
                            cB1.Checked = false;
                        }
                        if (cB2.Checked == true)
                        {
                            tq.rightans[1] = txtBox2.Text;
                            cB2.Checked = false;
                        }
                        if (cB3.Checked == true)
                        {
                            tq.rightans[2] = txtBox3.Text;
                            cB3.Checked = false;
                        }
                        if (cB4.Checked == true)
                        {
                            tq.rightans[3] = txtBox4.Text;
                            cB4.Checked = false;
                        }
                    }
                    if (cBSelect.SelectedIndex == 2)
                    {
                        if (txtBox1.Text != "")
                            tq.rightans[0] = txtBox1.Text;
                        if (txtBox2.Text != "")
                            tq.rightans[1] = txtBox2.Text;
                        if (txtBox3.Text != "")
                            tq.rightans[2] = txtBox3.Text;
                        if (txtBox4.Text != "")
                            tq.rightans[3] = txtBox4.Text;
                    }
                    if (cBSelect.SelectedIndex == 3)
                        tq.rightans[0] = txtBox1.Text;
                    if (cBSelect.SelectedIndex == 4)
                    {
                        tq.rightans[0] = txtBox1.Text;
                        tq.rightans[1] = txtBox2.Text;
                        tq.rightans[2] = txtBox3.Text;
                        tq.rightans[3] = txtBox4.Text;
                    }
                    for (int i = 0; i <= lstViewIstochnik.Items.Count - 1; i++)
                        tq.part[i] = lstViewIstochnik.Items[i].Text;
                    Save = true;

                }
                if (kolvoQuest != lstViewQuestion.SelectedItems[0].Index + 1)//загрузка не последнего вопроса
                {
                    NumItems = Int32.Parse(lstViewQuestion.SelectedItems[0].Tag.ToString());
                    if (rad1 != null)
                        rad1.Checked = false;
                    if (rad2 != null)
                        rad2.Checked = false;
                    if (rad3 != null)
                        rad3.Checked = false;
                    if (rad4 != null)
                        rad4.Checked = false;
                    if (cB1 != null)
                        cB1.Checked = false;
                    if (cB2 != null)
                        cB2.Checked = false;
                    if (cB3 != null)
                        cB3.Checked = false;
                    if (cB4 != null)
                        cB4.Checked = false;
                    //----------------------------------------------------------------------------
                    //btnSaveQ.Visible = true;
                    btnSaveQ.Enabled = true;
                    //btnAdd.Visible = false;
                    btnAdd.Enabled = false;
                    int h = Int32.Parse(lstViewQuestion.SelectedItems[0].Tag.ToString());
                    //Clear();
                    if (Questions[h].type_question == "Один вариант ответа")
                    {
                        cBSelect.SelectedIndex = 0;
                       // CreateBut("rad");
                        //ShowHideControls(true);
                    }
                    if (Questions[h].type_question == "Несколько вариантов ответа")
                    {
                        cBSelect.SelectedIndex = 1;
                        //CreateBut("cB");
                        //ShowHideControls(true);
                    }
                    if (Questions[h].type_question == "Выстроить последовательность")
                    {
                        cBSelect.SelectedIndex = 2;
                        //ShowHideControls(true);
                    }
                    if (Questions[h].type_question == "Свободный ответ")
                    {
                        cBSelect.SelectedIndex = 3;
                        //ShowHideControls(false);
                    }
                    if( Questions[h].type_question == "Сопоставление")
                    {
                        cBSelect.SelectedIndex = 4;
                        //ShowHideControls(true);
                    }
                    if (File.Exists(Questions[h].question) == false)
                        rtBQuestion.Text = Questions[h].question;
                    else
                    {
                        img = Image.FromFile(Questions[h].question);
                        Clipboard.Clear();
                        Clipboard.SetImage(img);
                        rtBQuestion.Paste();
                        Clipboard.Clear();
                    }

                    txtBox1.Text = Questions[h].answ1;
                    if (cBSelect.SelectedIndex != 3)
                    {
                        txtBox2.Text = Questions[h].answ2;
                        txtBox3.Text = Questions[h].answ3;
                        txtBox4.Text = Questions[h].answ4;
                    }
                    NumberList.Value = Questions[h].price;
                    if (cBSelect.SelectedIndex == 0)
                    {
                        if (Questions[h].rightans[0] == txtBox1.Text)
                            rad1.Checked = true;
                        if (Questions[h].rightans[0] == txtBox2.Text)
                            rad2.Checked = true;
                        if (Questions[h].rightans[0] == txtBox3.Text)
                            rad3.Checked = true;
                        if (Questions[h].rightans[0] == txtBox4.Text)
                            rad4.Checked = true;
                    }
                    if (cBSelect.SelectedIndex == 1)
                    {
                        if (Questions[h].rightans[0] == txtBox1.Text)
                            cB1.Checked = true;
                        if (Questions[h].rightans[1] == txtBox2.Text)
                            cB2.Checked = true;
                        if (Questions[h].rightans[2] == txtBox3.Text)
                            cB3.Checked = true;
                        if (Questions[h].rightans[3] == txtBox4.Text)
                            cB4.Checked = true;
                    }
                    lstViewIstochnik.Items.Clear();
                    for (int i = 0; i <= 9; i++)
                    {
                        if (Questions[h].part[i] != null)
                            lstViewIstochnik.Items.Add(Questions[h].part[i]);
                    }
                }
                if (kolvoQuest == lstViewQuestion.SelectedItems[0].Index + 1)//загрузка последнего вопроса
                {
                    if (rad1 != null)
                        rad1.Checked = false;
                    if (rad2 != null)
                        rad2.Checked = false;
                    if (rad3 != null)
                        rad3.Checked = false;
                    if (rad4 != null)
                        rad4.Checked = false;
                    if (cB1 != null)
                        cB1.Checked = false;
                    if (cB2 != null)
                        cB2.Checked = false;
                    if (cB3 != null)
                        cB3.Checked = false;
                    if (cB4 != null)
                        cB4.Checked = false;
                    //-----------------------------------------------------------------------------------------------
                    //btnSaveQ.Visible = false;
                    btnSaveQ.Enabled = false;
                    //btnAdd.Visible = true;
                    btnAdd.Enabled = true;
                    //Clear();
                    if (tq.type_question == "Один вариант ответа")
                    {
                        cBSelect.SelectedIndex = 0;
                        //CreateBut("rad");
                        //ShowHideControls(true);
                    }
                    if (tq.type_question == "Несколько вариантов ответа")
                    {
                        cBSelect.SelectedIndex = 1;
                        //CreateBut("cB");
                        //ShowHideControls(true);
                    }
                    if (tq.type_question == "Выстроить последовательность")
                    {
                        cBSelect.SelectedIndex = 2;
                        //ShowHideControls(true);
                    }
                    if (tq.type_question == "Свободный ответ")
                    {
                        cBSelect.SelectedIndex = 3;
                        //ShowHideControls(false);
                    }
                    if (tq.type_question == "Сопоставление")
                    {
                        cBSelect.SelectedIndex = 4;
                        //ShowHideControls(true);
                    }
                    if (File.Exists(tq.question) == false)
                        rtBQuestion.Text = tq.question;
                    else
                    {
                        img = Image.FromFile(tq.question);
                        Clipboard.Clear();
                        Clipboard.SetImage(img);
                        rtBQuestion.Paste();
                        Clipboard.Clear();
                    }
                    txtBox1.Text = tq.answ1;
                    if (cBSelect.SelectedIndex != 3)
                    {
                        txtBox2.Text = tq.answ2;
                        txtBox3.Text = tq.answ3;
                        txtBox4.Text = tq.answ4;
                    }

                    if (tq.type_question == "Один вариант ответа")
                    {
                        if (tq.rightans[0] == txtBox1.Text)
                            rad1.Checked = true;
                        if (tq.rightans[0] == txtBox2.Text)
                            rad2.Checked = true;
                        if (tq.rightans[0] == txtBox3.Text)
                            rad3.Checked = true;
                        if (tq.rightans[0] == txtBox4.Text)
                            rad4.Checked = true;
                    }
                    if (tq.type_question == "Несколько вариантов ответа")
                    {
                        if (tq.rightans[0] == txtBox1.Text)
                            cB1.Checked = true;
                        if (tq.rightans[1] == txtBox2.Text)
                            cB2.Checked = true;
                        if (tq.rightans[2] == txtBox3.Text)
                            cB3.Checked = true;
                        if (tq.rightans[3] == txtBox4.Text)
                            cB4.Checked = true;
                    }

                    NumberList.Value = tq.price;

                    lstViewIstochnik.Items.Clear();
                    for (int i = 0; i <= 9; i++)
                        if (tq.part[i] != null)
                            lstViewIstochnik.Items.Add(tq.part[i]);
                    Save = false;
                }
            }
        }
 private void TestCreate_Load(object sender, EventArgs e)
 {
     cBSelect.SelectedIndex = -1;
     //tabControl1.SelectedIndex = 1;
     lstViewQuestion.Items.Add("Вопрос № " + kolvoQuest);
     tek = new TextQuestion();
     cBOtch.SelectedIndex = 0;
     btnSaveQ.Enabled = false;
     btnAdd.Enabled = true;
     openFile.InitialDirectory = PathDirectory.TestPath;
     saveFileDialog1.InitialDirectory = PathDirectory.TestPath;
 }
        public void Next()
        {
            for (int i = 0; i <= lstViewIstochnik.Items.Count - 1; i++)
            {
                tek.part[i] = lstViewIstochnik.Items[i].Text;
            }
            rtBQuestion.Text = "";
            txtBox1.Text = "";
            if (cBSelect.SelectedIndex != 3)
            {
                txtBox2.Text = "";
                txtBox3.Text = "";
                txtBox4.Text = "";
            }
            cBSelect.SelectedIndex = 0;
            if (cBSelect.SelectedIndex == 0)
            {
                rad1.Checked = false;
                rad2.Checked = false;
                rad3.Checked = false;
                rad4.Checked = false;
            }
            if (cBSelect.SelectedIndex == 1)
            {
                cB1.Checked = false;
                cB2.Checked = false;
                cB3.Checked = false;
                cB4.Checked = false;
            }
            lstViewIstochnik.Items.Clear();

            img = null;
            Clipboard.Clear();

            Questions.Add(tek);
            kolvoQuest++;
            int y = lstViewQuestion.Items.Add("Вопрос № " + kolvoQuest.ToString()).Index - 1;
            x = Questions.IndexOf(tek);
            lstViewQuestion.Items[y].Tag = x;
            tek = new TextQuestion();
        }
예제 #4
0
        void LoadQuestions()
        {
            do xmlReader.Read();
            while (xmlReader.Name != "Theme");
            xmlReader.Read();
            Theme = xmlReader.Value.ToString();

            do xmlReader.Read();
            while (xmlReader.Name != "Questions");
            int Numbers = Int32.Parse(xmlReader.GetAttribute("Number"));
            while(pos<=Numbers)
            {
                    do xmlReader.Read(); while (xmlReader.Name != "Question" + pos);
                    if (xmlReader.Name == "Question" + pos)
                    {
                        tq.num = pos-1;
                        do xmlReader.Read(); while (xmlReader.Name != "Text");
                        xmlReader.Read();

                        tq.question = xmlReader.Value.ToString();

                        //------------------------------------------------------------------------
                        do xmlReader.Read(); while (xmlReader.Name != "TypeAnswer");
                        xmlReader.Read();
                        tq.type_question = xmlReader.Value.ToString();
                        if (tq.type_question == "One")
                        {
                            do xmlReader.Read(); while (xmlReader.Name != "Answers");
                            printAnswers("One");
                            do xmlReader.Read(); while (xmlReader.Name != "RightAnswer");
                            //MessageBox.Show(xmlReader.Value.ToString());//xmlReader.Read();
                            //tq.rightans[0] = xmlReader.Value.ToString();
                            printRightAnswers();
                            do xmlReader.Read(); while (xmlReader.Name != "Part");
                            printPart();
                            do xmlReader.Read(); while (xmlReader.Name != "Price");
                            xmlReader.Read();
                            tq.price = Int32.Parse(xmlReader.Value.ToString());

                        }
                        else
                            if (tq.type_question == "Several")
                            {
                                do xmlReader.Read(); while (xmlReader.Name != "Answers");
                                printAnswers("Several");
                                do xmlReader.Read(); while (xmlReader.Name != "RightAnswer");
                               // xmlReader.Read();
                                //printAnswers("Several");
                                printRightAnswers();
                                printPart();
                                do xmlReader.Read(); while (xmlReader.Name != "Price");
                                xmlReader.Read();
                                tq.price = Int32.Parse(xmlReader.Value.ToString());
                            }
                            else
                                if (tq.type_question == "Sequence")
                                {
                                    do xmlReader.Read(); while (xmlReader.Name != "Answers");
                                    printAnswers("Sequence");
                                    do xmlReader.Read(); while (xmlReader.Name != "RightAnswer");
                                    printRightAnswers();
                                    printPart();
                                    do xmlReader.Read(); while (xmlReader.Name != "Price");
                                    xmlReader.Read();
                                    tq.price = Int32.Parse(xmlReader.Value.ToString());
                                }
                                else
                                    if (tq.type_question == "Writing")
                                    {
                                        do xmlReader.Read(); while (xmlReader.Name != "Answers");
                                        printAnswers("Writing");
                                        do xmlReader.Read(); while (xmlReader.Name != "RightAnswer");
                                        xmlReader.Read();
                                        tq.rightans[0] = xmlReader.Value.ToString();
                                        printPart();

                                        do xmlReader.Read(); while (xmlReader.Name != "Price");
                                        xmlReader.Read();
                                        tq.price = Int32.Parse(xmlReader.Value.ToString());
                                    }
                                    else
                                    {
                                        do xmlReader.Read(); while (xmlReader.Name != "Answers");
                                        printAnswers("Comparison");
                                        do xmlReader.Read(); while (xmlReader.Name != "RightAnswer");
                                        xmlReader.Read();
                                        string temp = xmlReader.Value.ToString();
                                        int oneid = temp.IndexOf("==");
                                        string one = "";
                                        for (int h = 0; h < oneid; h++)
                                        {
                                            one = one + temp[h];
                                        }
                                        tq.rightans[0] = one;
                                        int twoid = temp.IndexOf("|");
                                        string two = "";
                                        for (int h = oneid + 2; h < twoid; h++)
                                        {
                                            two = two + temp[h];
                                        }
                                        tq.rightans[1] = two;
                                        oneid = temp.LastIndexOf("==");
                                        one = "";
                                        two = "";
                                        for (int h = twoid + 1; h < oneid; h++)
                                        {
                                            one = one + temp[h];
                                        }
                                        tq.rightans[2] = one;
                                        for (int h = oneid + 2; h < temp.Length; h++)
                                        {
                                            two = two + temp[h];
                                        }
                                        tq.rightans[3] = two;
                                        printPart();
                                        do xmlReader.Read(); while (xmlReader.Name != "Price");
                                        xmlReader.Read();
                                        tq.price = Int32.Parse(xmlReader.Value.ToString());
                                    }
                    }
                    pos++;
                Questions.Add(tq);
                int index=Questions.IndexOf(tq);

                int numbQuest = pos-1;
                int index2=lstQuestion.Items.Add("Вопрос " + numbQuest).Index;
                lstQuestion.Items[index2].Tag = index;
                lstQuestion.Items[index2].BackColor = Color.Red;
                testAns = new TestAnswers();
                testAns.NumberQuestion = index;
                Answers.Add(testAns);
                //lstQuestion.Items[pos--].Tag = index;
                tq = new TextQuestion();
                //do xmlReader.Read(); while (xmlReader.Name != "Price");
                //do xmlReader.Read(); while (xmlReader.Name != "Question"+pos--);
                xmlReader.Read();
                };//while(xmlReader.Name!="Questions");
            do
            {
                xmlReader.Read();
            } while (xmlReader.Name != "Time");
            xmlReader.Read();
            Time = Int32.Parse(xmlReader.Value.ToString());
            do
            {
                xmlReader.Read();
            } while (xmlReader.Name != "Report");
            xmlReader.Read();
            string tempRep = xmlReader.Value.ToString();
            if (tempRep == "Нет")
                Report = false;
            else
                Report = true;
            NotRightAnswers = new int[Questions.Count];
        }