コード例 #1
0
        public List <GroupWithStudentsWithAttemptsOutputModel> ConvertStudentsVSTestsDTOAndTeacherGroupsWithStudentsDTOToGroupWithStudentsWithAttemptsOutputModel(List <StudentsVSTestsDTO> students, List <TeacherGroupsWithStudentsDTO> groups, List <TestDTO> tests)
        {
            List <GroupWithStudentsWithAttemptsOutputModel> result = new List <GroupWithStudentsWithAttemptsOutputModel>();

            foreach (var a in groups)
            {
                if (a != null)
                {
                    GroupWithStudentsWithAttemptsOutputModel tmp = new GroupWithStudentsWithAttemptsOutputModel()
                    {
                        Id        = a.GroupID,
                        Name      = a.GroupName,
                        EndDate   = a.EndDate,
                        StartDate = a.StartDate,
                        Students  = new List <StudentOutputModel>()
                    };
                    foreach (var b in a.Students)
                    {
                        if (b != null)
                        {
                            StudentOutputModel tmp2 = new StudentOutputModel()
                            {
                                ID        = b.ID,
                                FirstName = b.FirstName,
                                LastName  = b.LastName,
                                DTO       = new List <TestAttemptOutputModel>()
                            };
                            foreach (var c in students)
                            {
                                if (tmp2.ID == c.Id)
                                {
                                    TestAttemptOutputModel tmp3 = new TestAttemptOutputModel()
                                    {
                                        AttemptCount = c.NumberOfAttempts,
                                        Name         = c.TestName,
                                        BestResult   = c.MaxResult,
                                        ID           = c.TestId,
                                    };
                                    foreach (var t in tests)
                                    {
                                        if (t.ID == tmp3.ID)
                                        {
                                            tmp3.SuccessScore = Convert.ToInt32(t.SuccessScore);
                                        }
                                    }
                                    tmp2.DTO.Add(tmp3);
                                }
                            }

                            tmp.Students.Add(tmp2);
                        }
                    }
                    result.Add(tmp);
                }
            }
            return(result);
        }
コード例 #2
0
        public IActionResult GetStudentTestsByUserId(int userId)
        {
            StudentDataAccess     student = new StudentDataAccess();
            Mapper                mapper  = new Mapper();
            List <TestAttemptDTO> tests   = student.GetCompleteTests(userId);

            tests.AddRange(student.GetIncompleteTests(userId));
            StudentOutputModel model = mapper.ConvertUserDTOTestAttemptDTOToStudentModel(student.GetUser(userId), mapper.ConvertTestAttemptDTOToTestAttemptModel(tests));

            return(Ok(model));
        }
コード例 #3
0
        public StudentOutputModel ConvertUserDTOTestAttemptDTOToStudentModel(UserDTO user, List <TestAttemptOutputModel> tests)
        {
            StudentOutputModel student = new StudentOutputModel(user.ID, user.FirstName, user.LastName, tests);

            return(student);
        }