public async Task <bool> DeleteTestQuestion(int id)
        {
            var test_question = await testQuestionRepository.GetQuestion(id);

            var test = await testRepository.GetTest(test_question.TestId);

            var question = await testQuestionRepository.GetQuestion(id);

            if (question == null)
            {
                return(false);
            }
            if ((int)test_question.Complexity == 3)
            {
                test.TimeOfTest -= 5;
            }
            else if ((int)test_question.Complexity == 2)
            {
                test.TimeOfTest -= 3;
            }
            else if ((int)test_question.Complexity == 1)
            {
                test.TimeOfTest -= 1;
            }
            question.isDelete = true;
            testRepository.Update(test);
            await testRepository.SaveChangesAsync();

            answersRepository.SetValueIsDeleteOnQuestion(question.NumberOfIdentification);
            testQuestionRepository.Update(question);
            await testQuestionRepository.SaveChangesAsync();

            return(true);
        }
Пример #2
0
        public async Task <int> CountMaxScoreOfTest(List <ListOfTestQuestions> listOfTestQuestions)
        {
            var score = 0;

            for (var i = 0; i < listOfTestQuestions.Count; i++)
            {
                var question = await testQuestionRepository.GetQuestion(Int32.Parse(listOfTestQuestions[i].QuestionId));

                if ((int)question.Complexity == 1)
                {
                    score += 5;
                }
                else if ((int)question.Complexity == 2)
                {
                    score += 10;
                }
                else if ((int)question.Complexity == 3)
                {
                    score += 15;
                }
            }
            return(score);
        }