/// <summary>
        /// Constructor.
        /// </summary>
        public UpdatedSectionAssignmentsViewModel(
            UpdatedSectionAssignmentResults results,
            DateTime submissionsRetrievedDate,
            SelectAssignmentReport markAssignmentsGraded,
            ITimeZoneProvider timeZoneProvider)
        {
            SectionName = results.SectionName;

            GradebookName = results.GradebookName;

            StartDate =
                results.AssignmentsLastGradedDate != DateTime.MinValue
                    ? results.AssignmentsLastGradedDate
                        .FormatLongDateTime(timeZoneProvider)
                    : "The beginning";

            EndDate = submissionsRetrievedDate.FormatLongDateTime(timeZoneProvider);

            AssignmentResults = results.AssignmentResults.Select
            (
                result => new AssignmentUpdatesViewModel(result)
            ).ToList();

            MarkAssignmentsGraded = markAssignmentsGraded;
        }
示例#2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public UpdatedSectionAssignmentsViewModel(
            UpdatedSectionAssignmentResults results,
            SelectAssignmentReport markAssignmentsGraded,
            ITimeZoneProvider timeZoneProvider,
            IAssignmentDisplayProviderFactory displayProviderFactory)
        {
            SectionName = results.SectionName;

            GradebookName = results.GradebookName;

            StartDate =
                results.AssignmentsLastGradedDate != DateTime.MinValue
                                        ? results.AssignmentsLastGradedDate
                .FormatLongDateTime(timeZoneProvider)
                                        : "The beginning";

            EndDate = results.ResultsRetrievedDate.FormatLongDateTime(timeZoneProvider);

            AssignmentResults = results.AssignmentResults.Select
                                (
                result => new AssignmentUpdatesViewModel
                (
                    result,
                    displayProviderFactory
                )
                                ).ToList();

            MarkAssignmentsGraded = markAssignmentsGraded;
        }
		public async Task<IActionResult> SectionReport(SelectAssignmentReport selectAssignmentReport)
		{
			if (selectAssignmentReport.LastTransferDate != null)
			{
				await AssignmentService.MarkAssignmentsGradedAsync
				(
					ClassroomName,
					selectAssignmentReport.SectionName,
					selectAssignmentReport.GradebookName,
					selectAssignmentReport.LastTransferDate.Value
				);
			}

			if (selectAssignmentReport.AssignmentGroupName == AllRecentlyUpdated)
			{
				var dateRetrieved = DateTime.UtcNow;
				dateRetrieved = dateRetrieved.AddSeconds(-dateRetrieved.Second);

				var updatedResults = await AssignmentService.GetUpdatedAssignmentResultsAsync
				(
					ClassroomName,
					selectAssignmentReport.SectionName,
					selectAssignmentReport.GradebookName
				);

				var report = new UpdatedSectionAssignmentsViewModel
				(
					updatedResults,
					dateRetrieved,
					new SelectAssignmentReport()
					{
						SectionName = selectAssignmentReport.SectionName,
						AssignmentGroupName = AllRecentlyUpdated,
						GradebookName = selectAssignmentReport.GradebookName,
						LastTransferDate = dateRetrieved
					},
					TimeZoneProvider
				);

				return View("UpdatedAssignmentsReport", report);
			}
			else
			{
				var sectionResults = await AssignmentService.GetSectionAssignmentResultsAsync
				(
					ClassroomName,
					selectAssignmentReport.SectionName,
					selectAssignmentReport.AssignmentGroupName
				);

				var report = new AssignmentViewModel(sectionResults);

				return View("SingleAssignmentReport", report);
			}
		}