コード例 #1
0
        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));
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
ファイル: GetAllQuestionsHandler.cs プロジェクト: KyMback/sht
        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)));
        }
コード例 #4
0
        public Task <bool> Check(StudentTestSession entity)
        {
            var queryParameters = new TestSessionQueryParameters
            {
                Id           = entity.TestSessionId,
                InstructorId = _executionContextService.GetCurrentUserId(),
            };

            return(_unitOfWork.Any(queryParameters));
        }
コード例 #5
0
        public Task Handle(IEntitiesTracker entitiesTracker)
        {
            var currentUserId = _executionContextService.GetCurrentUserId();

            foreach (var entity in entitiesTracker.GetTrackedEntities <IHasCreatedBy>(TrackedEntityStates.Added))
            {
                entity.CreatedById = currentUserId;
            }

            return(Task.CompletedTask);
        }
コード例 #6
0
        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)));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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)));
        }
コード例 #9
0
ファイル: TestSessionService.cs プロジェクト: KyMback/sht
        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);
        }
コード例 #10
0
        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()))));
        }
コード例 #11
0
        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);
コード例 #12
0
ファイル: GetUserContextHandler.cs プロジェクト: KyMback/sht
        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,
            });
        }
コード例 #13
0
        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);
コード例 #14
0
        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);
コード例 #15
0
ファイル: StudentQuestionService.cs プロジェクト: KyMback/sht
        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();
        }
コード例 #16
0
 public Task <bool> Check(StudentTestSession entity)
 {
     return(Task.FromResult(entity.StudentId == _executionContextService.GetCurrentUserId()));
 }
コード例 #17
0
        public Task <IQueryable <InstructorDto> > Handle(GetInstructorProfileRequest request, CancellationToken cancellationToken)
        {
            var queryParameters = new InstructorQueryParameters(_executionContextService.GetCurrentUserId());

            return(Task.FromResult(_queryProvider.Queryable(queryParameters).Select(InstructorDto.Selector)));
        }