示例#1
0
        public async Task Start(StudentTestSession studentTestSession, Guid variantId)
        {
            var queryParams = new TestSessionVariantsQueryParameters
            {
                Id            = variantId,
                TestSessionId = studentTestSession.TestSessionId,
                IsReadOnly    = false,
            };

            var testVariant = await _unitOfWork.GetSingleOrDefault(queryParams);

            if (testVariant == null)
            {
                throw new CodedException(ErrorCode.InvalidVariantName);
            }

            if (studentTestSession.TestSession.StudentTestDuration.HasValue)
            {
                studentTestSession.ShouldEndAt =
                    _dateTimeProvider.UtcNow.Add(studentTestSession.TestSession.StudentTestDuration.Value);
            }

            studentTestSession.TestVariantId = variantId;
            studentTestSession.Questions     = GenerateQuestions(testVariant);
            await _unitOfWork.Update(studentTestSession);
        }
示例#2
0
        public async Task <Unit> Handle(StudentTestSessionStateTransitionRequest request, CancellationToken cancellationToken)
        {
            var queryParameters = new StudentTestSessionQueryParameters(request.StudentTestSessionId)
            {
                IsReadOnly = false,
            };
            StudentTestSession session = await _unitOfWork.GetSingle(queryParameters);

            await _stateManager.Process(session, request.Trigger, request.SerializedData);

            await _unitOfWork.Update(session);

            await _unitOfWork.Commit();

            return(Unit.Value);
        }