Ejemplo n.º 1
0
 public void hide()
 {
     label1.Hide();
     Red_test.Hide();
     Blue_test.Hide();
     Green_test.Hide();
     label2.Show();
     Answer1.Show();
     Answer2.Show();
     Answer3.Show();
     Answer4.Show();
     button1.Show();
     richTextBox1.Show();
 }
Ejemplo n.º 2
0
        // get (Number of theme - 1)
        // return Number of question
        // or -1 if question list is empty
        private void GetQuestion(int theme)
        {
            string questNodeName = "";

            switch (theme)
            {
            case 0:
                questNodeName = "cycles";
                break;

            case 1:
                questNodeName = "arrays";
                break;

            case 2:
                questNodeName = "lines";
                break;

            case 3:
                questNodeName = "recursion";
                break;

            case 4:
                questNodeName = "struct";
                break;

            case 5:
                questNodeName = "file";
                break;

            case 6:
                questNodeName = "addresses_and_pointers";
                break;

            case 7:
                questNodeName = "dynamic_memory";
                break;

            default:
                return;
            }

            if (amount == 0)
            {
                for (int i = 0; i < MAX_QUESTIONS_TRAIN; i++)
                {
                    isOpened[i] = -1;
                }
            }

            XmlDocument doc = new XmlDocument();

            doc.Load("testing.xml");
            XmlNode rootNode = doc.DocumentElement;             // <testing>


            foreach (XmlNode themeNode in rootNode)
            {
                if (themeNode.Name == questNodeName)
                {
                    Random rnd      = new Random();
                    int    question = rnd.Next() % themeNode.ChildNodes.Count;

                    bool exit = false;
                    while (!exit)
                    {
                        int i;
                        for (i = 0; i < amount; i++)
                        {
                            if (isOpened[i] == question)
                            {
                                question = rnd.Next() % themeNode.ChildNodes.Count;
                                break;
                            }
                        }

                        if (i == amount)
                        {
                            exit = true;
                        }
                    }

                    isOpened[amount] = question;
                    amount++;

                    foreach (XmlNode questionNode in themeNode.ChildNodes[question])
                    {
                        if (questionNode.Name == "quest")
                        {
                            cur_question = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "true")
                        {
                            cur_answer = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "answer1")
                        {
                            Answer1.Show();
                            Answer1.Text = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "answer2")
                        {
                            Answer2.Show();
                            Answer2.Text = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "answer3")
                        {
                            Answer3.Show();
                            Answer3.Text = questionNode.InnerText;
                        }
                        else if (questionNode.Name == "answer4")
                        {
                            Answer4.Show();
                            Answer4.Text = questionNode.InnerText;
                        }
                    }

                    button2.Show();
                }
            }
        }