예제 #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);
		}
예제 #2
0
파일: LtiUtils.cs 프로젝트: andgein/uLearn
		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);
		}
예제 #3
0
 public UserSolutionsRepo(ULearnDb db)
 {
     this.db       = db;
     textsRepo     = new TextsRepo(db);
     visitsRepo    = new VisitsRepo(db);
     courseManager = WebCourseManager.Instance;
 }
예제 #4
0
파일: GroupsRepo.cs 프로젝트: epeshk/uLearn
 public GroupsRepo(ULearnDb db)
 {
     this.db            = db;
     slideCheckingsRepo = new SlideCheckingsRepo(db);
     userSolutionsRepo  = new UserSolutionsRepo(db);
     userQuizzesRepo    = new UserQuizzesRepo(db);
     visitsRepo         = new VisitsRepo(db);
 }
예제 #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);
 }
예제 #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);
		}