コード例 #1
0
 public void SaveSubmission(AssignmentSubmissionViewModel model)
 {
     try
     {
         // Submit Assignment
         _assignmentTaskAndSubmissionService.SaveStudentSubmission(CurrentUser.Id, model);
     }
     catch (Exception)
     {
     }
 }
コード例 #2
0
        /// <summary>
        /// Creates the student assignment with submission view model.
        /// </summary>
        /// <param name="assignments">The assignments.</param>
        /// <param name="studentId">The student id.</param>
        /// <param name="objectMapper">The object mapper.</param>
        /// <returns></returns>
        public static List <AssignmentSubmissionViewModel> CreateStudentAssignmentSubmissionViewModels(List <Assignment> assignments, int studentId, IObjectMapperAdapter objectMapper)
        {
            List <AssignmentSubmissionViewModel> assignmentSubmissionModels = new List <AssignmentSubmissionViewModel>();

            foreach (Assignment assignmentItem in assignments)
            {
                AssignmentSubmissionViewModel assignmentSubmissionViewModel = CreateStudentAssignmentSubmissionViewModel(assignmentItem, studentId, objectMapper);
                if (assignmentSubmissionViewModel != null)
                {
                    assignmentSubmissionModels.Add(assignmentSubmissionViewModel);
                }
            }
            return(assignmentSubmissionModels);
        }
コード例 #3
0
        public ActionResult UploadSubmissionFile(AssignmentSubmissionViewModel model)
        {
            ICollection <BaseFileViewModel> files = new List <BaseFileViewModel>();

            try
            {
                _assignmentTaskAndSubmissionService.UploadStudentSubmissionDocument(CurrentUser.Id, model);
                AssignmentSubmissionViewModel viewModel = _assignmentTaskAndSubmissionService.GetStudentAssignmentSubmission(CurrentUser.Id, model.AssignmentId);
                files = viewModel.FileUploads;
            }
            catch (Exception)
            {
            }
            return(PartialView("_SubmissionFilePartial", files));
        }
コード例 #4
0
        /// <summary>
        /// Gets the student assignment submission.
        /// </summary>
        /// <param name="studentId">The student id.</param>
        /// <param name="assignmentId">The assignment id.</param>
        /// <returns></returns>
        public AssignmentSubmissionViewModel GetStudentAssignmentSubmission(int studentId, int assignmentId)
        {
            AssignmentSubmissionViewModel model = null;

            try
            {
                Assignment assignment = AssignmentManager.GetAssignmentForStudent(studentId, assignmentId);
                model = AssignmentSubmissionViewModelFactory.CreateStudentAssignmentSubmissionViewModel(assignment, studentId, ObjectMapper);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
            return(model);
        }
コード例 #5
0
        public ActionResult MakeSubmission(AssignmentSubmissionViewModel model)
        {
            AssignmentSubmissionViewModel viewModel = null;

            try
            {
                // Submit Assignment
                viewModel = _assignmentTaskAndSubmissionService.SaveStudentSubmission(CurrentUser.Id, model, true);
            }
            catch (Exception)
            {
            }

            //return PartialView("_AssignmentSubmissionsPartial", viewModel ?? model);
            return(RedirectToAction("Assignments"));
        }
コード例 #6
0
        /// <summary>
        /// Saves the student submission.
        /// </summary>
        /// <param name="studentId">The student id.</param>
        /// <param name="assignmentSubmissionViewModel">The assignment submission view model.</param>
        /// <param name="setStatusToSubmitted">if set to <c>true</c> [set status to submitted].</param>
        public AssignmentSubmissionViewModel SaveStudentSubmission(int studentId, AssignmentSubmissionViewModel assignmentSubmissionViewModel, bool setStatusToSubmitted = false)
        {
            try
            {
                Submission submission = ObjectMapper.Map <AssignmentSubmissionViewModel, Model.Entities.Submission>(assignmentSubmissionViewModel);
                submission.StudentId = studentId;
                SubmissionManager.SubmissionForAssignmentAlreadyExists(ref submission);
                submission.Status = setStatusToSubmitted ? (int)SubmissionStatusType.Submitted : submission.Status;
                if (submission != null && submission.Id != 0)
                {
                    SubmissionManager.Update(submission);
                }
                else
                {
                    submission = SubmissionManager.Add(submission);
                    assignmentSubmissionViewModel.Id = submission.Id;
                }

                if (submission != null)
                {
                    List <string> associations = new List <string>();
                    associations.Add("CourseModules");
                    associations.Add("CourseModules.Course");
                    associations.Add("CourseModules.Course.StaffCourses");
                    AssignmentViewModel assignmentViewModel = GetAssignment(assignmentSubmissionViewModel.AssignmentId);
                    var module = ModuleManager.FindAll(associations).Where(m => m.Id.Equals(assignmentViewModel.ModuleId)).FirstOrDefault();

                    List <Message> messages = new List <Message>();
                    messages = StudentMessageViewModelFactory.CreateStudentAssignmentSubmissionMessages(module, assignmentViewModel, studentId);

                    MessageManager.AddMessages(messages);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
            return(assignmentSubmissionViewModel);
        }
コード例 #7
0
        /// <summary>
        /// Creates the student assignment submission view model.
        /// </summary>
        /// <param name="assignment">The assignment.</param>
        /// <param name="studentId">The student id.</param>
        /// <param name="objectMapper">The object mapper.</param>
        /// <returns></returns>
        public static AssignmentSubmissionViewModel CreateStudentAssignmentSubmissionViewModel(Assignment assignment, int studentId, IObjectMapperAdapter objectMapper)
        {
            AssignmentSubmissionViewModel model = null;

            if (assignment != null)
            {
                foreach (Submission submissionItem in assignment.Submissions)
                {
                    if (submissionItem.StudentId == studentId)
                    {
                        model = objectMapper.Map <Model.Entities.Submission, AssignmentSubmissionViewModel>(submissionItem);
                        break;
                    }
                }

                // If no submission exists, create a new one
                if (model == null)
                {
                    model = new AssignmentSubmissionViewModel();
                }

                //Set Assignment properties on Model
                model.StudentId    = studentId;
                model.AssignmentId = assignment.Id;
                model.Instructions = assignment.Instructions;
                model.DaysDue      = assignment.DaysDue;
                model.DaysLeft     = assignment.DaysLeft;
                model.Priority     = (int)assignment.Priority;
                if (model.Status == 0)
                {
                    model.Status = (int)SubmissionStatusType.New;
                }
                model.PointsPossible    = assignment.PointsPossible;
                model.Title             = assignment.Title;
                model.AssignmentUploads = objectMapper.Map <Model.Entities.BaseFile, BaseFileViewModel>(assignment.FileUploads.ToList());
            }

            return(model);
        }
コード例 #8
0
        /// <summary>
        /// Uploads the student submission document.
        /// </summary>
        /// <param name="studentId">The student id.</param>
        /// <param name="assignmentSubmissionViewModel">The assignment submission view model.</param>
        public void UploadStudentSubmissionDocument(int studentId, AssignmentSubmissionViewModel assignmentSubmissionViewModel)
        {
            try
            {
                Submission submission = ObjectMapper.Map <AssignmentSubmissionViewModel, Model.Entities.Submission>(assignmentSubmissionViewModel);
                submission.StudentId = studentId;
                SubmissionManager.SubmissionForAssignmentAlreadyExists(ref submission);

                // Create Submission if does not exist
                if (submission == null || submission.Id == 0)
                {
                    submission = SubmissionManager.Add(submission);
                }

                // UploadFile
                UniEBoard.Model.Entities.File uploadFile = FileFactory.CreateSubmissionContentFile(submission.Id, submission.AssignmentId, assignmentSubmissionViewModel.UploadFile) as File;
                FileManager.Add(uploadFile);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
        }
コード例 #9
0
        public ActionResult Assignment(int id)
        {
            AssignmentSubmissionViewModel model = _assignmentTaskAndSubmissionService.GetStudentAssignmentSubmission(CurrentUser.Id, id);

            return(View("Submission", model));
        }