/// <summary> /// Checks the correctness of the equation and updates the propabilities for each number and the statistics of the user. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ConfirmButton_Click(object sender, EventArgs e) { keys.FixResult(); int index = (int)LeftNum.Value - 1; string lbl; string lbl2; if (CultureInfo.CurrentCulture.Name.Equals("en-EN")) { lbl = "Correct!"; lbl2 = "Wrong!"; } else { lbl = "Σωστό!"; lbl2 = "Λάθος!"; } if (LeftNum.Value * RightNum.Value == ResultNum.Value) { msglabel.Text = lbl; statistics[2 * index]++; msglabel.ForeColor = Color.Green; QuestionGroup.Visible = false; msglabel.Visible = true; Wait(); if (multipliers[index] > 0.9f) { fix_probabilities(index, "-", 0.9f); } } else { msglabel.Text = lbl2; statistics[(2 * index) + 1]++; msglabel.ForeColor = Color.Maroon; QuestionGroup.Visible = false; msglabel.Visible = true; Wait(); if (multipliers[index] <= 7.2) { fix_probabilities(index, "+", 1.8f); } CreateQuestion(); } for (int i = 0; i < probabilities.Length; i++) { Console.WriteLine(probabilities[i] + " , " + multipliers[i]); } Datamapper dm = new Datamapper(); dm.GetConnection(); dm.SaveMultipliers(multipliers, StartingForm.username); dm.SaveStats(probabilities, StartingForm.username); dm.SaveStatistics("Practice_Statistics", StartingForm.username, statistics, DateTime.Now); CreateQuestion(); }
/// <summary> /// Checks for the correctness of the equation and updates the statistics in the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ConfirmButton_Click(object sender, EventArgs e) { keys.FixResult(); int index = (int)LeftNum.Value - 1; if (LeftNum.Value * RightNum.Value == ResultNum.Value) { points++; msglabel.Text = lbl; statistics[2 * index]++; msglabel.ForeColor = Color.Green; QuestionGroup.Visible = false; msglabel.Visible = true; Wait(); } else { msglabel.Text = lbl2; statistics[(2 * index) + 1]++; msglabel.ForeColor = Color.Maroon; QuestionGroup.Visible = false; msglabel.Visible = true; Wait(); } if (ThisQuestionNum < TotalQuestionsNum) { ConfirmButton.Enabled = true; BackButton.Enabled = false; CreateQuestion(); } else { dm.GetConnection(); dm.SaveStatistics("Final_Statistics", StartingForm.username, statistics, DateTime.Now); if (CultureInfo.CurrentCulture.Name.Equals("en-EN")) { MessageBox.Show("You've got " + points.ToString() + " out of " + TotalQuestionsNum.ToString() + " correct answets!"); } else { MessageBox.Show("Απάντησες σωστά " + points.ToString() + " από τις " + TotalQuestionsNum.ToString() + " ερωτήσεις!"); } BackButton.Enabled = true; ConfirmButton.Enabled = false; } }
public StartingForm() { InitializeComponent(); dm = new Datamapper(); dm.GetConnection(); }
/// <summary> /// Refreshes the chart from database data depending on user selection. /// </summary> /// <param name="date"></param> public void refresh_chart(DateTime date) { if (datecombo.SelectedIndex == -1) { datecombo.SelectedIndex = 0; } int selected_el = datecombo.SelectedIndex; switch (selected_el) { case 1: date = date.AddMonths(-1); date = new DateTime(date.Year, date.Month, 1); break; case 2: date = date.AddMonths(-3); date = new DateTime(date.Year, date.Month, 1); break; case 3: date = new DateTime(date.Year, 1, 1); break; case 4: date = date.AddYears(-1); date = new DateTime(date.Year, 1, 1); break; default: date = new DateTime(date.Year, date.Month, 1); break; } string correct; string wrong; if (CultureInfo.CurrentCulture.Name.Equals("en-EN")) { correct = "Correct"; wrong = "Wrong"; } else { correct = "Σωστά"; wrong = "Λανθασμένα"; } corr_chart.Series[0].Name = correct; corr_chart.Series[1].Name = wrong; corr_chart.Series[correct].Points.Clear(); corr_chart.Series[wrong].Points.Clear(); Datamapper dm = new Datamapper(); dm.GetConnection(); List <(int, int)> differences = new List <(int, int)>(); int[] statistics; if (testcombo.SelectedIndex == 0) { statistics = dm.GetStatistics("Practice_Statistics", username, date); } else { statistics = dm.GetStatistics("Final_Statistics", username, date); } int label = 1; for (int i = 0; i < 20; i += 2) { corr_chart.Series[correct].Points.AddXY(label, statistics[i]); corr_chart.Series[wrong].Points.AddXY(label, statistics[i + 1]); if (statistics[i] < statistics[i + 1]) { differences.Add((label, statistics[i + 1] - statistics[i]));