public async Task <ActionResult> GetStudentGroupResults(long courseId, [FromBody] DashboardAnalyticsRequestDto <StudentGroupResultType> request) { var results = await _dashboardService .GetStudentGroupResultAsync(courseId, request); return(results.ToActionResult()); }
public async Task <Result <StudentsResultsDto> > GetStudentResultAsync(long studentId, DashboardAnalyticsRequestDto <StudentResultType> request, ClaimsPrincipal userContext) { var errors = ValidateGenericRequest(request).Concat(ValidateStudentRights(studentId, userContext)); if (errors.Any()) { return(Result <StudentsResultsDto> .GetError(ErrorCode.ValidationError, string.Join(";\n", errors))); } var result = new StudentsResultsDto(); var studentGroupsIds = await _dashboardRepository .GetGroupsIdsByStudentIdAndPeriodAsync(studentId, request.StartDate, request.FinishDate); if (request.IncludeAnalytics.Contains(StudentResultType.AverageStudentMark)) { result.AverageStudentsMarks = await _dashboardRepository .GetStudentAverageMarksByStudentIdsAndGropsIdsAsync(new List <long> { studentId }, studentGroupsIds); } if (request.IncludeAnalytics.Contains(StudentResultType.AverageStudentVisits)) { result.AverageStudentVisits = await _dashboardRepository .GetStudentAverageVisitsPercentageByStudentIdsAsync(studentId, studentGroupsIds); } return(Result <StudentsResultsDto> .GetSuccess(result)); }
public async Task <ActionResult> GetStudentResults(long studentId, [FromBody] DashboardAnalyticsRequestDto <StudentResultType> request) { var userContext = HttpContext.User; var results = await _dashboardService .GetStudentResultAsync(studentId, request, userContext); return(results.ToActionResult()); }
private IEnumerable <string> ValidateGenericRequest <T>(DashboardAnalyticsRequestDto <T> request) where T : Enum { if (request == default) { yield return("Please provide request data"); yield break; } if (request.IncludeAnalytics == default || request.IncludeAnalytics.Length == 0) { yield return("Please provide 'IncludeAnalytics' parameters"); } }
public async Task <Result <StudentsClassbookResultDto> > GetStudentClassbookAsync(long studentId, DashboardAnalyticsRequestDto <ClassbookResultType> request, ClaimsPrincipal userContext) { var error = ValidateGenericRequest(request).Concat(ValidateStudentRights(studentId, userContext)); if (error.Any()) { return(Result <StudentsClassbookResultDto> .GetError(ErrorCode.ValidationError, string.Join(";\n", error))); } var result = new StudentsClassbookResultDto(); var studentGroupsIds = await _dashboardRepository .GetGroupsIdsByStudentIdAndPeriodAsync(studentId, request.StartDate, request.FinishDate); if (request.IncludeAnalytics.Contains(ClassbookResultType.StudentPresence)) { result.StudentsPresences = await _dashboardRepository .GetStudentPresenceListByStudentIds(studentId, studentGroupsIds); } if (request.IncludeAnalytics.Contains(ClassbookResultType.StudentMarks)) { result.StudentsMarks = await _dashboardRepository .GetStudentMarksListByStudentIds(studentId, studentGroupsIds); } return(Result <StudentsClassbookResultDto> .GetSuccess(result)); }
public async Task <Result <StudentGroupsResultsDto> > GetStudentGroupResultAsync(long courseId, DashboardAnalyticsRequestDto <StudentGroupResultType> request) { var errors = ValidateGenericRequest(request); if (errors.Any()) { return(Result <StudentGroupsResultsDto> .GetError(ErrorCode.ValidationError, string.Join(";\n", errors))); } var result = new StudentGroupsResultsDto(); var studentGroupsIds = await _dashboardRepository .GetGroupsIdsByCourseIdAsync(courseId, request.StartDate, request.FinishDate); if (studentGroupsIds == null) { return(Result <StudentGroupsResultsDto> .GetError(ErrorCode.NotFound, "Student groups not found")); } if (request.IncludeAnalytics.Contains(StudentGroupResultType.AverageStudentGroupMark)) { result.AverageStudentGroupsMarks = await _dashboardRepository .GetStudentGroupsAverageMarks(studentGroupsIds); } if (request.IncludeAnalytics.Contains(StudentGroupResultType.AverageStudentGroupVisitsPercentage)) { result.AverageStudentGroupsVisits = await _dashboardRepository .GetStudentGroupsAverageVisits(studentGroupsIds); } return(Result <StudentGroupsResultsDto> .GetSuccess(result)); }