public Task <bool> Check(StudentTestSession entity) { Guid id = _executionContextService.GetCurrentUserId(); if (entity.StudentId == id) { return(Task.FromResult(true)); } var queryParameters = new TestSessionQueryParameters { Id = entity.TestSessionId, InstructorId = _executionContextService.GetCurrentUserId(), }; return(_unitOfWork.Any(queryParameters)); }
public Task <IQueryable <TestVariantDto> > Handle(GetAllTestVariantsRequest request, CancellationToken cancellationToken) { var queryParameters = new TestVariantQueryParameters { CreatedById = _executionContextService.GetCurrentUserId(), }; return(Task.FromResult(_queryProvider.Queryable(queryParameters).Select(TestVariantDto.Selector))); }
public Task <IQueryable <QuestionDto> > Handle(GetAllQuestionsRequest request, CancellationToken cancellationToken) { var queryParameters = new QuestionTemplateQueryParameters { // TODO: currently user can see only his questions CreatedById = _executionContextService.GetCurrentUserId(), }; return(Task.FromResult(_queryProvider.Queryable(queryParameters).Select(QuestionDto.Selector))); }
public Task <bool> Check(StudentTestSession entity) { var queryParameters = new TestSessionQueryParameters { Id = entity.TestSessionId, InstructorId = _executionContextService.GetCurrentUserId(), }; return(_unitOfWork.Any(queryParameters)); }
public Task Handle(IEntitiesTracker entitiesTracker) { var currentUserId = _executionContextService.GetCurrentUserId(); foreach (var entity in entitiesTracker.GetTrackedEntities <IHasCreatedBy>(TrackedEntityStates.Added)) { entity.CreatedById = currentUserId; } return(Task.CompletedTask); }
public Task <IQueryable <StudentTestQuestionDto> > Handle( GetAllStudentTestQuestionsRequest request, CancellationToken cancellationToken) { var queryParameters = new StudentTestSessionQuestionQueryParameters { StudentId = _executionContextService.GetCurrentUserId(), }; return(Task.FromResult(_queryProvider.Queryable(queryParameters).Select(StudentTestQuestionDto.Selector))); }
public async Task <IReadOnlyCollection <string> > Handle( GetStudentTestSessionTriggersRequest request, CancellationToken cancellationToken) { var queryParameters = new StudentTestSessionQueryParameters(request.TestSessionId) { StudentId = _executionContextService.GetCurrentUserId(), }; var testSession = await _unitOfWork.GetSingle(queryParameters); return(await _stateManager.GetAvailableTriggers(testSession)); }
public Task <IQueryable <AnswersRatingDto> > Handle( GetAllAnswersRatingsRequest request, CancellationToken cancellationToken) { var queryParameters = new AnswersRatingQueryParameters { StudentId = _executionContextService.GetCurrentUserId(), TestSessionState = TestSessionState.Assessment, }; return(Task.FromResult(_queryProvider.Queryable(queryParameters).Select(AnswersRatingDto.Selector))); }
public async Task <TestSession> Create(TestSession session) { session.State = TestSessionState.Pending; session.InstructorId = _executionContextService.GetCurrentUserId(); session.StudentTestSessions.ForEach(e => e.State = StudentTestSessionState.Pending); var result = await _unitOfWork.Add(session); await _unitOfWork.Commit(); return(result); }
public Task <IQueryable <Lookup> > Handle( GetStudentTestSessionVariantsRequest request, CancellationToken cancellationToken) { var queryParameters = new TestSessionVariantsQueryParameters { StudentTestSessionId = request.StudentTestSessionId, StudentId = _executionContextService.GetCurrentUserId(), }; return(Task.FromResult(_queryProvider.Queryable(queryParameters) .Select(e => new Lookup(e.Name, e.Id.ToString())))); }
public async Task <Unit> Handle(UpdateQuestionRequest request, CancellationToken cancellationToken) { var queryParams = new QuestionTemplateQueryParameters { Id = request.Id, IsReadOnly = false, CreatedById = _executionContextService.GetCurrentUserId(), }; var question = await _unitOfWork.GetSingle(queryParams); _mapper.Map(request.Data, question); await _unitOfWork.Commit(); return(default);
public async Task <UserContextDto> Handle(GetUserContextRequest request, CancellationToken cancellationToken) { var queryParameters = new AccountQueryParameters(_executionContextService.GetCurrentUserId()); var data = await _unitOfWork.GetSingleOrDefault(queryParameters, UserContextDto.Selector); if (data != null) { data.IsAuthenticated = true; data.Culture = CultureInfo.CurrentCulture.Name; } return(data ?? new UserContextDto { Culture = CultureInfo.CurrentCulture.Name, }); }
public async Task <Unit> Handle(UpdateStudentProfileRequest request, CancellationToken cancellationToken) { var queryParams = new StudentQueryParameters { Id = _executionContextService.GetCurrentUserId(), IsReadOnly = false, }; var student = await _unitOfWork.GetSingle(queryParams); _mapper.Map(request.Data, student); await _unitOfWork.Update(student); await _unitOfWork.Commit(); return(default);
public async Task <Unit> Handle(UpdateTestSessionRequest request, CancellationToken cancellationToken) { var queryParameters = new TestSessionQueryParameters { Id = request.TestSessionId, InstructorId = _executionContextService.GetCurrentUserId(), IsReadOnly = false, IncludeStudentTestSessions = true, IncludeAssessment = true, IncludeVariants = true, IncludeVariantsQuestions = true, IncludeAnswersAssessmentQuestions = true, }; TestSession testSession = await _unitOfWork.GetSingle(queryParameters); _mapper.Map(request.Data, testSession); await _testSessionService.Update(testSession); return(default);
public async Task Answer(Guid questionId, QuestionGenericAnswer answer) { // TODO: add includes to optimize query var queryParameters = new StudentTestSessionQuestionQueryParameters { StudentId = _executionContextService.GetCurrentUserId(), IsReadOnly = false, Id = questionId, }; StudentTestSessionQuestion question = await _unitOfWork.GetSingle(queryParameters); await _studentQuestionValidationService.ThrowIfCannotAnswer(question.StudentTestSessionId); SetAnswer(question, answer); await _unitOfWork.Update(question); await _unitOfWork.Commit(); }
public Task <bool> Check(StudentTestSession entity) { return(Task.FromResult(entity.StudentId == _executionContextService.GetCurrentUserId())); }
public Task <IQueryable <InstructorDto> > Handle(GetInstructorProfileRequest request, CancellationToken cancellationToken) { var queryParameters = new InstructorQueryParameters(_executionContextService.GetCurrentUserId()); return(Task.FromResult(_queryProvider.Queryable(queryParameters).Select(InstructorDto.Selector))); }