コード例 #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);
        }
コード例 #2
0
        private void ShowTestsOfSelectedCategories(int?idCategory)
        {
            this.ShowHeaderTest();

            this.ClearTheList();


            using (TestingSystemEntities db = new TestingSystemEntities())
            {
                List <Test> listTestsOfSelectedCategories = null;
                if (this.isTeacher)
                {
                    listTestsOfSelectedCategories
                        = this.GetListTestsOfSelectedCategories(idCategory, db);
                }
                else
                {
                    listTestsOfSelectedCategories
                        = this.GetListActiveTestsOfSelectedCategories(idCategory, db);
                }

                GridLineTest gridLineTest = null;

                for (int i = 0; i < listTestsOfSelectedCategories.Count(); i++)
                {
                    gridLineTest
                        = new GridLineTest(
                              i,
                              listTestsOfSelectedCategories[i],
                              this.isTeacher
                              );


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

                    // Обработчик нажатия на название теста (Test).
                    (gridLineTest.Children[0] as Button).Click += ButtonInGridLineTest_Click;

                    if (this.isTeacher)
                    {
                        this.CreateEditingButtons(gridLineTest, listTestsOfSelectedCategories[i].Id);
                    }

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

                if (this.isTeacher)
                {
                    if (gridLineTest == null)
                    {
                        gridLineTest            = new GridLineTest();
                        gridLineTest.CategoryId = this.currentIdCategory;
                    }
                    this.CreateAddButton(gridLineTest);
                }
            }
        }
コード例 #3
0
        private void LaunchingTestQuestions(Button senderButton)
        {
            // Загрузить страницу прохождения теста
            this.gridSelection.Visibility = Visibility.Hidden;

            this.gridPassingTheTest.Visibility = Visibility.Visible;

            GridLineTest gridLineTest = senderButton.Parent as GridLineTest;


            this.textBlockPassing_Title.Text
                = gridLineTest.CategoryName
                  + " | "
                  + gridLineTest.TestName;


            this.answersToTheCurrentQuestion = new List <Answer>();

            using (TestingSystemEntities db = new TestingSystemEntities())
            {
                // Загружаем все активные вопросы текущего теста.
                this.questionsOfTheSelectedTest = (
                    from question in db.Question.Include("Answer")  // HACK или безотложная (много маленьких запросов)
                    where question.Test.Id == gridLineTest.TestID
                    where question.Active == true
                    select question
                    )
                                                  .ToList();

                // Загружаем ответы для активных вопросов теста.
                foreach (var item in this.questionsOfTheSelectedTest)
                {
                    this.answersToTheCurrentQuestion
                    .AddRange(item.Answer.Where(x => x.QuestionId == item.Id).Select(x => x));
                }


                this.ShowQuestionWithAnswers();
            }
        }