Beispiel #1
0
		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);
		}
Beispiel #2
0
		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);
		}
Beispiel #3
0
 public UserSolutionsRepo(ULearnDb db)
 {
     this.db       = db;
     textsRepo     = new TextsRepo(db);
     visitsRepo    = new VisitsRepo(db);
     courseManager = WebCourseManager.Instance;
 }
Beispiel #4
0
 public GroupsRepo(ULearnDb db)
 {
     this.db            = db;
     slideCheckingsRepo = new SlideCheckingsRepo(db);
     userSolutionsRepo  = new UserSolutionsRepo(db);
     userQuizzesRepo    = new UserQuizzesRepo(db);
     visitsRepo         = new VisitsRepo(db);
 }
Beispiel #5
0
 public CertificatesRepo(ULearnDb db)
 {
     this.db            = db;
     visitsRepo         = new VisitsRepo(db);
     userQuizzesRepo    = new UserQuizzesRepo(db);
     userSolutionsRepo  = new UserSolutionsRepo(db);
     slideCheckingsRepo = new SlideCheckingsRepo(db);
 }
Beispiel #6
0
		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);
		}