示例#1
0
        public List <StudentGroupUser> GetStudentGroupUserList(string groupName)
        {
            StudentGroupUserList = new List <StudentGroupUser>();

            var groupId = new GroupManagementService().GetGroupByName(groupName).Id;

            var students = new StudentManagementService().GetGroupStudents(groupId).ToList();
            var number   = 1;

            foreach (var student in students)
            {
                StudentGroupUserList.Add(new StudentGroupUser
                {
                    Number             = number,
                    Name               = student.LastName + " " + student.FirstName + " " + student.MiddleName,
                    ProjectName        = GetProjectNameList(student.Id),
                    ProjectRole        = GetProjectRoleList(student.Id),
                    ProjectCreatorName = GetProjectCreatorNameList(student.Id),
                    QuentityOfProjects = GetProjectNameList(student.Id).Count()
                });
                number++;
            }

            return(StudentGroupUserList);
        }
        public ModulesScheduleProtectionLabsViewModel(int subjectId, Module module)
            : base(subjectId, module)
        {
            var subject        = SubjectManagementService.GetSubject(subjectId);
            var firstOrDefault = subject.SubjectGroups.FirstOrDefault();
            var defaultOr      = firstOrDefault?.SubGroups.FirstOrDefault();

            if (defaultOr != null)
            {
                SubGroupId = defaultOr.Id.ToString(CultureInfo.InvariantCulture);
            }

            var subjectGroup = subject.SubjectGroups.FirstOrDefault();

            if (subjectGroup != null)
            {
                GroupId = subjectGroup.GroupId.ToString(CultureInfo.InvariantCulture);
            }

            ScheduleProtectionLabs = subject.Labs
                                     .Select(e => new ScheduleProtectionLabsDataViewModel(e, int.Parse(SubGroupId))).ToList();

            var groups = GroupManagementService.GetGroups(
                new Query <Group>(e => e.SubjectGroups.Any(x => x.SubjectId == subjectId)).Include(e => e.Students));

            FillGroupsList(groups);
        }
示例#3
0
        public void ModifyStudent()
        {
            var groupId = int.Parse(Group);

            StudentManagementService.UpdateStudent(
                new Student
            {
                Id         = Id,
                FirstName  = Name,
                LastName   = Surname,
                MiddleName = Patronymic,
                Email      = Email,
                Confirmed  = true,
                GroupId    = groupId,
                Group      = GroupManagementService.GetGroup(groupId),
                User       = new User
                {
                    Avatar       = Avatar,
                    UserName     = UserName,
                    About        = About,
                    SkypeContact = SkypeContact,
                    Phone        = Phone,
                    Email        = Email,
                    Id           = Id
                }
            });
        }
示例#4
0
        public ProjectParticipationViewModel(int groupId)
        {
            var group = new GroupManagementService().GetGroup(groupId);

            GroupId = group.Name;
            StudentGroupUserList = GetStudentGroupUserList(GroupId);
        }
示例#5
0
        public StudentMarkForDateResult GetMarksCalendarData(string dateId, string subjectId, string groupId)
        {
            try
            {
                var subjectIntId = int.Parse(subjectId);
                var dateIntId    = int.Parse(dateId);
                var visitingDate =
                    SubjectManagementService.GetScheduleVisitings(
                        new Query <LecturesScheduleVisiting>(e => e.SubjectId == subjectIntId && e.Id == dateIntId)).FirstOrDefault();

                var group = GroupManagementService.GetGroup(int.Parse(groupId));
                var model = new List <StudentMarkForDateViewData>();
                foreach (var student in group.Students.OrderBy(e => e.FullName))
                {
                    if (student.LecturesVisitMarks.Any(e => e.LecturesScheduleVisitingId == visitingDate.Id))
                    {
                        model.Add(new StudentMarkForDateViewData
                        {
                            MarkId      = student.LecturesVisitMarks.FirstOrDefault(e => e.LecturesScheduleVisitingId == visitingDate.Id).Id,
                            StudentId   = student.Id,
                            Login       = student.User.UserName,
                            StudentName = student.FullName,
                            Mark        = student.LecturesVisitMarks.FirstOrDefault(e => e.LecturesScheduleVisitingId == visitingDate.Id).Mark
                        });
                    }
                    else
                    {
                        model.Add(new StudentMarkForDateViewData
                        {
                            MarkId      = 0,
                            StudentId   = student.Id,
                            StudentName = student.FullName,
                            Login       = student.User.UserName,
                            Mark        = string.Empty
                        });
                    }
                }

                return(new StudentMarkForDateResult()
                {
                    DateId = dateIntId,
                    Date = visitingDate.Date.ToShortDateString(),
                    StudentMarkForDate = model,
                    Message = "Данные успешно загружены",
                    Code = "200"
                });
            }
            catch (Exception)
            {
                return(new StudentMarkForDateResult()
                {
                    Message = "Произошла ошибка",
                    Code = "500"
                });
            }
        }
        public DataTablesResult <GroupViewModel> GetCollectionGroups(DataTablesParam dataTableParam)
        {
            var searchString = dataTableParam.GetSearchString();

            ViewBag.EditActionLink   = "/Administration/EditGroup";
            ViewBag.DeleteActionLink = "/Administration/DeleteGroup";
            var groups = GroupManagementService.GetGroupsPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString);

            return(DataTableExtensions.GetResults(groups.Items.Select(g => GroupViewModel.FormGroup(g, PartialViewToString("_EditGlyphLinks", g.Id))), dataTableParam, groups.TotalCount));
        }
示例#7
0
        public IList <SelectListItem> GetGroups()
        {
            var groups = GroupManagementService.GetGroups();

            return(groups.Select(v => new SelectListItem
            {
                Text = v.Name,
                Value = v.Id.ToString(CultureInfo.InvariantCulture)
            }).OrderBy(e => e.Text).ToList());
        }
示例#8
0
 public void ModifyGroup()
 {
     GroupManagementService.UpdateGroup(new Group()
     {
         Id             = Id,
         Name           = Name,
         GraduationYear = GraduationYear,
         StartYear      = StartYear
     });
 }
示例#9
0
        private void FillSubjectGroups()
        {
            var groups = GroupManagementService.GetGroups();

            Groups = groups.Select(e => new SelectListItem
            {
                Text     = e.Name,
                Value    = e.Id.ToString(CultureInfo.InvariantCulture),
                Selected = false
            }).ToList();
        }
示例#10
0
        public ActionResult GetSideNav(int groupId)
        {
            var group    = GroupManagementService.GetGroup(groupId);
            var subjects = SubjectManagementService.GetGroupSubjects(groupId);

            var model = new ParentalViewModel(group)
            {
                Subjects = subjects
            };

            return(PartialView("_ParentalSideNavPartial", model));
        }
示例#11
0
        public ActionResult EditGroup(int id)
        {
            var group = GroupManagementService.GetGroup(id);

            if (group != null)
            {
                var model = new GroupViewModel(group);
                return(PartialView("_EditGroupView", model));
            }

            return(RedirectToAction("Index"));
        }
示例#12
0
        public JsonResult GetGroups(int subjectId)
        {
            Subject subject = SubjectsManagementService.GetSubject(subjectId);

            int[] groupIds = subject.SubjectGroups.Select(subjectGroup => subjectGroup.GroupId).ToArray();
            var   groups   = GroupManagementService.GetGroups(new Query <Group>(group => groupIds.Contains(group.Id)))
                             .Select(group => new
            {
                Id   = group.Id,
                Name = group.Name
            }).ToArray();

            return(Json(groups, JsonRequestBehavior.AllowGet));
        }
示例#13
0
        public ActionResult Index(string id)
        {
            var group = GroupManagementService.GetGroupByName(id);

            if (group != null)
            {
                var model = new ParentalViewModel()
                {
                    Group = group
                };
                return(View(model));
            }

            return(RedirectToAction("GroupNotFound"));
        }
示例#14
0
        private void SaveStudent()
        {
            var user    = UsersManagementService.GetUser(UserName);
            var student = StudentManagementService.Save(new Student
            {
                Id         = user.Id,
                FirstName  = Name,
                LastName   = Surname,
                MiddleName = Patronymic,
                GroupId    = int.Parse(Group),
                Confirmed  = false
            });

            student.User  = user;
            student.Group = GroupManagementService.GetGroup(student.GroupId);
            new StudentSearchMethod().AddToIndex(student);
        }
示例#15
0
        public void ModifyLecturer()
        {
            var selectedGroups = SelectedGroupIds != null && SelectedGroupIds.Count > 0
                ? GroupManagementService.GetGroups(new Query <Group>(x => SelectedGroupIds.Contains(x.Id)))
                : new List <Group>();

            foreach (var group in GroupManagementService.GetGroups(new Query <Group>(x => x.SecretaryId == LecturerId)))
            {
                group.SecretaryId = null;
                GroupManagementService.UpdateGroup(group);
            }

            if (IsSecretary)
            {
                foreach (var group in selectedGroups)
                {
                    group.SecretaryId = LecturerId;
                    GroupManagementService.UpdateGroup(group);
                }
            }

            LecturerManagementService.UpdateLecturer(new Lecturer
            {
                Id          = LecturerId,
                FirstName   = Name,
                LastName    = Surname,
                Skill       = Skill,
                MiddleName  = Patronymic,
                IsSecretary = IsSecretary,
                IsLecturerHasGraduateStudents = IsLecturerHasGraduateStudents,
                SecretaryGroups = selectedGroups,
                IsActive        = IsActive,
                User            = new User
                {
                    Id           = LecturerId,
                    Avatar       = Avatar,
                    UserName     = UserName,
                    About        = About,
                    SkypeContact = SkypeContact,
                    Phone        = Phone,
                    Email        = Email
                }
            });
        }
        public WatchingTimeViewModel(int conceptId)
        {
            this.conceptId = conceptId;
            var concept = ConceptManagementService.GetById(conceptId);

            groups = GroupManagementService.GetGroups(new Query <Group>(e =>
                                                                        e.SubjectGroups.Any(x => x.SubjectId == concept.SubjectId)));
            viewRecords = new List <ViewsWorm>();
            var list = new List <WatchingTime>();

            list = WatchingTimeService.GetAllRecords(conceptId);
            foreach (var item in list)
            {
                viewRecords.Add(new ViewsWorm
                {
                    Name = UsersManagementService.GetUser(item.UserId).FullName, Seconds = item.Time
                });
            }
        }
示例#17
0
        public IList <SelectListItem> GetGroups()
        {
            var groups = new List <Group>();

            var user = new UsersManagementService().GetUser(WebSecurity.CurrentUserId);

            if (user != null)
            {
                groups = GetAssignedGroups(WebSecurity.CurrentUserId);
            }
            else
            {
                groups = new GroupManagementService().GetGroups();
            }

            return(groups.Select(v => new SelectListItem
            {
                Text = v.Name,
                Value = v.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
示例#18
0
        public JsonResult DeleteGroup(int id)
        {
            try
            {
                var group = GroupManagementService.GetGroup(id);
                if (group != null)
                {
                    if (group.Students != null && group.Students.Count > 0)
                    {
                        return(Json(new { resultMessage = "Группа содержит студентов и не может быть удалена" }));
                    }

                    GroupManagementService.DeleteGroup(id);
                    return(Json(new { resultMessage = string.Format("Группа {0} удалена", group.Name) }));
                }

                return(Json(new { resultMessage = "Группы не существует" }));
            }
            catch
            {
                return(Json(new { resultMessage = "Произошла ошибка при удалении" }));
            }
        }
示例#19
0
        public void GetVisitLabs(int subjectId, int groupId, int subGroupId)
        {
            var data = new SLExcelData();

            var headerData = GroupManagementService.GetLabsScheduleVisitings(subjectId, groupId, subGroupId);
            var rowsData   = GroupManagementService.GetLabsScheduleMarks(subjectId, groupId, subGroupId);

            data.Headers.Add("Студент");
            data.Headers.AddRange(headerData);
            data.DataRows.AddRange(rowsData);

            var file = (new SLExcelWriter()).GenerateExcel(data);

            Response.Clear();
            Response.Charset         = "ru-ru";
            Response.HeaderEncoding  = Encoding.UTF8;
            Response.ContentEncoding = Encoding.UTF8;
            Response.ContentType     = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("Content-Disposition", "attachment; filename=LabVisiting.xlsx");
            Response.BinaryWrite(file);
            Response.Flush();
            Response.End();
        }
示例#20
0
        public SubGroupEditingViewModel(int subjectId, int groupId = 0)
        {
            var groups = GroupManagementService.GetGroups(new Query <Group>(e => e.SubjectGroups.Any(x => x.SubjectId == subjectId)).Include(e => e.Students));

            FillGroupsList(groups);

            if (groupId == 0)
            {
                groupId = int.Parse(GroupsList.FirstOrDefault().Value);
            }

            GroupId = groupId.ToString(CultureInfo.InvariantCulture);

            var subGroups = SubjectManagementService.GetSubGroups(subjectId, groupId);

            if (subGroups.Any())
            {
                FillSubGroupsList(subGroups);
                StudentGroupList = new List <SelectListItem>();

                foreach (var student in groups.FirstOrDefault(e => e.Id == groupId).Students)
                {
                    var studentId = student.Id.ToString(CultureInfo.InvariantCulture);

                    if (!SubGroupsFirstList.Any() && !SubGroupsTwoList.Any())
                    {
                        StudentGroupList.Add(new SelectListItem
                        {
                            Selected = false,
                            Text     = student.FullName,
                            Value    = studentId
                        });
                    }
                    else
                    {
                        if (SubGroupsFirstList.Any(e => e.Value == studentId) ||
                            SubGroupsTwoList.Any(e => e.Value == studentId))
                        {
                        }
                        else
                        {
                            StudentGroupList.Add(new SelectListItem
                            {
                                Selected = false,
                                Text     = student.FullName,
                                Value    = studentId
                            });
                        }
                    }
                }
            }
            else
            {
                SubGroupsFirstList = new List <SelectListItem>();
                SubGroupsTwoList   = new List <SelectListItem>();
                StudentGroupList   = groups.FirstOrDefault(e => e.Id == groupId).Students.Select(e => new SelectListItem
                {
                    Text     = e.FullName,
                    Value    = e.Id.ToString(CultureInfo.InvariantCulture),
                    Selected = false
                }).ToList();
            }
        }
示例#21
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"
                });
            }
        }
示例#22
0
 public bool IsValidGroup(string groupName)
 {
     return(GroupManagementService.GetGroupByName(groupName) != null);
 }
示例#23
0
 public void AddGroup()
 {
     GroupManagementService.AddGroup(GetGroupFromViewModel());
 }
示例#24
0
        public bool CheckGroupName()
        {
            var group = GroupManagementService.GetGroupByName(this.Name);

            return(@group == null);
        }