public LtiResultObserver(IWebCourseManager courseManager, ILtiConsumersRepo ltiConsumersRepo, ILtiRequestsRepo ltiRequestsRepo, IVisitsRepo visitsRepo) { this.courseManager = courseManager; this.ltiConsumersRepo = ltiConsumersRepo; this.ltiRequestsRepo = ltiRequestsRepo; this.visitsRepo = visitsRepo; }
public static async Task SubmitScore(string courseId, Slide slide, string userId, int score, ILtiRequestsRepo ltiRequestsRepo, ILtiConsumersRepo consumersRepo) { var ltiRequestJson = await ltiRequestsRepo.Find(courseId, userId, slide.Id); if (ltiRequestJson == null) { throw new Exception("LtiRequest for user '" + userId + "' not found"); } var ltiRequest = JsonConvert.DeserializeObject <LtiRequest>(ltiRequestJson); var consumerSecret = (await consumersRepo.Find(ltiRequest.ConsumerKey)).Secret; log.Info($"Надо отправить результаты слайда {slide.Id} пользователя {userId} по LTI. Нашёл LtiRequest: {ltiRequestJson}"); UriBuilder uri; try { uri = new UriBuilder(ltiRequest.LisOutcomeServiceUrl); } catch (Exception e) { log.Error(e, $"Неверный адрес отправки результатов по LTI: {ltiRequest.LisOutcomeServiceUrl}"); throw; } if (uri.Host == "localhost") { uri.Host = "192.168.33.10"; uri.Port = 80; uri.Scheme = "http"; } var maxScore = BaseController.GetMaxScoreForUsersSlide(slide, true, false, false); var outputScore = score / (double)maxScore; log.Info($"Отправляю результаты на {ltiRequest.LisOutcomeServiceUrl}: {score} из {maxScore} ({outputScore})"); /* Sometimes score is bigger then slide's MaxScore, i.e. in case of manual checking */ if (score > maxScore) { outputScore = 1; } var result = OutcomesClient.PostScore(uri.ToString(), ltiRequest.ConsumerKey, consumerSecret, ltiRequest.LisResultSourcedId, outputScore); if (!result.IsValid) { throw new Exception(uri + "\r\n\r\n" + result.Message); } }
public ExerciseController(IWebCourseManager courseManager, UlearnDb db, MetricSender metricSender, IUsersRepo usersRepo, IUserSolutionsRepo userSolutionsRepo, ICourseRolesRepo courseRolesRepo, IVisitsRepo visitsRepo, ILtiConsumersRepo ltiConsumersRepo, ILtiRequestsRepo ltiRequestsRepo, ISlideCheckingsRepo slideCheckingsRepo, IGroupsRepo groupsRepo, IStyleErrorsRepo styleErrorsRepo) : base(courseManager, db, usersRepo) { this.metricSender = metricSender; this.userSolutionsRepo = userSolutionsRepo; this.courseRolesRepo = courseRolesRepo; this.visitsRepo = visitsRepo; this.ltiConsumersRepo = ltiConsumersRepo; this.ltiRequestsRepo = ltiRequestsRepo; this.slideCheckingsRepo = slideCheckingsRepo; this.groupsRepo = groupsRepo; this.styleErrorsRepo = styleErrorsRepo; }
public UserProgressController(IWebCourseManager courseManager, UlearnDb db, IUsersRepo usersRepo, IVisitsRepo visitsRepo, IUserQuizzesRepo userQuizzesRepo, IAdditionalScoresRepo additionalScoresRepo, ICourseRolesRepo courseRolesRepo, IGroupAccessesRepo groupAccessesRepo, IGroupMembersRepo groupMembersRepo, ISlideCheckingsRepo slideCheckingsRepo, ILtiRequestsRepo ltiRequestsRepo, ILtiConsumersRepo ltiConsumersRepo) : base(courseManager, db, usersRepo) { this.visitsRepo = visitsRepo; this.userQuizzesRepo = userQuizzesRepo; this.additionalScoresRepo = additionalScoresRepo; this.courseRolesRepo = courseRolesRepo; this.groupAccessesRepo = groupAccessesRepo; this.groupMembersRepo = groupMembersRepo; this.slideCheckingsRepo = slideCheckingsRepo; this.ltiRequestsRepo = ltiRequestsRepo; this.ltiConsumersRepo = ltiConsumersRepo; }