public static void SubmitScore(Slide slide, string userId) { var ltiRequestsRepo = new LtiRequestsRepo(); var consumersRepo = new ConsumersRepo(); var visitsRepo = new VisitsRepo(); var ltiRequest = ltiRequestsRepo.Find(userId, slide.Id); if (ltiRequest == null) throw new Exception("LtiRequest for user '" + userId + "' not found"); var consumerSecret = consumersRepo.Find(ltiRequest.ConsumerKey).Secret; var score = visitsRepo.GetScore(slide.Id, userId); var uri = new UriBuilder(ltiRequest.LisOutcomeServiceUrl); if (uri.Host == "localhost") { uri.Host = "192.168.33.10"; uri.Port = 80; uri.Scheme = "http"; } var outputScore = score / (double)slide.MaxScore; /* Sometimes score is bigger then slide's MaxScore, i.e. in case of manual checking */ if (score > slide.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 static void SubmitScore(Slide slide, string userId) { var ltiRequestsRepo = new LtiRequestsRepo(); var consumersRepo = new ConsumersRepo(); var visitsRepo = new VisitsRepo(); var ltiRequest = ltiRequestsRepo.Find(userId, slide.Id); if (ltiRequest == null) throw new Exception("LtiRequest for user '" + userId + "' not found"); var consumerSecret = consumersRepo.Find(ltiRequest.ConsumerKey).Secret; var score = visitsRepo.GetScore(slide.Id, userId); // TODO: fix outcome address in local edx (no localhost and no https) var uri = new UriBuilder(ltiRequest.LisOutcomeServiceUrl); if (uri.Host == "localhost") { uri.Host = "192.168.33.10"; uri.Port = 80; uri.Scheme = "http"; } var result = OutcomesClient.PostScore(uri.ToString(), ltiRequest.ConsumerKey, consumerSecret, ltiRequest.LisResultSourcedId, score / (double)slide.MaxScore); if (!result.IsValid) throw new Exception(uri + "\r\n\r\n" + result.Message); }
public UserSolutionsRepo(ULearnDb db) { this.db = db; textsRepo = new TextsRepo(db); visitsRepo = new VisitsRepo(db); courseManager = WebCourseManager.Instance; }
public GroupsRepo(ULearnDb db) { this.db = db; slideCheckingsRepo = new SlideCheckingsRepo(db); userSolutionsRepo = new UserSolutionsRepo(db); userQuizzesRepo = new UserQuizzesRepo(db); visitsRepo = new VisitsRepo(db); }
public CertificatesRepo(ULearnDb db) { this.db = db; visitsRepo = new VisitsRepo(db); userQuizzesRepo = new UserQuizzesRepo(db); userSolutionsRepo = new UserSolutionsRepo(db); slideCheckingsRepo = new SlideCheckingsRepo(db); }
public AccountController() : this(new ULearnUserManager()) { db = new ULearnDb(); courseManager = WebCourseManager.Instance; usersRepo = new UsersRepo(db); userRolesRepo = new UserRolesRepo(db); groupsRepo = new GroupsRepo(db); certificatesRepo = new CertificatesRepo(db); visitsRepo = new VisitsRepo(db); }