List<string> resolvedProblemQuestions = new List<string>(); // Used to store the problematic Questions for the pupil we are currently viewing #endregion Fields #region Constructors // When a new instance of a Teacher Form is created public TeacherForm() { InitializeComponent(); // Initialize the component UserDatabase userDB = new UserDatabase(); // Create a new instance of a userDatabase for reading purposes List<string> usernames = userDB.getUsernames(); // Extract usernames for all pupils from the database RadioButton[] pupilRadioButtons = new RadioButton[usernames.Count]; // Prepare an array of RadioButtons which is the size of the number of usernames for (int i = 0; i < usernames.Count; i++) // For each username in the list that has been read { if (usernames[i] == "Teacher") // If the current username is "Teacher" { continue; // Skip this username } pupilRadioButtons[i] = new RadioButton(); // Create a new RadioButton for this username pupilRadioButtons[i].Text = usernames[i]; // Set the text of the RadioButton to the current username pupilRadioButtons[i].Size = OverviewRadioButton.Size; // Set the size of the RadioButton to the same as the Size of the Overview button pupilRadioButtons[i].Font = new Font("Microsoft Sans Serif", 14); // Set the font of the RadioButton pupilRadioButtons[i].Click += new EventHandler(RadioButtonClicked); // Add a Click listener to the radio button that calls RadioButtonClicked when clicked PupilFlowLayoutPanel.Controls.Add(pupilRadioButtons[i]); // Add the RadioButton to the FlowLayoutPanel } }
private void OverviewButton_Click(object sender, EventArgs e) { SetSettingsEnabled(false); ViewProblemsButton.Enabled = false; ViewResolvedProblemsButton.Enabled = false; PlayerNameLabel.Text = "Player Name: N/A"; GameCompletedLabel.Text = "Game Completed?: N/A"; int averageTime = 0, averageT1Correct = 0, averageT2Correct = 0, averageT3Correct = 0, averageT1Mistakes = 0, averageT2Mistakes = 0, averageT3Mistakes = 0, averageProblems = 0, averageResolvedProblems = 0; UserDatabase userDB = new UserDatabase(); int numberValues = userDB.getUsernames().Count; foreach (string username in userDB.getUsernames()) { UserDatabase.GameCompletedDetails gameCompletedDetails = userDB.GetGameCompletedDetails(username); if (gameCompletedDetails.timeInSeconds > 0) { averageTime += gameCompletedDetails.timeInSeconds; } else { numberValues--; continue; } averageT1Correct += gameCompletedDetails.numCorrectAnswers[0]; averageT2Correct += gameCompletedDetails.numCorrectAnswers[1]; averageT3Correct += gameCompletedDetails.numCorrectAnswers[2]; averageT1Mistakes += gameCompletedDetails.numMistakes[0]; averageT2Mistakes += gameCompletedDetails.numMistakes[1]; averageT3Mistakes += gameCompletedDetails.numMistakes[2]; averageProblems += gameCompletedDetails.problemQuestions.Count; averageResolvedProblems += gameCompletedDetails.resolvedQuestions.Count; } averageTime = averageTime / numberValues; averageT1Correct = averageT1Correct / numberValues; averageT2Correct = averageT2Correct / numberValues; averageT3Correct = averageT3Correct / numberValues; averageT1Mistakes = averageT1Mistakes / numberValues; averageT2Mistakes = averageT2Mistakes / numberValues; averageT3Mistakes = averageT3Mistakes / numberValues; averageProblems = averageProblems / numberValues; averageResolvedProblems = averageResolvedProblems / numberValues; GameTimeLabel.Text = "Game Time: " + averageTime + " Seconds"; NumCorrectAnswersLabel.Text = "Number of Correct Answers:\n " + averageT1Correct + "\n " + averageT2Correct + "\n " + averageT3Correct; NumMistakesLabel.Text = "Number of Correct Answers:\n " + averageT1Mistakes + "\n " + averageT2Mistakes + "\n " + averageT3Mistakes; NumProblemQuestionsLabel.Text = "Number of Problem Questions:\n " + averageProblems; NumResolvedProblemsLabel.Text = "Number of Resolved Problems:\n " + averageResolvedProblems; }
private void SaveAllPupilsButton_Click(object sender, EventArgs e) { PupilSettingsQuestionEntryBox.SaveSetForAllPupils(activePupilUsername); UserDatabase userDB = new UserDatabase(); // Create a new instance of a User Database to save the buttons state List<string> usernames = userDB.getUsernames(); foreach (string name in usernames) { userDB.SetUserQuestionButtonState(name, SettingsBiologyT1Button.Enabled, SettingsOtherSubjectT1Button.Enabled, SettingsOtherSubjectT1Button.Text.Substring(0, SettingsOtherSubjectT1Button.Text.Length - 7)); // Update the button state in the new User Database } userDB.SaveDatabase(); MessageBox.Show("Details Saved for all pupils"); }