Beispiel #1
0
        private bool IsNameAlreadyExists()
        {
            bool isExists = false;

            if (this.gridEditCategory.IsVisible == true)
            {
                isExists = GridLineCategory.IsNameAlreadyExists(this.textBoxCategoryName.Text);
            }
            else if (this.gridEditTest.IsVisible == true)
            {
                isExists = GridLineTest.IsNameAlreadyExists(
                    this.textBoxTestName.Text, this.entityParentId);
            }
            else if (this.gridEditQuestion.IsVisible == true)
            {
                isExists = GridLineQuestion.IsNameAlreadyExists(
                    this.textBoxQuestionName.Text, this.entityParentId);
            }
            else if (this.gridEditAnswer.IsVisible == true)
            {
                isExists = GridLineAnswer.IsNameAlreadyExists(
                    this.textBoxAnswerText.Text, this.entityParentId);
            }

            return(isExists);
        }
Beispiel #2
0
        /// <summary>
        /// Показать вопросы выбранного теста.
        /// </summary>
        /// <param name="idTest">Id выбранного теста.</param>
        private void ShowQuestionsOfSelectedOfTest(int idTest)
        {
            this.ShowHeaderQuestion();

            this.ClearTheList();


            using (TestingSystemEntities db = new TestingSystemEntities())
            {
                this.level = Level.QuestionsOfTheSelectedTest;

                var listOfQuestionsCurrentTest
                    = (
                          from question in db.Question.Include("Answer")
                          where question.TestId == idTest
                          select question
                          )
                      .ToList();

                GridLineQuestion gridLineQuestion = null;

                for (int i = 0; i < listOfQuestionsCurrentTest.Count(); i++)
                {
                    gridLineQuestion
                        = new GridLineQuestion(
                              i,
                              listOfQuestionsCurrentTest[i]
                              );

                    // Установить стиль кнопки внутри grid
                    (gridLineQuestion.Children[0] as Button).Style = (Style)(this.Resources["styleButtonForList"]);

                    // Обработчик нажатия на название Вопроса (Question).
                    (gridLineQuestion.Children[0] as Button).Click += ButtonInGridLineQuestion_Click;


                    this.CreateEditingButtons(gridLineQuestion, listOfQuestionsCurrentTest[i].Id);

                    this.stackPanelSelection.Children.Add(gridLineQuestion);
                }

                if (gridLineQuestion == null)
                {
                    gridLineQuestion        = new GridLineQuestion();
                    gridLineQuestion.TestId = this.currentIdTest;
                }

                if (this.isTeacher)
                {
                    this.CreateAddButton(gridLineQuestion);
                }
            }
        }