public void GetPassedFailedStatsTest(int id)
        {
            TestStatistics    statistic = new TestStatistics(id);
            PassedFailedModel actual    = statistic.GetPassedFailedStats(id);
            TestExpectedMock  test      = new TestExpectedMock();
            PassedFailedModel expected  = test.GetPassedFailed(id);

            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public ActionResult <List <TestOutputModel> > GetAllTests()
        {
            Mapper           mapper = new Mapper();
            AuthorDataAccess tests  = new AuthorDataAccess();

            List <TestOutputModel> listOfModels = mapper.ConvertTestDTOToTestModelList(tests.GetAllTests());

            foreach (var i in listOfModels)
            {
                TestStatistics    statistics = new TestStatistics(i.ID);
                PassedFailedModel pfs        = statistics.GetPassedFailedStats(i.ID);
                i.AverageResult = statistics.GetAverageResults(i.ID);
                i.Passed        = pfs.Passed;
                i.Failed        = pfs.Failed;
                i.SuccessRate   = pfs.SuccessRate;
            }
            return(Ok(listOfModels));
        }
示例#3
0
        public ActionResult <TestOutputModel> GetTestAllInfoById(int testId)
        {
            Mapper           mapper       = new Mapper();
            AuthorDataAccess tests        = new AuthorDataAccess();
            var            test           = tests.GetTestById(testId);
            TestStatistics testStatistics = new TestStatistics(testId);

            if (test == null)
            {
                return(BadRequest("Теста не существует"));
            }
            TestOutputModel   model = mapper.ConvertTestDTOToTestOutputModel(tests.GetTestById(testId));
            PassedFailedModel pfs   = testStatistics.GetPassedFailedStats(testId);

            model.Questions     = mapper.ConvertQuestionDTOToQuestionModelList(tests.GetQuestionsByTestID(testId));
            model.Tags          = mapper.ConvertTagDTOToTagModelList(tests.GetTagsInTest(testId));
            model.AverageResult = testStatistics.GetAverageResults(testId);
            model.Passed        = pfs.Passed;
            model.Failed        = pfs.Failed;
            model.SuccessRate   = pfs.SuccessRate;
            foreach (QuestionOutputModel qModel in model.Questions)
            {
                qModel.Answers = mapper.ConvertAnswerDTOToAnswerModelList(tests.GetAnswerByQuestionId(qModel.ID));
                QuestionStatistics statistics = new QuestionStatistics(qModel.ID);
                qModel.PercentageOfCorrectlyAnswered = statistics.GetPercentageOfCorrectlyAnswered(qModel.ID);
                Dictionary <int, double> answersPercent = new Dictionary <int, double>();
                answersPercent = statistics.GetPercentageOfPeopleChoosingAnswer(qModel.ID);
                foreach (var answer in qModel.Answers)
                {
                    foreach (var i in answersPercent)
                    {
                        if (answer.ID == i.Key)
                        {
                            answer.PercentageOfPeopleChoosingAnswer = i.Value;
                        }
                        else
                        {
                            answer.PercentageOfPeopleChoosingAnswer = 0;
                        }
                    }
                }
            }
            return(Ok(model));
        }
示例#4
0
        public PassedFailedModel qq(int testId)
        {
            TestStatistics st = new TestStatistics(testId);

            return(st.GetPassedFailedStats(testId));
        }