public ActionResult List(string namePrefix = null, string role = null) { IQueryable<ApplicationUser> applicationUsers = new ULearnDb().Users; if (!string.IsNullOrEmpty(namePrefix)) applicationUsers = applicationUsers.Where(u => u.UserName.StartsWith(namePrefix)); if (!string.IsNullOrEmpty(role)) applicationUsers = applicationUsers.Where(u => u.Roles.Any(r => r.Role.Name == role)); return View(applicationUsers.OrderBy(u => u.UserName).Take(50).ToList()); }
public AccountController() : this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ULearnDb()))) { db = new ULearnDb(); courseManager = WebCourseManager.Instance; UserManager.UserValidator = new UserValidator<ApplicationUser>(UserManager) { AllowOnlyAlphanumericUserNames = false }; }
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); }
public static IAppBuilder UseLtiAuthentication(this IAppBuilder app) { app.UseLtiAuthentication(new LtiAuthenticationOptions { Provider = new LtiAuthenticationProvider { // Look up the secret for the consumer OnAuthenticate = async context => { // Make sure the request is not being replayed var timeout = TimeSpan.FromMinutes(5); var oauthTimestampAbsolute = OAuthConstants.Epoch.AddSeconds(context.LtiRequest.Timestamp); if (DateTime.UtcNow - oauthTimestampAbsolute > timeout) { throw new LtiException("Expired " + OAuthConstants.TimestampParameter); } var db = new ULearnDb(); var consumer = await db.Consumers.SingleOrDefaultAsync(c => c.Key == context.LtiRequest.ConsumerKey); if (consumer == null) { throw new LtiException("Invalid " + OAuthConstants.ConsumerKeyParameter + " " + context.LtiRequest.ConsumerKey); } /* Substitute http(s) scheme with real scheme from header */ var uriBuilder = new UriBuilder(context.LtiRequest.Url) { Scheme = context.OwinContext.Request.GetRealRequestScheme(), Port = context.OwinContext.Request.GetRealRequestPort() }; context.LtiRequest.Url = uriBuilder.Uri; var signature = context.LtiRequest.GenerateSignature(consumer.Secret); if (!signature.Equals(context.LtiRequest.Signature)) { throw new LtiException("Invalid " + OAuthConstants.SignatureParameter); } // If we made it this far the request is valid }, // Sign in using application authentication. This handler will create a new application // user if no matching application user is found. OnAuthenticated = context => SecurityHandler.OnAuthenticated(context), // Generate a username using the LisPersonEmailPrimary from the LTI request OnGenerateUserName = context => SecurityHandler.OnGenerateUserName(context) }, SignInAsAuthenticationType = DefaultAuthenticationTypes.ApplicationCookie }); return app; }
public TextsRepo(ULearnDb db) { this.db = db; }
public SlideRateRepo(ULearnDb db) { this.db = db; }
public AntiPlagiarismController(ULearnDb db, UserSolutionsRepo userSolutionsRepo, GroupsRepo groupsRepo) { this.db = db; this.userSolutionsRepo = userSolutionsRepo; this.groupsRepo = groupsRepo; }
public UnitsRepo(ULearnDb db, CourseManager courseManager) { this.db = db; this.courseManager = courseManager; }
// private static IEnumerable<Tuple<string, string, string>> GetErrors(string compilationError) // { // var lines = compilationError.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); // var regex = new Regex(@"\((\d+),\d+\):\s+(warning|error)\s+CS(\d{4})"); // foreach (var line in lines) // { // var m = regex.Match(line); // if (!m.Success) // continue; // var lineNumber = m.Groups[1].Value; // var type = m.Groups[2].Value; // var code = m.Groups[3].Value; // yield return Tuple.Create(lineNumber, type, code); // } // } // // private static string RemoveFileName(string str) // { // var pos = str.IndexOf('('); // return pos == -1 ? "" : str.Substring(pos); // } // // private static int SecondIndexOf(string str, char pattern) // { // var pos = str.IndexOf(pattern); // if (pos == -1) // return 0; // pos = str.IndexOf(pattern, pos + 1); // return pos == -1 ? 0 : pos; // } private static IEnumerable<Solution> GetSources() { var slides = WebCourseManager.Instance .GetCourses() .SelectMany(course => course.Slides) .Where(slide => slide is ExerciseSlide) .Cast<ExerciseSlide>() .ToDictionary(slide => slide.Id); var db = new ULearnDb(); var solutions = db.UserSolutions.ToList(); return solutions.Select(solution => new Solution(slides[solution.SlideId], solution)); }
public CertificatesRepo(ULearnDb db) { this.db = db; }
public RestoreRequestRepo(ULearnDb db) { this.db = db; }
public UnitController() { db = new ULearnDb(); courseManager = WebCourseManager.Instance; usersRepo = new UsersRepo(db); }
public UnitController() { db = new ULearnDb(); courseManager = WebCourseManager.Instance; }
public CoursesRepo(ULearnDb db) { this.db = db; }
public VisitsRepo(ULearnDb db) { this.db = db; }
public GroupsRepo(ULearnDb db) { this.db = db; }
public ConsumersRepo(ULearnDb db) { this.db = db; }
public SlideHintRepo(ULearnDb db) { this.db = db; }
public UserCourseModel(Course course, ApplicationUser user, ULearnDb db) { Course = course; User = user; var visits = db.Visits.Where(v => v.UserId == user.Id && v.CourseId == course.Id).GroupBy(v => v.SlideId).ToDictionary(g => g.Key, g => g.FirstOrDefault()); var unitResults = new Dictionary<string, UserCourseUnitModel>(); foreach (var slide in Course.Slides) { var unit = slide.Info.UnitName; if (!unitResults.ContainsKey(unit)) unitResults.Add(unit, new UserCourseUnitModel { UnitName = unit, SlideVisits = new ProgressModel(), Exercises = new ProgressModel(), Quizes = new ProgressModel(), Total = new ProgressModel() }); var res = unitResults[unit]; var isVisited = visits.ContainsKey(slide.Id); var isPassed = isVisited && visits[slide.Id].IsPassed; var score = isPassed ? visits[slide.Id].Score : 0; res.SlideVisits.Total++; res.Total.Total += slide.MaxScore; res.Total.Earned += score; if (isVisited) res.SlideVisits.Earned++; if (slide is ExerciseSlide) { res.Exercises.Total += slide.MaxScore; res.Exercises.Earned += score; } if (slide is QuizSlide) { res.Quizes.Total += slide.MaxScore; res.Quizes.Earned += score; } } Units = course.GetUnits().Select(unitName => unitResults[unitName]).ToArray(); Total = new UserCourseUnitModel { Total = new ProgressModel(), Exercises = new ProgressModel(), SlideVisits = new ProgressModel(), Quizes = new ProgressModel() }; foreach (var result in Units) { Total.Total.Add(result.Total); Total.Exercises.Add(result.Exercises); Total.SlideVisits.Add(result.SlideVisits); Total.Quizes.Add(result.Quizes); } }
public LtiRequestsRepo() { db = new ULearnDb(); serializer = new JsonSerializer(); }
public AntiPlagiarismController(ULearnDb db, CourseManager courseManager) : this(db, new UserSolutionsRepo(db, courseManager), new GroupsRepo(db, courseManager)) { this.courseManager = courseManager; }
public UserSolutionsRepo(ULearnDb db) { this.db = db; }
public VisitsRepo(ULearnDb db) { this.db = db; this.slideCheckingsRepo = new SlideCheckingsRepo(db); }
public UserQuizzesRepo(ULearnDb db) { this.db = db; }
public UserQuestionsRepo(ULearnDb db) { this.db = db; }
public UserRolesRepo(ULearnDb db) { this.db = db; }
public override void PreRemove(ULearnDb db) { db.Set <ExerciseCodeReview>().RemoveRange(Reviews); }
public UsersRepo(ULearnDb db) { this.db = db; userRolesRepo = new UserRolesRepo(db); }
public virtual void PreRemove(ULearnDb db) { }
public CommentsRepo(ULearnDb db) { this.db = db; }
public UserCourseModel(Course course, ApplicationUser user, ULearnDb db) { Course = course; User = user; var visits = db.Visits.Where(v => v.UserId == user.Id && v.CourseId == course.Id).GroupBy(v => v.SlideId).ToDictionary(g => g.Key, g => g.FirstOrDefault()); var unitResults = new Dictionary <string, UserCourseUnitModel>(); foreach (var slide in Course.Slides) { var unit = slide.Info.UnitName; if (!unitResults.ContainsKey(unit)) { unitResults.Add(unit, new UserCourseUnitModel { UnitName = unit, SlideVisits = new ProgressModel(), Exercises = new ProgressModel(), Quizes = new ProgressModel(), Total = new ProgressModel() }); } var res = unitResults[unit]; var isVisited = visits.ContainsKey(slide.Id); var isPassed = isVisited && visits[slide.Id].IsPassed; var score = isPassed ? visits[slide.Id].Score : 0; res.SlideVisits.Total++; res.Total.Total += slide.MaxScore; res.Total.Earned += score; if (isVisited) { res.SlideVisits.Earned++; } if (slide is ExerciseSlide) { res.Exercises.Total += slide.MaxScore; res.Exercises.Earned += score; } if (slide is QuizSlide) { res.Quizes.Total += slide.MaxScore; res.Quizes.Earned += score; } } Units = course.GetUnits().Select(unitName => unitResults[unitName]).ToArray(); Total = new UserCourseUnitModel { Total = new ProgressModel(), Exercises = new ProgressModel(), SlideVisits = new ProgressModel(), Quizes = new ProgressModel() }; foreach (var result in Units) { Total.Total.Add(result.Total); Total.Exercises.Add(result.Exercises); Total.SlideVisits.Add(result.SlideVisits); Total.Quizes.Add(result.Quizes); } }