Esempio n. 1
0
        void StatTest_Click(object sender, EventArgs e)// создание файла и начала тестирования
        {
            if (NameTest.Count == 0)
            {
                MessageBox.Show("Ошибка: вы не выбрали тест");
                return;
            }
            string fileName = "", FIO, BD, TD;//Создаём имя файла, ФИО-ДР-ДАТА

            FIO      = $"{(textBox1.Text != "" ? textBox1.Text + " " : "")}{(textBox2.Text != "" ? textBox2.Text + " " : "")}{(textBox3.Text != "" ? textBox3.Text + " " : "")}";
            BD       = $"{(textBox4.Text != "" ? textBox4.Text + "." : "")}{(textBox5.Text != "" ? textBox5.Text + "." : "")} {textBox6.Text}";
            TD       = (DateTime.Today.ToString("d")).Replace('/', '.');
            fileName = $"{(FIO != "" ? FIO + " " : "")}{(BD != "" ? BD + " " : "")}{TD}";
            fileName = Additional_functions.Create_name_for_file(fileName);
            StreamWriter sr;

            sr = new StreamWriter(fileName = $"{Setting.database_path}\\{fileName}.txt");
            sr.WriteLine($"{Descriptors._HEADER} <");
            sr.WriteLine($"Имя: {FIO}");
            sr.WriteLine($"Дата рождения: {BD}");
            sr.WriteLine($"Дата тестирования: {TD}");
            sr.WriteLine($"Тесты: ");
            for (int i = 0; i < NameTest.Count; i++)
            {
                sr.WriteLine($"{i+1}) {NameTest[i]}");
            }
            sr.WriteLine(">");
            Form2 FormCreate = new Form2(NameTest, fileName);

            sr.Close();
            this.Close();
        }
Esempio n. 2
0
        public static void _LINK(List <Group> Groups, ref int i, ref string line)
        {
            string temp = Additional_functions.ClearLine(ref i, line);

            try
            {
                string[] links = temp.Split('&');
                int      k     = 0;
                Link     L     = new Link();
                foreach (var l in links)
                {
                    L.Add(
                        Additional_functions.Trim(l, ref k, '{', '}'),
                        Additional_functions.Trim(l, ref k, '{', '}'),
                        Convert.ToInt32(Additional_functions.Trim(l, ref k, '[', ']'))
                        );
                    k = 0;
                }
                Groups[Groups.Count - 1].Links.Add(L);
            }
            catch
            {
                Stored_Exceptions.Add(new Exception("Error: Link exception, in Group " + Groups.Count));
            }
        }
Esempio n. 3
0
 public static void _SCALE(List <Scale> _Scales, ref int i, ref string line)
 {
     try{
         string temp = "";
         for (; i < line.Length && line[i] != ']'; i++)
         {
             temp += line[i];
         }
         for (; i < line.Length && line[i] != '<'; i++)
         {
             temp += line[i];
         }
         temp = temp.Trim();
         int   k     = 0;
         Scale scale = new Scale(
             Additional_functions.Trim(temp, ref k, '[', ']').Replace('\n', ' ').Replace('\r', ' ').Replace(" ", ""),
             Additional_functions.Trim(temp, ref k, '(', ')'),
             Additional_functions.ClearLine(ref i, line)
             );
         _Scales.Add(scale);
     }
     catch {
         Stored_Exceptions.Add(new Exception("Error: _Scales exception, Scale number " + _Scales.Count + 1));
     }
 }
Esempio n. 4
0
 public void Calculation_measure_of_expression(List <Dictionary <string, double> > Dictionary_of_scales, List <Test> TESTS)
 {
     for (int number_group = 0; number_group < Groups.Count; number_group++)
     {
         for (int number_link = 0; number_link < Groups[number_group].Links.Count; number_link++)
         {
             double Sum = 0;
             for (int i = 0; i < Groups[number_group].Links[number_link].Test_name.Count; i++)
             {
                 int number_test = Additional_functions.Number_of_Contains(TESTS, Groups[number_group].Links[number_link].Test_name[i]);
                 if (number_test >= 0 && Dictionary_of_scales[number_test].TryGetValue(Groups[number_group].Links[number_link].Scale_name[i], out double point_on_scale))
                 {
                     Sum += Return_Measure_for_fuzzy_sets(
                         TESTS[number_test],
                         Groups[number_group].Links[number_link].Scale_name[i],
                         point_on_scale, Groups[number_group].Links[number_link].Function_number[i]
                         );
                 }
                 else
                 {
                     Stored_Exceptions.Add(new Exception("Error: cannot find name of scale"));
                 }
             }
             if (Stored_Exceptions.Empty)
             {
                 Groups[number_group].Links[number_link].Measure_of_expression = Sum / Groups[number_group].Links[number_link].Scale_name.Count;
             }
         }
     }
 }
Esempio n. 5
0
        public static void _FUZZY_SETS(List <Fuzzy_sets> _Fuzzy_sets, ref int i, ref string line)
        {
            Fuzzy_sets F_s = new Fuzzy_sets
            {
                Name = (Additional_functions.Trim(line, ref i, '(', ')')).Trim()
            };
            string temp = Additional_functions.ClearLine(ref i, line).Replace('\n', ' ').Replace('\r', ' ').Replace(" ", "");

            try{
                string[] Functions = temp.Split(',');
                int      k         = 0;
                foreach (var f in Functions)
                {
                    F_s.Functions.Add(new Trapeze(
                                          Additional_functions.ToLine(Additional_functions.Trim(f, ref k, '[', ']'), Additional_functions.Trim(f, ref k, '[', ']')),
                                          Additional_functions.ToLine(Additional_functions.Trim(f, ref k, '[', ']'), Additional_functions.Trim(f, ref k, '[', ']'))
                                          ));
                    k = 0;
                }
                _Fuzzy_sets.Add(F_s);
            }
            catch {
                Stored_Exceptions.Add(new Exception("Error: _Fuzzy_sets exception, fuzzy sets number " + _Fuzzy_sets.Count + 1));
            }
        }
Esempio n. 6
0
        public static void Create_an_automatic_resume(List <Test> TESTS, List <Answers_to_Test> Answers_to_all_tests, string FileName)
        {
            List <List <double> > Keys_value_all = new List <List <double> >(); // all points on the scales

            for (int test_number = 0; test_number < TESTS.Count; ++test_number)
            {
                Keys_value_all.Add(Descriptors_implementation._SUM_counting(TESTS[test_number]._Keys, Answers_to_all_tests[test_number]));
            }

            Dictionary_of_scales = new List <Dictionary <string, double> >();
            List <List <string> > Manifestations_all = new List <List <string> >(); // all Manifestations on the first and second level

            for (int test_number = 0; test_number < TESTS.Count; ++test_number)
            {
                Dictionary <string, double> newscale = new Dictionary <string, double>();
                Manifestations_all.Add(Test_parser_level_1_and_2(TESTS[test_number]._Scales, Keys_value_all[test_number], ref newscale));
                Dictionary_of_scales.Add(newscale);
            }

            List <string> characteristics = new List <string>(Additional_functions.Get_filenames(Setting.characteristics_path));
            List <Personal_characteristic> Personal_characteristics = new List <Personal_characteristic>();

            for (int number = 0; number < characteristics.Count; number++)
            {
                Personal_characteristics.Add(Test_parser_level_3(ref TESTS, characteristics[number], Dictionary_of_scales));
            }

            if (!Stored_Exceptions.Empty)
            {
                MessageBox.Show("Ошибка: резюме содержит ошибки!");
            }

            Save_automatic_resume(TESTS, Answers_to_all_tests, Manifestations_all, Personal_characteristics, FileName);
        }
Esempio n. 7
0
        public static void Loading_settings()
        {
            StreamReader sr;

            using (sr = new StreamReader(@"Resources\\setting.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    int    i;
                    string key = "";
                    for (i = 0; i < line.Length && line[i] != ' '; i++)
                    {
                        key += line[i];
                    }
                    switch (key)
                    {
                    case _location_tests:
                    {
                        key        = Additional_functions.ClearLine(ref i, line);
                        tests_path = $"..\\..\\{key}";
                        break;
                    }

                    case _database:
                    {
                        key           = Additional_functions.ClearLine(ref i, line);
                        database_path = $"..\\..\\{key}";
                        break;
                    }

                    case _design:
                    {
                        key         = Additional_functions.ClearLine(ref i, line);
                        design_path = $"..\\..\\{key}";
                        break;
                    }

                    case _personal_characteristics:
                    {
                        key = Additional_functions.ClearLine(ref i, line);
                        characteristics_path = $"..\\..\\{key}";
                        break;
                    }

                    case _theme:
                    {
                        key   = Additional_functions.ClearLine(ref i, line);
                        theme = key;
                        break;
                    }

                    default: { break; }
                    }
                }
            }
        }
Esempio n. 8
0
 private void Add_answer_on_form(int height, TextBox answer)
 {
     Additional_functions.Create_textbox(answer, question_textBox.Width - 95, 110, height);
     answer.Multiline  = true;
     answer.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     answer.Height     = 50;
     answer.Anchor     = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right));
     main_panel.Controls.Add(answer);
 }
Esempio n. 9
0
        public Test_selection()
        {
            InitializeComponent();

            const int Width_Button = 550, Height_Button = 45;

            BackgroundImage = Design.Background;
            Design.Design_for_label(label_SName);
            Design.Design_for_label(label_Name);
            Design.Design_for_label(label_PName);
            Design.Design_for_label(label_day);
            Design.Design_for_label(label_month);
            Design.Design_for_label(label_year);

            this.SuspendLayout(); //Временно приостанавливает логику компоновки для элемента управления.
            List <string> test_names = new List <string>(Additional_functions.Get_filenames(Setting.tests_path));

            Button[] Test_add_button = new Button[test_names.Count];
            Test_add_button[0] = new Button
            {
                Text   = test_names[0],
                Width  = Width_Button,
                Height = Height_Button,
                BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch,
                Font     = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))),
                Location = new Point(50, textBox4.Location.Y + textBox4.Height + 45)
            };
            Design.Design_for_button(Test_add_button[0]);
            Test_add_button[0].Click += new EventHandler(Button_add_test_Click);
            this.Controls.Add(Test_add_button[0]);
            for (int i = 1; i < test_names.Count; i++)
            {
                Test_add_button[i] = new Button
                {
                    Width = Width_Button, Height = Height_Button, Text = test_names[i],
                    BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch,
                    Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                };
                Test_add_button[i].Location = new Point(50, Test_add_button[i - 1].Location.Y + Test_add_button[i - 1].Height + 5);
                this.Controls.Add(Test_add_button[i]);
                Test_add_button[i].Click += new EventHandler(Button_add_test_Click);
                Design.Design_for_button(Test_add_button[i]);
            }
            Button StatTest = new Button {
                Width = Width_Button - 100, Height = Height_Button, Text = "Начать тестирование"
            };

            StatTest.Click += new EventHandler(StatTest_Click);
            Design.Design_for_button(StatTest);
            StatTest.Location = new Point(150, Test_add_button[Test_add_button.Length - 1].Location.Y + Test_add_button[Test_add_button.Length - 1].Height + 35);
            this.Controls.Add(StatTest);

            this.AutoScrollMargin = new System.Drawing.Size(0, 20);
            this.ResumeLayout(false);//
            this.Show();
        }
Esempio n. 10
0
        private void Create_file(Test TEST)
        {
            Random t        = new Random();
            string fileName = "";

            fileName = TEST._Header.Name;

            fileName = Additional_functions.Create_name_for_file(fileName);
            StreamWriter sr;

            sr = new StreamWriter(fileName = $"{Setting.tests_path}\\{fileName}.txt", true, Encoding.UTF8);
            sr.WriteLine($"{Descriptors._NAME} <{TEST._Header.Name }>");
            sr.WriteLine($"{Descriptors._DESCRIPTION} <{TEST._Header.Description}>");
            sr.WriteLine($"{Descriptors._VERIFIER} <{TEST._Header.Verifier}>");
            for (int i = 0; i < TEST._Questions.Count; i++)
            {
                sr.WriteLine($"{Descriptors._QUESTION} <{TEST._Questions[i]._Question}>");
                for (int j = 0; j < TEST._Questions[i]._Answer.Count; j++)
                {
                    sr.WriteLine($"  {Descriptors._ANSWER} <{TEST._Questions[i]._Answer[j]}>");
                }
            }
            for (int i = 0; i < TEST._Keys.Count; i++)
            {
                sr.WriteLine($"{Descriptors._KEY} [{i}]<");
                for (int j = 0; j < TEST._Keys[i].Count - 1; j++)
                {
                    sr.WriteLine($"[{TEST._Keys[i][j].Question}]({TEST._Keys[i][j].Answer})={TEST._Keys[i][j].Point}+");
                }
                sr.WriteLine($"[{TEST._Keys[i][TEST._Keys[i].Count - 1].Question}]({TEST._Keys[i][TEST._Keys[i].Count - 1].Answer})={TEST._Keys[i][TEST._Keys[i].Count - 1].Point}>");
            }
            for (int i = 0; i < TEST._Scales.Count; i++)
            {
                sr.WriteLine($"{Descriptors._SCALE} [{TEST._Scales[i].If_scale}]({TEST._Scales[i].Name_scale}) ");
                sr.WriteLine($"<{TEST._Scales[i].Manifestation}>");
            }
            for (int i = 0; i < TEST._Fuzzy_sets.Count; i++)
            {
                sr.WriteLine(Descriptors._FUZZY_SETS + " (" + TEST._Fuzzy_sets[i].Name + ") <");
                for (int j = 0; j < TEST._Fuzzy_sets[i].Functions.Count - 1; j++)
                {
                    sr.Write($"[{TEST._Fuzzy_sets[i].Functions[j].Left_side.A.X};{TEST._Fuzzy_sets[i].Functions[j].Left_side.A.Y}]");
                    sr.Write($"[{TEST._Fuzzy_sets[i].Functions[j].Left_side.B.X};{TEST._Fuzzy_sets[i].Functions[j].Left_side.B.Y}]");
                    sr.Write($"[{TEST._Fuzzy_sets[i].Functions[j].Right_side.A.X};{TEST._Fuzzy_sets[i].Functions[j].Right_side.A.Y}]");
                    sr.WriteLine($"[{TEST._Fuzzy_sets[i].Functions[j].Right_side.B.X};{TEST._Fuzzy_sets[i].Functions[j].Right_side.B.Y}],");
                }
                sr.Write($"[{TEST._Fuzzy_sets[i].Functions[TEST._Fuzzy_sets[i].Functions.Count - 1].Left_side.A.X};{TEST._Fuzzy_sets[i].Functions[TEST._Fuzzy_sets[i].Functions.Count - 1].Left_side.A.Y}]");
                sr.Write($"[{TEST._Fuzzy_sets[i].Functions[TEST._Fuzzy_sets[i].Functions.Count - 1].Left_side.B.X};{TEST._Fuzzy_sets[i].Functions[TEST._Fuzzy_sets[i].Functions.Count - 1].Left_side.B.Y}]");
                sr.Write($"[{TEST._Fuzzy_sets[i].Functions[TEST._Fuzzy_sets[i].Functions.Count - 1].Right_side.A.X};{TEST._Fuzzy_sets[i].Functions[TEST._Fuzzy_sets[i].Functions.Count - 1].Right_side.A.Y}]");
                sr.WriteLine($"[{TEST._Fuzzy_sets[i].Functions[TEST._Fuzzy_sets[i].Functions.Count - 1].Right_side.B.X};{TEST._Fuzzy_sets[i].Functions[TEST._Fuzzy_sets[i].Functions.Count - 1].Right_side.B.Y}]>");
            }
            sr.Close();
            MessageBox.Show("Файл добавлен");
            this.Close();
        }
Esempio n. 11
0
        public static void _VERIFIER(Header _Header, ref int i, ref string line)
        {
            Enum.TryParse(Additional_functions.ClearLine(ref i, line), out VerificationDescriptors Descriptor);
            switch (Descriptor)
            {
            case VerificationDescriptors._ONLY_ONE: { _Header.Verifier = VerificationDescriptors._ONLY_ONE; break; }

            case VerificationDescriptors._AT_LEAST_ONE: { _Header.Verifier = VerificationDescriptors._AT_LEAST_ONE; break; }

            case VerificationDescriptors._NO_LIMITS: { _Header.Verifier = VerificationDescriptors._NO_LIMITS; break; }
            }
        }
Esempio n. 12
0
 private void Button_update_Click(object sender, EventArgs e)  // update Listbox
 {
     try
     {
         listBox_test_results.Items.Clear();
         List <string> names = new List <string>(Additional_functions.Get_filenames(Setting.database_path));
         for (int i = 0; i < names.Count; i++)
         {
             listBox_test_results.Items.Add(names[i]);
         }
     }
     catch
     {
         MessageBox.Show("Ошибка: БД результатов не найдена");
     }
 }
Esempio n. 13
0
        private void Add_row_on_form(int y, TextBox question, TextBox answer, TextBox point)
        {
            Additional_functions.Create_textbox(question, 100, 15, y);
            question.Height = 20;
            question.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top) | System.Windows.Forms.AnchorStyles.Left));
            main_panel.Controls.Add(question);

            Additional_functions.Create_textbox(answer, 100, 130, y);
            answer.Height = 20;
            answer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top) | System.Windows.Forms.AnchorStyles.Left));
            main_panel.Controls.Add(answer);

            Additional_functions.Create_textbox(point, 100, 245, y);
            point.Height = 20;
            point.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top) | System.Windows.Forms.AnchorStyles.Left));
            main_panel.Controls.Add(point);
        }
Esempio n. 14
0
        private void Add_textboxes_on_function_on_form(int height, TextBox L_x1, TextBox L_x2, TextBox R_x1, TextBox R_x2)
        {
            Additional_functions.Create_textbox(L_x1, 100, label_left_line.Location.X, height);
            L_x1.Anchor = ((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top) | System.Windows.Forms.AnchorStyles.Left);
            main_panel.Controls.Add(L_x1);

            Additional_functions.Create_textbox(L_x2, 100, L_x1.Location.X + L_x1.Width + 15, height);
            L_x2.Anchor = ((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top) | System.Windows.Forms.AnchorStyles.Left);
            main_panel.Controls.Add(L_x2);

            Additional_functions.Create_textbox(R_x1, 100, label_right_line.Location.X, height);
            R_x1.Anchor = ((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top) | System.Windows.Forms.AnchorStyles.Left);
            main_panel.Controls.Add(R_x1);

            Additional_functions.Create_textbox(R_x2, 100, R_x1.Location.X + R_x1.Width + 15, height);
            R_x2.Anchor = ((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top) | System.Windows.Forms.AnchorStyles.Left);
            main_panel.Controls.Add(R_x2);
        }
Esempio n. 15
0
        public static void _KEY(List <Key> _Keys, ref int i, ref string line)
        {
            string temp = Additional_functions.ClearLine(ref i, line);

            temp = temp.Replace('\n', ' ').Replace('\r', ' ').Replace(" ", "");
            try{
                Key      key  = new Key();
                string[] rows = temp.Split('+');
                foreach (var row in rows)
                {
                    int k = 0;
                    key.Add(new Element(
                                Convert.ToInt32(Additional_functions.Trim(row, ref k, '[', ']')),
                                Convert.ToInt32(Additional_functions.Trim(row, ref k, '(', ')')),
                                Convert.ToSingle(Additional_functions.Trim(row, ref k, '=', '*').Replace('.', ','))
                                ));
                }
                _Keys.Add(key);
            }
            catch {
                Stored_Exceptions.Add(new Exception("Error: _Keys exception, key number " + _Keys.Count + 1));
            }
        }
Esempio n. 16
0
        public Form3()
        {
            InitializeComponent();
            this.BackgroundImage = Design.Background;
            this.Show();
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            try
            {
                listBox_tests.Items.Clear();
                List <string> names = new List <string>(Additional_functions.Get_filenames(Setting.tests_path));
                for (int i = 0; i < names.Count; i++)
                {
                    listBox_tests.Items.Add(names[i]);
                }
            }
            catch
            {
                MessageBox.Show("Ошибка: БД тестов не найдена");
                this.Close();
                return;
            }
        }
Esempio n. 17
0
 public static string _SCALE_counting(Scale _Scale, List <double> Key_value, Dictionary <string, double> newscale)
 {
     try{
         string expression = _Scale.If_scale;
         expression = Additional_functions.Replace_Point(expression, Key_value);
         expression = expression.Replace(',', '.');
         if (!newscale.Keys.Contains(_Scale.Name_scale)) // add new name scale
         {
             string tmp = Additional_functions.Split_for_value(expression);
             tmp = Additional_functions.Clean_for_compilation(tmp);
             double point = Convert.ToSingle(Additional_functions.Verification_of_conditions(Constants_for_the_compiler.Begin_C, tmp, Constants_for_the_compiler.End));
             newscale.Add(_Scale.Name_scale, point);
         }
         if (Convert.ToBoolean(Additional_functions.Verification_of_conditions(Constants_for_the_compiler.Begin_V, expression, Constants_for_the_compiler.End)))
         {
             return("(" + _Scale.Name_scale + ") " + "Баллов - " + Convert.ToString(newscale[_Scale.Name_scale]) + "\r\n" + _Scale.Manifestation);
         }
         return(null);
     }
     catch {
         Stored_Exceptions.Add(new Exception("Error: internal format is not correct"));
         return(null);
     }
 }
Esempio n. 18
0
 public static void _DESCRIPTION(Header _Header, ref int i, ref string line) => _Header.Description = Additional_functions.ClearLine(ref i, line);
Esempio n. 19
0
 public static void _GROUP(List <Group> Groups, ref int i, ref string line)
 {
     Groups.Add(new Group());
     Groups[Groups.Count - 1].Manifestation = Additional_functions.ClearLine(ref i, line, '<', '>', false);
 }
Esempio n. 20
0
 public static void _GET_RESULT(ref int i, string line, out string result)
 {
     result = Additional_functions.ClearLine(ref i, line);
 }
Esempio n. 21
0
 public static void _NAME(Header _Header, ref int i, ref string line) => _Header.Name = Additional_functions.ClearLine(ref i, line);
Esempio n. 22
0
 public static void _ANSWER(List <Question> _Questions, ref int i, ref string line)
 {
     _Questions[_Questions.Count - 1]._Answer.Add(Additional_functions.ClearLine(ref i, line));
 }
Esempio n. 23
0
 public static void _QUESTION(List <Question> _Questions, ref int i, ref string line)
 {
     _Questions.Add(new Question());
     _Questions[_Questions.Count - 1]._Question = Additional_functions.ClearLine(ref i, line);
 }