public TestEditor() { InitializeComponent(); RefreshAnswerEditList(int.Parse((string)((ComboBoxItem)answerAmountSelector.SelectedItem).Content)); Title = testName; current = new EditorQuestion(); }
private void SetQuestion(int index) { if (!question.Text.Equals("")) { foreach (DockPanel item in answerList.Children) { if (((TextBox)item.Children[2]).Text.Equals("")) { MessageBox.Show("There are some choices that are still empty. "); return; } } if (index == AppConstants.QUESTIONS.Count) { AppConstants.QUESTIONS.Add(current); } } if (qIndex > 0) { Previous.Visibility = Visibility.Visible; } AppConstants.QUESTIONS[index].SetQuestion(question.Text); AppConstants.QUESTIONS[index].removeAllChoices(); foreach (DockPanel item in answerList.Children) { // TODO make sure this works bool answer = (bool)((CheckBox)item.Children[0]).IsChecked; char key = ((string)((Label)item.Children[1]).Content)[0]; AppConstants.QUESTIONS[index].AddChoice(key, ((TextBox)item.Children[2]).Text); if (answer) { AppConstants.QUESTIONS[index].SetChoiceTrue(key); } } AppConstants.QUESTIONS[index].SetExplanation(explanation.Text + "\n"); current = new EditorQuestion(); question.Text = ""; explanation.Text = ""; addQImage.Content = "Add Image"; addQVideo.Content = "Add Video"; addImage.Content = "Add Image"; addVideo.Content = "Add Video"; if (!current.CheckQImageFile() && !current.CheckQVideoFile()) { qMediaFile.Text = "No media"; } else { qMediaFile.Text = ""; } if (!current.CheckAImageFile() && !current.CheckAVideoFile()) { mediaFile.Content = "No media"; } else { mediaFile.Content = ""; } if (current.CheckQImageFile()) { qMediaFile.Text += current.GetAImageFile().Split('\\').Last(); addQImage.Content = "Remove Image"; } if (current.CheckAImageFile() && current.CheckAVideoFile()) { qMediaFile.Text += ", "; } if (current.CheckAVideoFile()) { qMediaFile.Text += current.GetAVideoFile().Split('\\').Last(); addQVideo.Content = "Remove Video"; } if (current.CheckAImageFile()) { mediaFile.Content += current.GetAVideoFile().Split('\\').Last(); addImage.Content = "Remove Image"; } if (current.CheckAImageFile() && current.CheckAVideoFile()) { mediaFile.Content += ", "; } if (current.CheckAVideoFile()) { mediaFile.Content += current.GetAVideoFile().Split('\\').Last(); addVideo.Content = "Remove Video"; } RefreshAnswerEditList(int.Parse((string)((ComboBoxItem)answerAmountSelector.SelectedItem).Content)); }