Beispiel #1
0
        public async Task <IActionResult> RebuildSnippetsForTask([FromQuery] RebuildSnippetsForTaskParameters parameters)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await snippetsRepo.RemoveSnippetsOccurrencesForTaskAsync(parameters.TaskId).ConfigureAwait(false);

            var submissions = await submissionsRepo.GetSubmissionsByTaskAsync(client.Id, parameters.TaskId).ConfigureAwait(false);

            foreach (var submission in submissions)
            {
                await submissionsRepo.UpdateSubmissionTokensCountAsync(submission, GetTokensCount(submission.ProgramText, submission.Language));

                await newSubmissionHandler.ExtractSnippetsFromSubmissionAsync(submission).ConfigureAwait(false);
            }

            await newSubmissionHandler.CalculateTaskStatisticsParametersAsync(client.Id, parameters.TaskId).ConfigureAwait(false);

            return(Json(new RebuildSnippetsForTaskResponse
            {
                SubmissionsIds = submissions.Select(s => s.Id).ToList(),
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> RebuildSnippetsForTask([FromQuery] RebuildSnippetsForTaskParameters parameters)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await snippetsRepo.RemoveSnippetsOccurencesForTaskAsync(parameters.TaskId);

            var submissions = await submissionsRepo.GetSubmissionsByTaskAsync(client.Id, parameters.TaskId);

            foreach (var submission in submissions)
            {
                await ExtractSnippetsFromSubmissionAsync(submission);
            }
            await CalculateTaskStatisticsParametersAsync(client.Id, parameters.TaskId);

            return(Json(new RebuildSnippetsForTaskResult
            {
                SubmissionsIds = submissions.Select(s => s.Id).ToList(),
            }));
        }