private void startButton_Click(object sender, EventArgs e) { this.Visible = false; currentTest = testName.SelectedItem.ToString(); currentVzvod = vzvodName.SelectedItem.ToString(); currentStudent = FIOName.SelectedItem.ToString(); currentCource = comboBoxChooseCourse.SelectedItem.ToString(); //Test currentTestInLists = new Test(); int index = 0; for (int i = 0; i < listOfFormDefaultTest.TestList.Count; i++) { if (listOfFormDefaultTest.TestList[i].Name.Equals(currentTest)) { index = i; } } if (radioButtonTestModeTest.Checked) { _formTest = new FormTest(currentTest, currentVzvod, currentStudent, currentCource); listFormTests.Add(_formTest); _formTest.initTest(listOfFormDefaultTest.TestList[index]); _formTest.Visible = true; _formTest.Text = "ТЕСТ. " + currentTest + ". " + currentVzvod + " взвод. " + "Студент " + currentStudent; } if (radioButtonTestModeStudy.Checked) { _formStudy = new FormStudy(currentTest, currentVzvod, currentStudent, currentCource); listFormStudy.Add(_formStudy); _formStudy.initTest(listOfFormDefaultTest.TestList[index]); _formStudy.Visible = true; _formStudy.Text = "ОБУЧЕНИЕ. " + currentTest + ". " + currentVzvod + " взвод. " + "Студент " + currentStudent; } }
public FormResults(FormTest formTest) { InitializeComponent(); this.MinimumSize = this.Size; this.MaximumSize = this.Size; _currentTest = formTest._currentTest; _currentVzvod = formTest._currentVzvod; _currentStudent = formTest._currentStudent; _currentCourse = formTest._currentCourse; _countRightAnswers = formTest.countRightAnswers; _countTasks = formTest._listTasksInTest.Count; _marks = formTest._marks; labelTestName.Text = _currentTest; labelVzvodName.Text = _currentVzvod; labelFIOName.Text = _currentStudent; labelCurrentCourse.Text = _currentCourse; labelTasksCount.Text = _countTasks.ToString(); labelTasksRight.Text = _countRightAnswers.ToString(); double percentRight = Math.Round((((float)_countRightAnswers / (float)_countTasks) * 100), 0, MidpointRounding.AwayFromZero); labelTasksPercent.Text = percentRight + "%".ToString(); //labelFinalMark if (percentRight >= _marks.Excellent) { labelFinalMark.Text = "Отлично"; labelFinalMark.ForeColor = Color.Green; } else if (percentRight >= _marks.Good) { labelFinalMark.Text = "Хорошо"; labelFinalMark.ForeColor = Color.Blue; } else if (percentRight >= _marks.Satisfactory) { labelFinalMark.Text = "Удовлетворительно"; labelFinalMark.ForeColor = Color.Orange; } else if (percentRight < _marks.Satisfactory) { labelFinalMark.Text = "Неудовлетворительно"; labelFinalMark.ForeColor = Color.Red; } var json = JsonConvert.SerializeObject(new Result { Mark = labelFinalMark.Text, Platoon = labelVzvodName.Text, StudentName = labelFIOName.Text, TestName = labelTestName.Text, Timestamp = DateTime.Now, ResultType = "Экзамен", Course = labelCurrentCourse.Text }); var connectToServer = SendMessageFromServer(json); if (connectToServer) { return; } var path = "res.data"; var results = new List <Result>(); if (File.Exists(path)) { try { results = JsonConvert.DeserializeObject <List <Result> >(File.ReadAllText(path)); } catch (Exception) { } } results.Add(new Result { Mark = "Пройдено", Platoon = labelVzvodName.Text, StudentName = labelFIOName.Text, TestName = labelTestName.Text, Timestamp = DateTime.Now, ResultType = "Тренировка", Course = labelCurrentCourse.Text }); File.WriteAllText(path, JsonConvert.SerializeObject(results)); }