private static async Task ResendLti(UlearnDb db) { var ltiConsumersRepo = new LtiConsumersRepo(db); var slideCheckingsRepo = new SlideCheckingsRepo(db, null); var visitsRepo = new VisitsRepo(db, slideCheckingsRepo); // current 288064 var ltiRequests = await db.LtiRequests.Where(r => r.RequestId > 285417).OrderByDescending(r => r.RequestId).ToListAsync(); var courseManager = new CourseManager(CourseManager.GetCoursesDirectory()); var i = 0; foreach (var ltiRequest in ltiRequests) { i++; Console.WriteLine($"{i} requestId {ltiRequest.RequestId}"); try { var course = courseManager.GetCourse(ltiRequest.CourseId); var slide = course.GetSlideById(ltiRequest.SlideId, true); var score = await visitsRepo.GetScore(ltiRequest.CourseId, ltiRequest.SlideId, ltiRequest.UserId); await LtiUtils.SubmitScore(slide, ltiRequest.UserId, score, ltiRequest.Request, ltiConsumersRepo); Console.WriteLine($"{i} requestId {ltiRequest.RequestId} score {score}"); } catch (Exception ex) { Console.WriteLine(ex); } } }
public static int GetManualCheckingsCountInQueue(SlideCheckingsRepo slideCheckingsRepo, GroupsRepo groupsRepo, IPrincipal user, string courseId, Slide slide, List <string> groupsIds) { var filterOptions = GetFilterOptionsByGroup <ManualCheckingQueueFilterOptions>(groupsRepo, user, courseId, groupsIds); if (filterOptions.UserIds == null) { groupsIds = new List <string> { "all" } } ; filterOptions.SlidesIds = new List <Guid> { slide.Id }; if (slide is ExerciseSlide) { return(slideCheckingsRepo.GetManualCheckingQueue <ManualExerciseChecking>(filterOptions).Count()); } if (slide is QuizSlide) { return(slideCheckingsRepo.GetManualCheckingQueue <ManualQuizChecking>(filterOptions).Count()); } throw new ArgumentException("Slide should be quiz or exercise", nameof(slide)); } }
public ExerciseController(CourseManager courseManager) { this.courseManager = courseManager; groupsRepo = new GroupsRepo(db); solutionsRepo = new UserSolutionsRepo(db); visitsRepo = new VisitsRepo(db); slideCheckingsRepo = new SlideCheckingsRepo(db); }
public QuizController(CourseManager courseManager) { this.courseManager = courseManager; userQuizzesRepo = new UserQuizzesRepo(db); visitsRepo = new VisitsRepo(db); quizzesRepo = new QuizzesRepo(db); groupsRepo = new GroupsRepo(db); slideCheckingsRepo = new SlideCheckingsRepo(db); }
// Обновляет пройденные тесты с нулевым баллом public static async Task UpdateTests(UlearnDb db, string courseId) { var courseManager = new CourseManager(CourseManager.GetCoursesDirectory()); var course = courseManager.GetCourse(courseId); var slideCheckingsRepo = new SlideCheckingsRepo(db, null); var visitsRepo = new VisitsRepo(db, slideCheckingsRepo); var tests = course.GetSlides(true).OfType <QuizSlide>().ToList(); foreach (var test in tests) { var testVisits = db.Visits.Where(v => v.CourseId == courseId && v.SlideId == test.Id && v.IsPassed && v.Score == 0).ToList(); foreach (var visit in testVisits) { var answers = db.UserQuizAnswers.Where(s => s.Submission.CourseId == courseId && s.Submission.UserId == visit.UserId && s.Submission.SlideId == visit.SlideId).ToList(); var groupsBySubmission = answers.GroupBy(a => a.Submission.Id).ToList(); foreach (var group in groupsBySubmission) { var submissionAnswers = group.ToList(); var blockAnswers = submissionAnswers.GroupBy(s => s.BlockId); var allQuizInfos = new List <QuizInfoForDb>(); foreach (var ans in blockAnswers) { var quizInfos = CreateQuizInfo(test, ans); if (quizInfos != null) { allQuizInfos.AddRange(quizInfos); } } foreach (var answer in submissionAnswers) { var valid = allQuizInfos.First(i => i.BlockId == answer.BlockId && i.ItemId == answer.ItemId); answer.QuizBlockScore = valid.QuizBlockScore; answer.QuizBlockMaxScore = valid.QuizBlockMaxScore; } var score = allQuizInfos .DistinctBy(forDb => forDb.BlockId) .Sum(forDb => forDb.QuizBlockScore); var checking = db.AutomaticQuizCheckings.FirstOrDefault(c => c.Submission.Id == group.Key); if (checking != null) // В случае попытки сверх лимита AutomaticQuizCheckings не создается, но ответы сохраняются в UserQuizAnswers { checking.Score = score; } db.SaveChanges(); } await visitsRepo.UpdateScoreForVisit(courseId, test, visit.UserId); } Console.WriteLine(test.Id); } }
public QuizController() { metricSender = new GraphiteMetricSender("web"); userQuizzesRepo = new UserQuizzesRepo(db); visitsRepo = new VisitsRepo(db); groupsRepo = new GroupsRepo(db, courseManager); slideCheckingsRepo = new SlideCheckingsRepo(db); notificationsRepo = new NotificationsRepo(db); }
public RunnerController(ULearnDb db, CourseManager courseManager) { this.db = db; this.courseManager = courseManager; userSolutionsRepo = new UserSolutionsRepo(db, courseManager); slideCheckingsRepo = new SlideCheckingsRepo(db); visitsRepo = new VisitsRepo(db); groupsRepo = new GroupsRepo(db, courseManager); usersRepo = new UsersRepo(db); metricSender = new MetricSender(ApplicationConfiguration.Read <UlearnConfiguration>().GraphiteServiceName); }
public QuizController() { metricSender = new MetricSender(ApplicationConfiguration.Read <UlearnConfiguration>().GraphiteServiceName); userQuizzesRepo = new UserQuizzesRepo(db); visitsRepo = new VisitsRepo(db); groupsRepo = new GroupsRepo(db, courseManager); slideCheckingsRepo = new SlideCheckingsRepo(db); notificationsRepo = new NotificationsRepo(db); unitsRepo = new UnitsRepo(db); }
public CertificateGenerator( UserQuizzesRepo userQuizzesRepo, UserSolutionsRepo userSolutionsRepo, SlideCheckingsRepo slideCheckingsRepo, VisitsRepo visitsRepo) { this.userQuizzesRepo = userQuizzesRepo; this.userSolutionsRepo = userSolutionsRepo; this.slideCheckingsRepo = slideCheckingsRepo; this.visitsRepo = visitsRepo; }
public CourseController() { slideCheckingsRepo = new SlideCheckingsRepo(db); visitsRepo = new VisitsRepo(db); unitsRepo = new UnitsRepo(db); slideRateRepo = new SlideRateRepo(db); solutionsRepo = new UserSolutionsRepo(db, courseManager); ltiRequestsRepo = new LtiRequestsRepo(db); groupsRepo = new GroupsRepo(db, courseManager); userQuizzesRepo = new UserQuizzesRepo(db); coursesRepo = new CoursesRepo(db); }
public CodeReviewStatisticsController(ILogger logger, WebCourseManager courseManager, SlideCheckingsRepo slideCheckingsRepo, UserRolesRepo userRolesRepo, UsersRepo usersRepo, GroupsRepo groupsRepo, UlearnDb db) : base(logger, courseManager, db) { this.slideCheckingsRepo = slideCheckingsRepo; this.userRolesRepo = userRolesRepo; this.usersRepo = usersRepo; this.groupsRepo = groupsRepo; }
public AccountController() { userRolesRepo = new UserRolesRepo(db); groupsRepo = new GroupsRepo(db, courseManager); certificatesRepo = new CertificatesRepo(db); visitsRepo = new VisitsRepo(db); notificationsRepo = new NotificationsRepo(db); coursesRepo = new CoursesRepo(db); systemAccessesRepo = new SystemAccessesRepo(db); tempCoursesRepo = new TempCoursesRepo(db); slideCheckingsRepo = new SlideCheckingsRepo(db); telegramSecret = WebConfigurationManager.AppSettings["ulearn.telegram.webhook.secret"] ?? ""; }
public BaseExerciseController(ULearnDb db, CourseManager courseManager, GraphiteMetricSender metricSender) { this.db = db; this.courseManager = courseManager; this.metricSender = metricSender; userSolutionsRepo = new UserSolutionsRepo(db, courseManager); slideCheckingsRepo = new SlideCheckingsRepo(db); groupsRepo = new GroupsRepo(db, courseManager); visitsRepo = new VisitsRepo(db); notificationsRepo = new NotificationsRepo(db); usersRepo = new UsersRepo(db); styleErrorsRepo = new StyleErrorsRepo(db); }
public GroupsRepo( UlearnDb db, SlideCheckingsRepo slideCheckingsRepo, UserSolutionsRepo userSolutionsRepo, UserQuizzesRepo userQuizzesRepo, VisitsRepo visitsRepo, GroupsCreatorAndCopier groupsCreatorAndCopier, WebCourseManager courseManager, ILogger logger) { this.db = db; this.slideCheckingsRepo = slideCheckingsRepo; this.userSolutionsRepo = userSolutionsRepo; this.userQuizzesRepo = userQuizzesRepo; this.visitsRepo = visitsRepo; this.groupsCreatorAndCopier = groupsCreatorAndCopier; this.courseManager = courseManager; this.logger = logger; }
private static async Task UpdateExerciseVisits(UlearnDb db, string courseId) { var courseManager = new CourseManager(CourseManager.GetCoursesDirectory()); var course = courseManager.GetCourse(courseId); var slideCheckingsRepo = new SlideCheckingsRepo(db, null); var visitsRepo = new VisitsRepo(db, slideCheckingsRepo); var slides = course.GetSlides(true).OfType <ExerciseSlide>().ToList(); foreach (var slide in slides) { var slideVisits = db.Visits.Where(v => v.CourseId == courseId && v.SlideId == slide.Id && v.IsPassed).ToList(); foreach (var visit in slideVisits) { await visitsRepo.UpdateScoreForVisit(courseId, slide, visit.UserId); } } }
public static async Task <bool> SendToReviewAndUpdateScore(UserExerciseSubmission submission, CourseManager courseManager, SlideCheckingsRepo slideCheckingsRepo, GroupsRepo groupsRepo, VisitsRepo visitsRepo, MetricSender metricSender, bool startTransaction) { var userId = submission.User.Id; var courseId = submission.CourseId; var course = courseManager.GetCourse(courseId); var exerciseSlide = course.FindSlideById(submission.SlideId, true) as ExerciseSlide; // SlideId проверен в вызывающем методе if (exerciseSlide == null) { return(false); } var exerciseMetricId = GetExerciseMetricId(courseId, exerciseSlide); var automaticChecking = submission.AutomaticChecking; var isProhibitedUserToSendForReview = slideCheckingsRepo.IsProhibitedToSendExerciseToManualChecking(courseId, exerciseSlide.Id, userId); var sendToReview = exerciseSlide.Scoring.RequireReview && submission.AutomaticCheckingIsRightAnswer && !isProhibitedUserToSendForReview && groupsRepo.IsManualCheckingEnabledForUser(course, userId); if (sendToReview) { await slideCheckingsRepo.RemoveWaitingManualCheckings <ManualExerciseChecking>(courseId, exerciseSlide.Id, userId, false); await slideCheckingsRepo.AddManualExerciseChecking(courseId, exerciseSlide.Id, userId, submission); await visitsRepo.MarkVisitsAsWithManualChecking(courseId, exerciseSlide.Id, userId); metricSender.SendCount($"exercise.{exerciseMetricId}.sent_to_review"); metricSender.SendCount("exercise.sent_to_review"); } await visitsRepo.UpdateScoreForVisit(courseId, exerciseSlide, userId); if (automaticChecking != null) { var verdictForMetric = automaticChecking.GetVerdict().Replace(" ", ""); metricSender.SendCount($"exercise.{exerciseMetricId}.{verdictForMetric}"); } return(sendToReview); }
public VisitsRepo(ULearnDb db) { this.db = db; this.slideCheckingsRepo = new SlideCheckingsRepo(db); }