예제 #1
0
        private int AssignStudentsToSynthesis(IEnumerable <Guid> studentIds, int testId)
        {
            if (_synthesisRepo.Get(testId).Status >= TestStatus.Completed)
            {
                return(0);
            }

            var synthesisEntity = _synthesisRepo.GetWithTaskAndTemplate(testId);
            var userMapEntities = _userRepo.Get(studentIds);

            var createContainedUserSuccessIds = new List <Guid>();

            #region Create_Contained_Users
            var task     = synthesisEntity.Task;
            var template = task.Template;
            foreach (var userMapEntity in userMapEntities)
            {
                if (CreateContainedReadonly(userMapEntity.SqlUsername, userMapEntity.SqlPassword, template.NameOnServer))
                {
                    createContainedUserSuccessIds.Add(userMapEntity.AzureId);
                }
            }
            #endregion

            return(_studentRepo.AssignSynthesisTest(createContainedUserSuccessIds, testId, UserId));
        }
예제 #2
0
        public ActionResult <Result <bool> > DeleteSynthesisTest([FromBody] DeleteEntityRQ body)
        {
            var entity = _synthesisRepo.Get(body.Id);

            if (entity.Status > TestStatus.Scheduled)
            {
                var statusText = entity.Status.ToString().ToLower();
                return(Result <bool> .Fail($"Unable to delete. Delete of '{statusText}' test is not allowed"));
            }

            var assignedCount = _synthesisRepo.AssignedStudentsCount(body.Id);

            if (assignedCount > 0)
            {
                return(Result <bool> .Fail($"Unable to delete. A total of {assignedCount} students are assigned to this test."));
            }

            var success = _synthesisRepo.DeleteTest(body.Id, body.TimeStamp);

            if (success)
            {
                return(Result <bool> .Success(true));
            }
            else
            {
                return(Result <bool> .Fail("Failed to delete record."));
            }
        }
예제 #3
0
        public IActionResult AssignStudents(int testId, TestType testType)
        {
            switch (testType)
            {
            case TestType.Synthesis:
                if (_synthesisRepository.Get(testId).Status >= TestStatus.Completed)
                {
                    return(StatusCode(500));
                }
                break;

            case TestType.Analysis:
                if (_analysisRepository.Get(testId).Status >= TestStatus.Completed)
                {
                    return(StatusCode(500));
                }
                break;

            default:
                return(StatusCode(500));
            }

            var vm = new AssignStudentsVM
            {
                TestId          = testId,
                TestType        = testType,
                InitialPageSize = 10
            };

            return(View(vm));
        }