/// <summary> /// /// </summary> /// <param name="teacherId"></param> /// <returns></returns> public List <AssignmentViewModel> GetAssignmentsForTeacher(int teacherId, bool includeSubmissions = false) { List <AssignmentViewModel> assignmentViewModelList = new List <AssignmentViewModel>(); try { //StudentManager.GetStudentsForTeacher(teacherId); List <Model.Entities.Assignment> assignments = AssignmentManager.GetAssignmentForTeacher(teacherId, includeSubmissions); foreach (var assign in assignments) { List <Model.Entities.Student> students = StudentManager.GetStudentsForModule(assign.ModuleId ?? 0); foreach (var stud in students) { if (!assign.Submissions.Any(sub => stud.Id == sub.StudentId)) { Submission newSub = new Submission(); newSub.Student = stud; newSub.StudentId = stud.Id; newSub.Assignment = assign; newSub.AssignmentId = assign.Id; newSub.Status = 0; assign.Submissions.Add(newSub); } } } assignmentViewModelList = ObjectMapper.Map <Model.Entities.Assignment, AssignmentViewModel>(assignments); } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } return(assignmentViewModelList); }