public async Task <ActionResult <ApiSlideInfo> > SlideInfo([FromRoute] Course course, [FromRoute] Guid slideId) { var isInstructor = await courseRolesRepo.HasUserAccessToCourse(User.GetUserId(), course.Id, CourseRoleType.Instructor).ConfigureAwait(false); var slide = course?.FindSlideById(slideId, isInstructor); if (slide == null) { var instructorNote = course?.FindInstructorNoteById(slideId); if (instructorNote != null && isInstructor) { slide = instructorNote.Slide; } } if (slide == null) { return(NotFound(new { status = "error", message = "Course or slide not found" })); } var userId = User.GetUserId(); var getSlideMaxScoreFunc = await BuildGetSlideMaxScoreFunc(solutionsRepo, userQuizzesRepo, visitsRepo, groupsRepo, course, userId); var getGitEditLinkFunc = await BuildGetGitEditLinkFunc(userId, course, courseRolesRepo, coursesRepo); var baseUrl = CourseUnitUtils.GetDirectoryRelativeWebPath(slide.Info.SlideFile); var slideRenderContext = new SlideRenderContext(course.Id, slide, UserId, baseUrl, !isInstructor, course.Settings.VideoAnnotationsGoogleDoc, Url); return(await slideRenderer.BuildSlideInfo(slideRenderContext, getSlideMaxScoreFunc, getGitEditLinkFunc)); }
public async Task <ApiSlideInfo> BuildSlideInfo(SlideRenderContext slideRenderContext, Func <Slide, int> getSlideMaxScoreFunc, Func <Slide, string> getGitEditLink) { var result = BuildShortSlideInfo <ApiSlideInfo>(slideRenderContext.CourseId, slideRenderContext.Slide, getSlideMaxScoreFunc, getGitEditLink, slideRenderContext.UrlHelper); result.Blocks = new List <IApiSlideBlock>(); foreach (var b in slideRenderContext.Slide.Blocks) { result.Blocks.AddRange(await ToApiSlideBlocks(b, slideRenderContext)); } return(result); }
public async Task <IEnumerable <IApiSlideBlock> > ToApiSlideBlocks(SlideBlock slideBlock, SlideRenderContext context) { if (context.RemoveHiddenBlocks && slideBlock.Hide) { return new IApiSlideBlock[] {} } ; var apiSlideBlocks = (IEnumerable <IApiSlideBlock>) await RenderBlock((dynamic)slideBlock, context); if (context.RemoveHiddenBlocks) { apiSlideBlocks = apiSlideBlocks.Where(b => !b.Hide); } return(apiSlideBlocks); }
private async Task <IEnumerable <IApiSlideBlock> > RenderBlock(YoutubeBlock yb, SlideRenderContext context) { var annotation = await videoAnnotationsClient.GetVideoAnnotations(context.VideoAnnotationsGoogleDoc, yb.VideoId); var googleDocLink = string.IsNullOrEmpty(context.VideoAnnotationsGoogleDoc) ? null : "https://docs.google.com/document/d/" + context.VideoAnnotationsGoogleDoc; var response = new YoutubeBlockResponse(yb, annotation, googleDocLink); return(new [] { response }); }
private async Task <IEnumerable <IApiSlideBlock> > RenderBlock(AbstractExerciseBlock b, SlideRenderContext context) { var submissions = await solutionsRepo .GetAllSubmissionsByUser(context.CourseId, context.Slide.Id, context.UserId) .Include(s => s.AutomaticChecking).ThenInclude(c => c.Output) .Include(s => s.AutomaticChecking).ThenInclude(c => c.CompilationError) .Include(s => s.AutomaticChecking).ThenInclude(c => c.DebugLogs) .Include(s => s.SolutionCode) .Include(s => s.Reviews).ThenInclude(c => c.Author) .Include(s => s.ManualCheckings).ThenInclude(c => c.Reviews).ThenInclude(r => r.Author) .ToListAsync(); var codeReviewComments = await slideCheckingsRepo.GetExerciseCodeReviewComments(context.CourseId, context.Slide.Id, context.UserId); var isCourseAdmin = await courseRolesRepo.HasUserAccessToCourseAsync(context.UserId, context.CourseId, CourseRoleType.CourseAdmin); ExerciseAttemptsStatistics exerciseAttemptsStatistics = null; if (b.HasAutomaticChecking()) { var exerciseUsersCount = await slideCheckingsRepo.GetExerciseUsersCount(context.CourseId, context.Slide.Id); var exerciseUsersWithRightAnswerCount = await slideCheckingsRepo.GetExerciseUsersWithRightAnswerCount(context.CourseId, context.Slide.Id); var lastSuccessAttemptDate = await slideCheckingsRepo.GetExerciseLastRightAnswerDate(context.CourseId, context.Slide.Id); exerciseAttemptsStatistics = new ExerciseAttemptsStatistics { AttemptedUsersCount = exerciseUsersCount, UsersWithRightAnswerCount = exerciseUsersWithRightAnswerCount, LastSuccessAttemptDate = lastSuccessAttemptDate }; } var exerciseSlideRendererContext = new ExerciseSlideRendererContext { Submissions = submissions, CodeReviewComments = codeReviewComments, SlideFile = context.Slide.Info.SlideFile, CanSeeCheckerLogs = isCourseAdmin, AttemptsStatistics = exerciseAttemptsStatistics, }; return(new[] { new ExerciseBlockResponse(b, exerciseSlideRendererContext) }); }
private static async Task <IEnumerable <IApiSlideBlock> > RenderBlock(MarkdownBlock mb, SlideRenderContext context) { var renderedMarkdown = mb.RenderMarkdown(context.CourseId, context.Slide, context.BaseUrl); var parsedBlocks = ParseBlocksFromMarkdown(renderedMarkdown); if (mb.Hide) { parsedBlocks.ForEach(b => b.Hide = true); } return(parsedBlocks); }
private async Task <IEnumerable <IApiSlideBlock> > RenderBlock(SpoilerBlock sb, SlideRenderContext context) { var innerBlocks = new List <IApiSlideBlock>(); foreach (var b in sb.Blocks) { innerBlocks.AddRange(await ToApiSlideBlocks(b, context)); } if (sb.Hide) { innerBlocks.ForEach(b => b.Hide = true); } return(new [] { new SpoilerBlockResponse(sb, innerBlocks) }); }
private async Task <IEnumerable <IApiSlideBlock> > RenderBlock(TexBlock b, SlideRenderContext context) { return(new[] { new TexBlockResponse(b) }); }
private async Task <IEnumerable <IApiSlideBlock> > RenderBlock(HtmlBlock b, SlideRenderContext context) { return(new[] { new HtmlBlockResponse(b, false) }); }
private async Task <IEnumerable <IApiSlideBlock> > RenderBlock(SlideBlock b, SlideRenderContext context) { return(Enumerable.Empty <IApiSlideBlock>()); }