Exemple #1
0
        public async Task <IActionResult> ResetLimitsForStudents(int groupId, ResetLimitsParameters parameters)
        {
            var hasEditAccess = await groupAccessesRepo.HasUserEditAccessToGroupAsync(groupId, UserId);

            if (!hasEditAccess)
            {
                return(StatusCode((int)HttpStatusCode.Forbidden, new ErrorResponse("You have no edit access to this group")));
            }

            var group = await groupsRepo.FindGroupByIdAsync(groupId);

            var members = await groupMembersRepo.GetGroupsMembersIdsAsync(new [] { groupId });

            var studentsToProcessSet = parameters.StudentIds.ToHashSet();

            studentsToProcessSet.IntersectWith(members);

            foreach (var studentId in studentsToProcessSet)
            {
                await slideCheckingsRepo.ResetAutomaticCheckingLimitsForUser(group.CourseId, studentId);
            }

            return(Ok(new SuccessResponseWithMessage($"Limits for {studentsToProcessSet.Count} students have been reset")));
        }