/// <summary> /// multipleChoice_Clicked Method /// Adds a Multiple Choice Canvas to the grid /// Initializes a new Multiple Choice questions /// </summary> /// <param name="sender">button handler</param> /// <param name="e">button handler</param> private void multipleChoice_Clicked(object sender, RoutedEventArgs e) { if (misClick == true) { misClick = false; } else { QuestionsCanvasTemplate.Children.Clear(); double height = QuestionsCanvasTemplate.ActualHeight; double width = QuestionsCanvasTemplate.ActualWidth; McCanvas = new MultipleChoiceCanvas(height, width); QuestionsCanvasTemplate.Children.Add(McCanvas.BottomCanvas); this.DeckQuestion = new Question("MC"); } }
/// <summary> /// DisplayQuestion method /// This method sets the QuestionCanvasTemplate to match the /// type of question passed in. It the fills in the question /// text box and the appropriate answer template for True False, /// Multiple Choice and Fill In The Blank questions /// </summary> /// <param name="ques">type of Question, cannot be null and needs a QuestionType</param> void DisplayQuestion(Question ques) { QuestionsCanvasTemplate.Children.Clear(); double height = QuestionsCanvasTemplate.ActualHeight; double width = QuestionsCanvasTemplate.ActualWidth; // Sets the QuestionsCanvasTemplate to Fill In The Blank Template Canvas // when a QuetionType.FillInBlank from the Question ques has been passed in if (ques.typeQuestion == Question.QuestionType.FillInBlank) { FibCanvas = new FillInBlankCanvas(height, width); QuestionsCanvasTemplate.Children.Add(FibCanvas.BottomCanvas); FibCanvas.Tb1.Text = ques.QuestionText; FibCanvas.Tb1.Background = new SolidColorBrush(Color.FromRgb(246, 246, 246)); FibCanvas.Tb1.BorderThickness = new System.Windows.Thickness(0); FibCanvas.Tb1.IsReadOnly = true; } // Sets the QuestionsCanvasTemplate to True False Template Canvas // when a QuetionType.TrueFalse from the Question ques has been passed in if (ques.typeQuestion == Question.QuestionType.TrueFalse) { tfCanvas = new TrueFalseCanvas(height, width); QuestionsCanvasTemplate.Children.Add(tfCanvas.BottomCanvas); TfCanvas.QuestionBox.Text = ques.QuestionText; TfCanvas.QuestionBox.Background = new SolidColorBrush(Color.FromRgb(246, 246, 246)); TfCanvas.QuestionBox.BorderThickness = new System.Windows.Thickness(0); tfCanvas.QuestionBox.IsReadOnly = true; } // Sets the QuestionsCanvasTemplate to Multiple Choice Template Canvas // when a QuetionType.MultipleChoice from the Question ques has been passed in if (ques.typeQuestion == Question.QuestionType.MultipleChoice) { McCanvas = new MultipleChoiceCanvas(height, width); QuestionsCanvasTemplate.Children.Add(McCanvas.BottomCanvas); McCanvas.QuestionBox.Text = ques.QuestionText; McCanvas.QuestionBox.BorderThickness = new System.Windows.Thickness(0); McCanvas.QuestionBox.IsReadOnly = true; McCanvas.QuestionBox.Background = new SolidColorBrush(Color.FromRgb(246, 246, 246)); for (int i = 0; i < 5; i++) { if (i < ques.MCAnswers.Choices.Count) { McCanvas.AnswerBoxes[i].Text = ques.MCAnswers.Choices[i]; McCanvas.AnswerBoxes[i].BorderThickness = new System.Windows.Thickness(0); McCanvas.AnswerBoxes[i].IsReadOnly = true; McCanvas.AnswerBoxes[i].Background = new SolidColorBrush(Color.FromRgb(246, 246, 246)); } else { McCanvas.AnswerBoxes[i].Visibility = Visibility.Hidden; McCanvas.AnswerButtons[i].Visibility = Visibility.Hidden; McCanvas.AnswerBoxes[i].BorderThickness = new System.Windows.Thickness(0); McCanvas.AnswerBoxes[i].IsReadOnly = true; McCanvas.AnswerBoxes[i].Background = new SolidColorBrush(Color.FromRgb(246, 246, 246)); } } } }