Example #1
0
 //Стандартный конструктор
 public Test()
 {
     Password            = "";
     Questions           = new List <Question>();
     Sections            = new List <string>();
     TimeForTest         = 0;
     QuestionAllocation  = QuestionAllocation.One_Variant;
     CountForGenerate    = 0;
     DBConnectionRequest = "";
 }
Example #2
0
        //Конструктор с загрузкой из файла
        public Test(string FileName, string TmpPath, string Password = "")
        {
            Questions = new List <Question>();
            Sections  = new List <string>();

            if (Password == "")
            {
                using (ZipFile Zip = new ZipFile(FileName))
                {
                    Zip.ExtractAll("");
                }
            }
            else
            {
                EncryptDecryptFile(FileName, Password, false, TmpPath + @"\testtmp.test");
                using (ZipFile Zip = new ZipFile(TmpPath + @"\testtmp.test"))
                {
                    Zip.ExtractAll("");
                }
            }

            var Doc = new XmlDocument();

            Doc.Load(TmpPath + @"\" + "main.xml");

            var Root = Doc.DocumentElement;

            foreach (XmlNode Child1 in Root)
            {
                if (Child1.Name == "password")
                {
                    this.Password = Child1.InnerText;
                }
                else
                if (Child1.Name == "time")
                {
                    TimeForTest = Convert.ToInt32(Child1.InnerText);
                }
                else
                if (Child1.Name == "raspred")
                {
                    QuestionAllocation = (QuestionAllocation)Convert.ToInt32(Child1.InnerText);
                }
                else
                if (Child1.Name == "generate")
                {
                    CountForGenerate = Convert.ToInt32(Child1.InnerText);
                }
                else
                if (Child1.Name == "BD")
                {
                    DBConnectionRequest = Child1.InnerText;
                }
                else
                if (Child1.Name == "razdeli")
                {
                    foreach (XmlNode Child2 in Child1.ChildNodes)
                    {
                        if (Child2.Name == "razdeli")
                        {
                            Sections.Add(Child2.InnerText);
                        }
                    }
                }
            }

            var i = 0;

            while (File.Exists(TmpPath + @"\" + i.ToString() + ".xml"))
            {
                Questions.Add(new Question(i.ToString() + ".xml", TmpPath));
                i++;
            }
        }