public testerView(tester t, List<oprosnikElem> l)
        {
            InitializeComponent();
            res = t;
            oprosnik=l;

            foreach (var te in oprosnik)
            {
                treeView1.Nodes.Add(te.question);
            }
        }
Exemple #2
0
        public bool connectOpr(string add)
        {
            opros op = new opros();
            if (!op.load(add)) return false;

            if (this.anketa.Count != op.anketa.Count) return false;
            for (int i=0; i<op.anketa.Count; i++)
            {
                if (this.anketa[i] != op.anketa[i]) return false;
            }

            foreach (var x in op.testers)
            {
                tester t = new tester();
                foreach (var a in x.anketa)
                {
                    t.anketa.Add(a);
                }
                foreach (var a in x.answers)
                {
                    answer answ = new answer(new List<bool>());
                    foreach (var b in a.SelectedAnswers)
                    {
                        answ.SelectedAnswers.Add(b);
                    }
                    t.answers.Add(answ);
                }
                this.testers.Add(t);
            }
            return true;
        }
Exemple #3
0
        public bool load(string way)
        {
            try
            {
                FileStream fs = new FileStream(way, FileMode.Open);
                using (StreamReader sw = new StreamReader(fs))
                {
                    string temp="";

                    temp=sw.ReadLine();
                    if (temp != "!realOprosFile!") return false;

                    maxTesters = Convert.ToInt32(sw.ReadLine());

                    temp = sw.ReadLine();
                    while (temp != "!endDescr!")
                    {
                        Description += temp+Environment.NewLine;
                        temp = sw.ReadLine();
                    }
                    IsAnonimus = Convert.ToBoolean(sw.ReadLine());

                    temp = sw.ReadLine();
                    while (temp != "!endGenAnketa!")
                    {
                        anketa.Add(temp);
                        temp = sw.ReadLine();
                    }

                    temp = sw.ReadLine();

                    while (temp != "!oprosnik!")
                    {
                        tester t = new tester();
                        while (temp != "!next!")
                        {
                            while (temp != "!endAnketa!")
                            {
                                t.anketa.Add(temp);
                                temp = sw.ReadLine();
                            }
                            temp = sw.ReadLine();

                            while (temp != "!next!")
                            {

                                if (temp != "!next!")
                                {
                                    List<bool> variant = new List<bool>();
                                    while (temp != "!newAnsw!")
                                    {
                                        if (temp == "+") variant.Add(true);
                                        else variant.Add(false);
                                        temp = sw.ReadLine();
                                    }
                                    t.answers.Add(new answer(variant));
                                    temp = sw.ReadLine();
                                }
                            }
                        }
                        temp = sw.ReadLine();
                        testers.Add(t);
                    }

                    temp = sw.ReadLine();
                    while (temp != "!END!")
                    {
                        oprosnikElem x = new oprosnikElem();
                        x.IsOneVariant = Convert.ToBoolean(temp);
                        x.question = sw.ReadLine();
                        temp = sw.ReadLine();
                        while (temp != "!next!")
                        {
                            x.answers.Add(temp);
                            temp = sw.ReadLine();
                        }
                        temp = sw.ReadLine();
                        selectedOprosnik.elements.Add(x);
                    }

                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Ошибка при загрузке" + Environment.NewLine + ex.Message);
            }
            return true;
        }