Ejemplo n.º 1
0
        public async Task UpdateScoreForVisit(string courseId, Slide slide, string userId)
        {
            var maxSlideScore = slide.MaxScore;
            var newScore      = slide is ExerciseSlide ex
                                ? (await slideCheckingsRepo.GetExerciseSlideScoreAndPercent(courseId, ex, userId)).Score
                                : await slideCheckingsRepo.GetUserScoreForQuizSlide(courseId, slide.Id, userId);

            newScore = Math.Min(newScore, maxSlideScore);
            var isPassed = await slideCheckingsRepo.IsSlidePassed(courseId, slide.Id, userId);

            if (await IsSkipped(courseId, slide.Id, userId))
            {
                newScore = 0;
            }
            log.Info($"Обновляю количество баллов пользователя {userId} за слайд {slide.Id} в курсе \"{courseId}\". " +
                     $"Новое количество баллов: {newScore}, слайд пройден: {isPassed}");
            await UpdateAttempts(courseId, slide.Id, userId, visit =>
            {
                visit.Score    = newScore;
                visit.IsPassed = isPassed;
            });
        }