Ejemplo n.º 1
0
        /// <summary>
        /// Refreshes all the question user controls
        /// </summary>
        private void RefreshQuestions()
        {
            TestTotal.Text = $"Total Marks: {TestController.GetTotalMarks(_testId)}";
            StackPanel.Children.Clear();

            var questions = TestController.GetQuestions(_testId);

            for (int i = 0; i < questions.Count; i++)
            {
                QuestionUserControl question = GetUserControl(questions[i], i);
                StackPanel.Children.Add(question);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new user control
        /// </summary>
        /// <param name="question">The question to add to the user control</param>
        /// <param name="i">The question number</param>
        private QuestionUserControl GetUserControl(Question question, int i)
        {
            QuestionUserControl questionUserControl = new QuestionUserControl();

            //  Initialize the controls
            questionUserControl.InitControls(question, i);

            //  Subscribe the edit and delete button to the button click event
            questionUserControl.Edit.Click += Button_Click_Edit;
            questionUserControl.Edit.Tag    = question.Question_ID;

            questionUserControl.Delete.Click += Button_Click_Delete;
            questionUserControl.Delete.Tag    = question.Question_ID;

            return(questionUserControl);
        }