Example #1
0
 private void CreateAttemptAnswersLists(InfoForStatisticsModel info)
 {
     foreach (var attempt in info.Attempts)
     {
         attempt.Value.Answers = new List <int>();
         foreach (var record in info.IdInfo)
         {
             if (attempt.Key == record.AnswerId)
             {
                 attempt.Value.Answers.Add(record.AttemptId);
             }
         }
     }
 }
Example #2
0
        private void CreateQuestionAnswersLists(InfoForStatisticsModel info)
        {
            AuthorDataAccess tests = new AuthorDataAccess();

            foreach (var question in info.Questions)
            {
                question.Value.AnswersId = new List <int>();
                question.Value.CorrectId = new List <int>();
                var answers = tests.GetAnswerByQuestionId(question.Key);
                foreach (var answer in answers)
                {
                    question.Value.AnswersId.Add(answer.ID);
                    if (answer.Correct == true)
                    {
                        question.Value.CorrectId.Add(answer.ID);
                    }
                }
            }
        }
Example #3
0
        private InfoForStatisticsModel Create(List <AttemptQuestionAnswerFullInformationDTO> data)
        {
            InfoForStatisticsModel info = new InfoForStatisticsModel();

            foreach (var item in data)
            {
                AttemptQuestionAnswerAllIdsModel idModel = new AttemptQuestionAnswerAllIdsModel
                {
                    AttemptId  = item.AttemptID,
                    QuestionId = item.QuestionID,
                    AnswerId   = item.AnswerID,
                    TestId     = item.TestID,
                    UserId     = item.UserID,
                    GroupId    = item.GroupID
                };
                info.IdInfo.Add(idModel);

                if (!info.Attempts.ContainsKey(item.AttemptID))
                {
                    AttemptInfoModel attemptInfo = new AttemptInfoModel()
                    {
                        Number     = item.AttemptNumber,
                        TestId     = item.TestID,
                        UserId     = item.UserID,
                        UserResult = item.UserResult,
                        Date       = item.AttemptDateTime,
                        Duration   = item.AttemptDurationTime
                    };
                    info.Attempts.Add(item.AttemptID, attemptInfo);
                }

                if (!info.Questions.ContainsKey(item.QuestionID))
                {
                    QuestionInfoModel questionInfo = new QuestionInfoModel()
                    {
                        TestId       = item.TestID,
                        Value        = item.QuestionValue,
                        TypeId       = item.TypeID,
                        AnswersCount = item.AnswersCount,
                        Weight       = item.Weight
                    };
                    info.Questions.Add(item.QuestionID, questionInfo);
                }

                if (!info.Answers.ContainsKey(item.AnswerID))
                {
                    AnswerInfoModel answerInfo = new AnswerInfoModel()
                    {
                        QuestionID = item.QuestionID,
                        Value      = item.Value,
                        Correct    = item.Correct
                    };
                    info.Answers.Add(item.AnswerID, answerInfo);
                }

                if (!info.TestSuccessScores.ContainsKey(item.TestID))
                {
                    info.TestSuccessScores.Add(item.TestID, item.SuccessScore);
                }
            }

            CreateAnswerAttemptsLists(info);
            CreateAttemptAnswersLists(info);
            CreateQuestionAnswersLists(info);
            return(info);
        }