Exemple #1
0
        public JsonResult GetStudentResults(int subjectId)
        {
            var results = TestPassingService.GetStidentResults(subjectId, CurrentUserId).GroupBy(g => g.TestName).Select(group => new
            {
                Title  = group.Key,
                Points = group.Last().Points
            });

            return(Json(results, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public JsonResult GetAvailableTests(int subjectId)
        {
            var availableTests = TestPassingService.GetAvailableTestsForStudent(CurrentUserId, subjectId)
                                 .Select(test => new
            {
                Id          = test.Id,
                Title       = test.Title,
                Description = test.Description
            });

            return(Json(availableTests, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public JsonResult GetControlItems(int subjectId)
        {
            RealTimePassingResult[] passingResults = TestPassingService.GetRealTimePassingResults(subjectId).Where(result => result.PassResults.Count() > 0).ToArray();
            var groupedResults = passingResults.GroupBy(result => result.TestName).ToArray();

            var results = groupedResults.Select(result => new
            {
                Test     = result.Key,
                Students = result.ToArray()
            }).ToArray();

            return(Json(results, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        public ActionResult StudentsTesting(int subjectId)
        {
            Subject subject   = SubjectsManagementService.GetSubject(subjectId);
            bool    available = TestPassingService.CheckForSubjectAvailableForStudent(CurrentUserId, subjectId);

            if (available)
            {
                return(View(subject));
            }
            else
            {
                ViewBag.Message = "Данный предмет не доступен для студента";
                return(View("Error"));
            }
        }
        public PartialViewResult GetNextQuestion(int testId, int questionNumber)
        {
            if (questionNumber == 1 && TestsManagementService.GetTest(testId, true).Questions.Count == 0)
            {
                ViewBag.Message = "Тест не содержит ни одного вопроса";
                return(PartialView("Error"));
            }

            NextQuestionResult nextQuestion = TestPassingService.GetNextQuestion(testId, CurrentUserId, questionNumber);

            if (nextQuestion.Question == null)
            {
                ViewBag.Mark = nextQuestion.Mark;
                return(PartialView("EndTest", nextQuestion.QuestionsStatuses));
            }

            return(PartialView("GetNextQuestion", nextQuestion));
        }
Exemple #6
0
        public ActionResult ChangeLockForUserForStudent(int testId, int studentId, bool unlocked)
        {
            TestsManagementService.UnlockTestForStudent(testId, studentId, unlocked);
            if (unlocked)
            {
                TestPassResult passedByUser = TestPassingService.GetTestPassingTime(testId, studentId);
                if (passedByUser != null)
                {
                    Student student = StudentManagementService.GetStudent(studentId);
                    return(Json(new
                    {
                        PassedTime = passedByUser.StartTime.ToShortDateString(),
                        Test = TestsManagementService.GetTest(testId).Title,
                        Student = string.Format("{0} {1}", student.FirstName, student.LastName),
                        Points = passedByUser.Points
                    }));
                }
            }

            return(Json("Ok"));
        }
Exemple #7
0
        public GroupsResult GetGroups(string subjectId)
        {
            try
            {
                var id     = int.Parse(subjectId);
                var groups =
                    GroupManagementService.GetGroups(new Query <Group>(e => e.SubjectGroups.Any(x => x.SubjectId == id))
                                                     .Include(e => e.Students.Select(x => x.LecturesVisitMarks))
                                                     .Include(e => e.Students.Select(x => x.StudentPracticalMarks))
                                                     .Include(e => e.Students.Select(x => x.User))
                                                     .Include(e => e.Students.Select(x => x.ScheduleProtectionPracticalMarks))
                                                     .Include(e => e.ScheduleProtectionPracticals)).ToList();

                var model = new List <GroupsViewData>();

                var labsData       = SubjectManagementService.GetSubject(int.Parse(subjectId)).Labs.OrderBy(e => e.Order).ToList();
                var practicalsData = new List <Practical>();
                var isPractModule  =
                    SubjectManagementService.GetSubject(int.Parse(subjectId)).SubjectModules.Any(e => e.ModuleId == 13);
                if (isPractModule)
                {
                    practicalsData = SubjectManagementService.GetSubject(int.Parse(subjectId)).Practicals.OrderBy(e => e.Order).ToList();
                }

                foreach (Group group in groups)
                {
                    IList <SubGroup> subGroups = this.SubjectManagementService.GetSubGroups(id, group.Id);

                    var subjectIntId = int.Parse(subjectId);

                    var userLabsFile = SubjectManagementService.GetUserLabFiles(0, subjectIntId);

                    var lecturesVisitingData = SubjectManagementService.GetScheduleVisitings(new Query <LecturesScheduleVisiting>(e => e.SubjectId == subjectIntId)).OrderBy(e => e.Date);

                    var lecturesVisiting = new List <LecturesMarkVisitingViewData>();

                    var scheduleProtectionPracticals =
                        group.ScheduleProtectionPracticals.Where(e => e.SubjectId == subjectIntId && e.GroupId == group.Id)
                        .ToList().OrderBy(e => e.Date)
                        .ToList();

                    foreach (var student in group.Students.OrderBy(e => e.FullName))
                    {
                        var data = new List <MarkViewData>();

                        foreach (var lecturesScheduleVisiting in lecturesVisitingData.OrderBy(e => e.Date))
                        {
                            if (
                                student.LecturesVisitMarks.Any(
                                    e => e.LecturesScheduleVisitingId == lecturesScheduleVisiting.Id))
                            {
                                data.Add(new MarkViewData
                                {
                                    Date           = lecturesScheduleVisiting.Date.ToShortDateString(),
                                    LecuresVisitId = lecturesScheduleVisiting.Id,
                                    Mark           = student.LecturesVisitMarks.FirstOrDefault(e => e.LecturesScheduleVisitingId == lecturesScheduleVisiting.Id).Mark,
                                    MarkId         = student.LecturesVisitMarks.FirstOrDefault(e => e.LecturesScheduleVisitingId == lecturesScheduleVisiting.Id).Id
                                });
                            }
                            else
                            {
                                data.Add(new MarkViewData
                                {
                                    Date           = lecturesScheduleVisiting.Date.ToShortDateString(),
                                    LecuresVisitId = lecturesScheduleVisiting.Id,
                                    Mark           = string.Empty,
                                    MarkId         = 0
                                });
                            }
                        }

                        lecturesVisiting.Add(new LecturesMarkVisitingViewData
                        {
                            StudentId   = student.Id,
                            StudentName = student.FullName,
                            Login       = student.User.UserName,
                            Marks       = data
                        });
                    }

                    //first subGroupLabs
                    var labsFirstSubGroup = labsData.Select(e => new LabsViewData
                    {
                        Theme     = e.Theme,
                        Order     = e.Order,
                        Duration  = e.Duration,
                        ShortName = e.ShortName,
                        ScheduleProtectionLabsRecomend = subGroups.Any() ? subGroups.FirstOrDefault().ScheduleProtectionLabs.OrderBy(x => x.Date)
                                                         .Select(x => new ScheduleProtectionLab {
                            ScheduleProtectionId = x.Id, Mark = string.Empty
                        }).ToList() : new List <ScheduleProtectionLab>()
                    }).ToList();

                    var durationCount = 0;

                    foreach (var lab in labsFirstSubGroup)
                    {
                        var mark = 10;
                        durationCount += lab.Duration / 2;
                        for (int i = 0; i < lab.ScheduleProtectionLabsRecomend.Count; i++)
                        {
                            if (i + 1 > durationCount - (lab.Duration / 2))
                            {
                                lab.ScheduleProtectionLabsRecomend[i].Mark = mark.ToString(CultureInfo.InvariantCulture);

                                if (i + 1 >= durationCount)
                                {
                                    if (mark != 0)
                                    {
                                        mark -= 1;
                                    }
                                }
                            }
                        }
                    }

                    //second subGroupLabs
                    var labsSecondSubGroup = labsData.Select(e => new LabsViewData
                    {
                        Theme     = e.Theme,
                        Order     = e.Order,
                        Duration  = e.Duration,
                        ShortName = e.ShortName,
                        ScheduleProtectionLabsRecomend = subGroups.Any() ?
                                                         subGroups.LastOrDefault()
                                                         .ScheduleProtectionLabs.OrderBy(x => x.Date)
                                                         .Select(x => new ScheduleProtectionLab {
                            ScheduleProtectionId = x.Id, Mark = string.Empty
                        })
                                                         .ToList() : new List <ScheduleProtectionLab>()
                    }).ToList();
                    durationCount = 0;
                    foreach (var lab in labsSecondSubGroup)
                    {
                        var mark = 10;
                        durationCount += lab.Duration / 2;
                        for (int i = 0; i < lab.ScheduleProtectionLabsRecomend.Count; i++)
                        {
                            if (i + 1 > durationCount - (lab.Duration / 2))
                            {
                                lab.ScheduleProtectionLabsRecomend[i].Mark = mark.ToString(CultureInfo.InvariantCulture);

                                if (i + 1 >= durationCount)
                                {
                                    if (mark != 0)
                                    {
                                        mark -= 1;
                                    }
                                }
                            }
                        }
                    }

                    model.Add(new GroupsViewData
                    {
                        GroupId                      = group.Id,
                        GroupName                    = group.Name,
                        LecturesMarkVisiting         = lecturesVisiting,
                        ScheduleProtectionPracticals = scheduleProtectionPracticals.Select(e => new ScheduleProtectionPracticalViewData
                        {
                            GroupId   = e.GroupId,
                            Date      = e.Date.ToShortDateString(),
                            SubjectId = e.SubjectId,
                            ScheduleProtectionPracticalId = e.Id
                        }).ToList(),
                        Students     = group.Students.OrderBy(e => e.LastName).Select(e => new StudentsViewData(null, e, null, scheduleProtectionPracticals, null, practicalsData)).ToList(),
                        SubGroupsOne = subGroups.Any() ? new SubGroupsViewData
                        {
                            GroupId = group.Id,
                            Name    = "Подгруппа 1",
                            Labs    = labsFirstSubGroup,
                            ScheduleProtectionLabs = subGroups.FirstOrDefault().ScheduleProtectionLabs.OrderBy(e => e.Date).Select(e => new ScheduleProtectionLabsViewData(e)).ToList(),
                            SubGroupId             = subGroups.FirstOrDefault().Id,
                            Students = subGroups.FirstOrDefault().SubjectStudents.OrderBy(e => e.Student.LastName).Select(e => new StudentsViewData(TestPassingService.GetStidentResults(subjectIntId, e.StudentId), e.Student, subGroups.FirstOrDefault().ScheduleProtectionLabs.OrderBy(x => x.Date).ToList(), null, labsData, null, userLabsFile.Where(x => x.UserId == e.StudentId).Select(t => new UserlabFilesViewData()
                            {
                                Comments = t.Comments, Date = t.Date != null ? t.Date.Value.ToString("dd.MM.yyyy HH:mm") : string.Empty, Id = t.Id, PathFile = t.Attachments, Attachments = FilesManagementService.GetAttachments(t.Attachments).ToList()
                            }).ToList())).ToList()
                        }
                                                         : null,
                        SubGroupsTwo = subGroups.Any() ? new SubGroupsViewData
                        {
                            GroupId = group.Id,
                            Name    = "Подгруппа 2",
                            Labs    = labsSecondSubGroup,
                            ScheduleProtectionLabs = subGroups.LastOrDefault().ScheduleProtectionLabs.OrderBy(e => e.Date).Select(e => new ScheduleProtectionLabsViewData(e)).ToList(),
                            SubGroupId             = subGroups.LastOrDefault().Id,
                            Students = subGroups.LastOrDefault().SubjectStudents.OrderBy(e => e.Student.LastName).Select(e => new StudentsViewData(TestPassingService.GetStidentResults(subjectIntId, e.StudentId), e.Student, subGroups.LastOrDefault().ScheduleProtectionLabs.OrderBy(x => x.Date).ToList(), null, labsData, null, userLabsFile.Where(x => x.UserId == e.StudentId).Select(t => new UserlabFilesViewData()
                            {
                                Comments = t.Comments, Date = t.Date != null ? t.Date.Value.ToString("dd.MM.yyyy HH:mm") : string.Empty, Id = t.Id, PathFile = t.Attachments, Attachments = FilesManagementService.GetAttachments(t.Attachments).ToList()
                            }).ToList())).ToList()
                        }
                                                          : null
                    });
                }

                if (!isPractModule)
                {
                    foreach (var groupsViewData in model)
                    {
                        foreach (var student in groupsViewData.Students)
                        {
                            student.PracticalVisitingMark = new List <PracticalVisitingMarkViewData>();
                            student.PracticalMarkTotal    = "-";
                        }
                    }
                }

                return(new GroupsResult
                {
                    Groups = model,
                    Message = "Группы успешно загружены",
                    Code = "200"
                });
            }
            catch (Exception ex)
            {
                return(new GroupsResult()
                {
                    Message = ex.Message + "\n" + ex.StackTrace,
                    Code = "500"
                });
            }
        }
Exemple #8
0
        public JsonResult GetResults(int groupId, int subjectId)
        {
            TestResultItemListViewModel[] results = TestPassingService.GetPassTestResults(groupId, subjectId).Select(TestResultItemListViewModel.FromStudent).OrderBy(res => res.StudentName).ToArray();

            return(Json(results, JsonRequestBehavior.AllowGet));
        }
Exemple #9
0
        public JsonResult AnswerQuestionAndGetNext(IEnumerable <AnswerViewModel> answers, int testId, int questionNumber)
        {
            TestPassingService.MakeUserAnswer(answers != null && answers.Any() ? answers.Select(answerModel => answerModel.ToAnswer()) : null, CurrentUserId, testId, questionNumber);

            return(Json("Ok"));
        }