public IDomainModel DeleteCourse(Guid courseId)
        {
            var deletedCourseModel = new CourseDomainModel();

            try
            {
                var course = CourseInteractor.GetCourse(courseId);

                var linkedEvaluations = EvaluationService.GetEvaluationsForCourse(courseId);

                if (linkedEvaluations.Count > 0)
                {
                    foreach (var evaluation in linkedEvaluations)
                    {
                        var evaluationModel = (EvaluationDomainModel)evaluation;
                        EvaluationService.DeleteEvaluation(evaluationModel.Id);
                    }
                }

                CourseInteractor.DeleteCourse(courseId);

                deletedCourseModel = new CourseDomainModel {
                    StudentId = course.StudentId
                };
            }
            catch (GradeTrackerException gte)
            {
                return(new ErrorDomainModel(gte, false));
            }

            return(deletedCourseModel);
        }
Exemple #2
0
 public Mutation(
     ProjectService projectService,
     EvaluationService evaluationService,
     ParticipantService participantService,
     QuestionService questionService,
     AnswerService answerService,
     ActionService actionService,
     NoteService noteService,
     ClosingRemarkService closingRemarkService,
     QuestionTemplateService questionTemplateService,
     ProjectCategoryService projectCategoryService,
     IAuthService authService,
     ILogger <Mutation> logger
     )
 {
     _projectService          = projectService;
     _evaluationService       = evaluationService;
     _participantService      = participantService;
     _questionService         = questionService;
     _answerService           = answerService;
     _actionService           = actionService;
     _noteService             = noteService;
     _closingRemarkService    = closingRemarkService;
     _questionTemplateService = questionTemplateService;
     _projectCategoryService  = projectCategoryService;
     _authService             = authService;
     _logger = logger;
 }
Exemple #3
0
        void HandleAgentDisconnected()
        {
            var disconnectedAgent = agent;

            ResetAgentConnection();
            EvaluationService.OutdateAllCodeCells();

            PostEvent(ClientSessionEventKind.AgentDisconnected);

            var title = Catalog.GetString("Session Disconnected");

            Message message;

            if (SessionKind == ClientSessionKind.Workbook)
            {
                message = WithReconnectSessionAction(
                    Message.CreateErrorAlert(title, Catalog.GetString(
                                                 "The Workbook host application has terminated.")));
            }
            else
            {
                message = Message.CreateInfoAlert(
                    title,
                    Catalog.Format(Catalog.GetString(
                                       "Inspector is no longer connected to {0}. You may review and close " +
                                       "the session window at your leisure. A new Inspector session may be " +
                                       "attached via the debugger in your IDE."),
                                   disconnectedAgent.Identity.ApplicationName));
            }

            ViewControllers.Messages.PushMessage(message);
        }
        public MutationTest()
        {
            ILoggerFactory factory = new NullLoggerFactory();

            _projectService          = new ProjectService(_context);
            _evaluationService       = new EvaluationService(_context);
            _participantService      = new ParticipantService(_context);
            _questionService         = new QuestionService(_context);
            _answerService           = new AnswerService(_context);
            _questionTemplateService = new QuestionTemplateService(_context);
            _actionService           = new ActionService(_context);
            _noteService             = new NoteService(_context);
            _mutation = new Mutation(
                _projectService,
                _evaluationService,
                _participantService,
                _questionService,
                _answerService,
                _questionTemplateService,
                _actionService,
                _noteService,
                new MockAuthService(),
                new Logger <Mutation>(factory)
                );
        }
Exemple #5
0
        public MutationTest(DatabaseFixture fixture)
        {
            this.fixture = fixture;

            ILoggerFactory factory = new NullLoggerFactory();

            _projectService          = new ProjectService(fixture.context);
            _evaluationService       = new EvaluationService(fixture.context);
            _participantService      = new ParticipantService(fixture.context);
            _questionService         = new QuestionService(fixture.context);
            _answerService           = new AnswerService(fixture.context);
            _actionService           = new ActionService(fixture.context);
            _noteService             = new NoteService(fixture.context);
            _closingRemarkService    = new ClosingRemarkService(fixture.context);
            _questionTemplateService = new QuestionTemplateService(fixture.context);
            _projectCategoryService  = new ProjectCategoryService(fixture.context);
            _authService             = new MockAuthService();
            _mutation = new Mutation(
                _projectService,
                _evaluationService,
                _participantService,
                _questionService,
                _answerService,
                _actionService,
                _noteService,
                _closingRemarkService,
                _questionTemplateService,
                _projectCategoryService,
                _authService,
                new Logger <Mutation>(factory)
                );

            _project = _projectService.Create("Project");
        }
Exemple #6
0
        public ProcessItem(
            ILogger <ProcessItem> logger, CourseService courseService, LanguageService languageService,
            IdService idService, AppOptions appOptions, IHubContext <LiveHub> liveHub,
            CompareService compareService, MatlabServer matlabServer, EvaluationService evaluationService,
            CcData item)
        {
            _logger            = logger;
            _courseService     = courseService;
            _languageService   = languageService;
            _liveHub           = liveHub;
            _idService         = idService;
            _appOptions        = appOptions;
            _compareService    = compareService;
            _matlabServer      = matlabServer;
            _evaluationService = evaluationService;

            Item    = item;
            Context = new CourseContext(
                _courseService,
                _languageService,
                Item
                );

            _matlabServer.Initialize(ProcessService.ContainerName);

            var timeout = Context.CourseProblem.Timeout < 1 ? DefaultTimeoutPerCase : Context.CourseProblem.Timeout;

            TimeBank = new TimeBank(
                Context.Language,
                Item.Action == "input" ? IncreaseTimeoutForInput(timeout) : timeout
                );
            Item.Result.TimeLimit = TimeBank.TimeLeft;
        }
Exemple #7
0
        public void CreateFollowUpAnswers()
        {
            ParticipantService participantService = new ParticipantService(fixture.context);
            QuestionService    questionService    = new QuestionService(fixture.context);
            AnswerService      answerService      = new AnswerService(fixture.context);

            ProjectService    projectService    = new ProjectService(fixture.context);
            Project           project           = projectService.Create("AnswerService_GetFromQuestionExists");
            EvaluationService evaluationService = new EvaluationService(fixture.context);
            Evaluation        evaluation        = evaluationService.Create("AnswerService_GetFromQuestionExists", project, "");

            Participant             participant = participantService.Create("CreateFollowUpAnswers_id", evaluation, Organization.All, Role.Facilitator);
            QuestionTemplateService qts         = new QuestionTemplateService(fixture.context);
            List <Question>         questions   = questionService.CreateBulk(qts.GetAll().ToList(), evaluation);

            answerService.Create(participant, questions[0], Severity.High, "test_answer_0", Progression.Workshop);
            answerService.Create(participant, questions[1], Severity.High, "test_answer_1", Progression.Workshop);
            answerService.Create(participant, questions[2], Severity.High, "test_answer_2", Progression.Workshop);

            int nAnswersFollowupBefore = answerService.GetAll().Where(a => (a.Progression.Equals(Progression.FollowUp) && a.Question.Evaluation.Equals(evaluation))).Count();
            int nAnswersWorkshop       = answerService.GetAll().Where(a => (a.Progression.Equals(Progression.Workshop) && a.Question.Evaluation.Equals(evaluation))).Count();

            answerService.CreateFollowUpAnswers(evaluation);
            int nAnswersFollowup = answerService.GetAll().Where(a => (a.Progression.Equals(Progression.FollowUp) && a.Question.Evaluation.Equals(evaluation))).Count();

            Assert.Equal(nAnswersFollowupBefore + nAnswersWorkshop, nAnswersFollowup);
        }
        public void SetWorkshopCompleteDate()
        {
            Project           project    = GetProject();
            EvaluationService service    = new EvaluationService(fixture.context);
            Evaluation        evaluation = service.Create("eval_name", project, "");

            System.DateTimeOffset testStartDate = System.DateTimeOffset.UtcNow;

            Assert.Null(evaluation.WorkshopCompleteDate);

            evaluation.Progression = Progression.Workshop;
            var exceptionProgress = Assert.Throws <System.InvalidOperationException>
                                        (() => service.SetWorkshopCompleteDate(evaluation));

            Assert.Contains(
                $"WorkshopCompleteDate requires an evaluation on FollowUp; it is: {evaluation.Progression}",
                exceptionProgress.Message);

            evaluation.Progression = Progression.FollowUp;
            service.SetWorkshopCompleteDate(evaluation);
            Assert.True(testStartDate < evaluation.WorkshopCompleteDate);

            var exceptionPreviouslySet = Assert.Throws <System.InvalidOperationException>
                                             (() => service.SetWorkshopCompleteDate(evaluation));

            Assert.Contains(
                $"Completion date already set as: {evaluation.WorkshopCompleteDate}",
                exceptionPreviouslySet.Message);
        }
        public void Tests_SendClassEvaluation_1_API_Call()
        {
            //Arrange
            ClassEvaluation classEvaluation = new ClassEvaluation
            {
                Class = "7b",
                StudentEvaluations = new List <string> {
                    "Passed", "Passed", "Failed", "Passed"
                }
            };

            var mockLog = new Mock <ILogService>();

            var mockApi = new Mock <IEducationMinistryApiHandler>();
            HttpResponseMessage responseMessage = new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = new StringContent("")
            };

            mockApi.Setup(api => api.PostClassEvaluation(It.IsAny <ClassEvaluation>())).Returns(Task.FromResult <HttpResponseMessage>(responseMessage));

            int expectedNoOfApiCalls = 1;

            //Act
            EvaluationService evaluationService = new EvaluationService(mockLog.Object, mockApi.Object);

            evaluationService.SendClassEvaluation(classEvaluation);

            //Assert
            mockApi.Verify(api => api.PostClassEvaluation(classEvaluation), Times.Exactly(expectedNoOfApiCalls),
                           "The API wasn't called the expected number of times.");
            mockApi.VerifyNoOtherCalls();

            mockLog.VerifyNoOtherCalls();
        }
        private static void DoSearch()
        {
            var fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; // Starting pos

            //fen = "2rr3k/pp3pp1/1nnqbN1p/3pN3/2pP4/2P3Q1/PPB4P/R4RK1 w - -"; // Mate in 3
            fen = "r1b1k2r/ppppnppp/2n2q2/2b5/3NP3/2P1B3/PP3PPP/RN1QKB1R w KQkq - 0 1"; // Developed
            fen = "r1b1kb1r/2pp1ppp/1np1q3/p3P3/2P5/1P6/PB1NQPPP/R3KB1R b KQkq - 0 1 "; // Midgame
            var fact  = new BoardFactory();
            var board = fact.ParseFEN(fen);

            var hyperbola         = new HyperbolaQuintessence();
            var evaluationService = new EvaluationService();
            var attacksService    = new AttacksService(hyperbola);
            var movesService      = new PossibleMovesService(attacksService, hyperbola);
            var interruptor       = new ConsoleInterruptor();
            var searchService     = new SearchService(movesService, evaluationService, interruptor);

            searchService.OnSearchInfo += info => Console.WriteLine(info.ToString());
            var sParams = new SearchParams();

            //sParams.MaxDepth = 5;
            sParams.Infinite = true;

            var move = searchService.Search(board, sParams);
        }
        static void Main(string[] args)
        {
            var buEvaluation = new BasicUsersEvaluation
            {
                Id          = 1,
                User        = "******",
                Description = "Good city to visit",
                Grade       = 3
            };

            var puEvaluation = new PrimeUsersEvaluation
            {
                Id          = 2,
                User        = "******",
                Description = "Good city to visit",
                Grade       = 4
            };

            var service = new EvaluationService <CityEvaluation>();

            service.content.Evaluations.Add(buEvaluation);
            service.content.Evaluations.Add(puEvaluation);
            Console.WriteLine($"Type of evaluation: {service.GetTypeOfEvaluation()}");
            Console.WriteLine($"The final evaluation is {service.CalculateEvaluationAverage()}");
            Console.ReadKey();
        }
        public void GetQueryable()
        {
            EvaluationService evaluationService = new EvaluationService(fixture.context);

            IQueryable <Evaluation> evaluationQueryable = evaluationService.GetAll();

            Assert.True(evaluationQueryable.Count() > 0);
        }
        public void Setup()
        {
            _sendEmailServiceMock = new MockContext<ISendEmailService> ();

            _stringResource = new StringResourceMock();
            _sendEmailService = new SendEmailServiceMock (_sendEmailServiceMock);

            _service = new EvaluationService (_stringResource, _sendEmailService);
        }
        public void GetAzureIdNotExists()
        {
            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluation        = evaluationService.GetAll().First();

            ParticipantService participantService = new ParticipantService(_context);
            string             azureUniqueId      = "get_azure_unique_id_not_exists";

            Assert.Throws <NotFoundInDBException>(() => participantService.GetParticipant(azureUniqueId, evaluation));
        }
Exemple #15
0
 public AuthService(
     IHttpContextAccessor contextAccessor,
     ParticipantService participantService,
     EvaluationService evaluationService
     )
 {
     _contextAccessor    = contextAccessor;
     _participantService = participantService;
     _evaluationService  = evaluationService;
 }
        public void GetExists()
        {
            Project project = GetProject();

            EvaluationService evaluationService = new EvaluationService(fixture.context);
            Evaluation        evaluationCreate  = evaluationService.Create("some__name", project, "");

            Evaluation evaluationGet = evaluationService.GetEvaluation(evaluationCreate.Id);

            Assert.Equal(evaluationCreate, evaluationGet);
        }
        public void SetStatus()
        {
            Project           project    = GetProject();
            EvaluationService service    = new EvaluationService(fixture.context);
            Evaluation        evaluation = service.Create("eval_name", project, "");

            Status newStatus = Status.Voided;

            service.SetStatus(evaluation, newStatus);
            Assert.Equal(newStatus, evaluation.Status);
        }
        public void InitializeTest()
        {
            Stubs.Initialize();
            Stubs.EvaluationRepository.Add(new Evaluation());
            Stubs.EvaluationRepository.Add(new Evaluation());
            Stubs.EvaluationRepository.Add(new Evaluation());
            Stubs.EvaluationRepository.Add(new Evaluation());
            Stubs.UnitOfWork.Commit();

            m_target = new EvaluationService();
        }
Exemple #19
0
        public DataWrapper GetVehicleValue([FromBody] string jsonString)
        {
            Dto.Query query;
            try { query = JsonConvert.DeserializeObject <Dto.Query>(jsonString); }
            catch { throw new HttpResponseException(HttpStatusCode.NotFound); }

            var vehicleValue = EvaluationService.GetVehicleValue(query.Trim, query.EvaluationType, query.ConditionType,
                                                                 query.Mileage, query.PostalCode, query.EquipmentList);

            return(DataWrapper(new { vehicleValue }, null));
        }
 public ApplicationsController(FileService fileService, SearchService searchService, ApplicationService applicationService,
                               ApplicationTemplateService applicationTemplateService, EvaluationService evaluationService,
                               ILogger <ApplicationsController> logger)
 {
     this.fileService                = fileService;
     this.searchService              = searchService;
     this.applicationService         = applicationService;
     this.applicationTemplateService = applicationTemplateService;
     this.evaluationService          = evaluationService;
     this.logger = logger;
 }
        public void Tests_SendClassEvaluation_4_API_Calls()
        {
            //Arrange
            ClassEvaluation classEvaluation = new ClassEvaluation
            {
                Class = "7b",
                StudentEvaluations = new List <string> {
                    "Passed", "Passed", "Failed", "Passed"
                }
            };

            var mockLog = new Mock <ILogService>();

            var mockApi = new Mock <IEducationMinistryApiHandler>();

            HttpResponseMessage responseRequestTimeout1 = new HttpResponseMessage(HttpStatusCode.RequestTimeout)
            {
                Content = new StringContent("")
            };
            HttpResponseMessage responseRequestTimeout2 = new HttpResponseMessage(HttpStatusCode.RequestTimeout)
            {
                Content = new StringContent("")
            };
            HttpResponseMessage responseRequestTimeout3 = new HttpResponseMessage(HttpStatusCode.RequestTimeout)
            {
                Content = new StringContent("")
            };
            HttpResponseMessage responseRequestTimeout4 = new HttpResponseMessage(HttpStatusCode.RequestTimeout)
            {
                Content = new StringContent("")
            };

            mockApi.SetupSequence(api => api.PostClassEvaluation(It.IsAny <ClassEvaluation>()))
            .Returns(Task.FromResult <HttpResponseMessage>(responseRequestTimeout1))
            .Returns(Task.FromResult <HttpResponseMessage>(responseRequestTimeout2))
            .Returns(Task.FromResult <HttpResponseMessage>(responseRequestTimeout3))
            .Returns(Task.FromResult <HttpResponseMessage>(responseRequestTimeout4));

            int    expectedNoOfApiCalls = 3;
            string expectedLogMessage   = "Could not send class evaluation because of request timeout.";

            //Act
            EvaluationService evaluationService = new EvaluationService(mockLog.Object, mockApi.Object);

            evaluationService.SendClassEvaluation(classEvaluation);

            //Assert
            mockApi.Verify(api 8u => api.PostClassEvaluation(classEvaluation), Times.Exactly(expectedNoOfApiCalls),
                           "The API wasn't called the expected number of times.");
            mockApi.VerifyNoOtherCalls();

            mockLog.Verify(log => log.Log(expectedLogMessage), "The expected message wasn't logged.");
            mockLog.VerifyNoOtherCalls();
        }
Exemple #22
0
        private static void DoEvaluate()
        {
            //var fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
            var fen               = "r4rk1/p2n1ppp/3qp3/6B1/N5P1/3P1b2/PPP1BbP1/R2Q1R1K b - - 0 14";
            var boardFactory      = new BoardFactory();
            var board             = boardFactory.ParseFEN(fen);
            var evaluationService = new EvaluationService();
            var evaluation        = evaluationService.Evaluate(board, null);

            Console.WriteLine(evaluation);
        }
        public void SetSummary()
        {
            Project           project    = GetProject();
            EvaluationService service    = new EvaluationService(fixture.context);
            Evaluation        evaluation = service.Create("eval_name", project, "");

            string summary = "Summary";

            Assert.Equal("", evaluation.Summary);
            service.SetSummary(evaluation, summary);
            Assert.Equal(summary, evaluation.Summary);
        }
Exemple #24
0
 async Task InitializeAgentConnectionAsync()
 {
     if (EvaluationService != null)
     {
         using (EvaluationService.InhibitEvaluate())
             await DoInitalizeAgentConnectionAsync();
     }
     else
     {
         await DoInitalizeAgentConnectionAsync();
     }
 }
        public void GetExists()
        {
            ProjectService projectService = new ProjectService(_context);
            Project        project        = projectService.GetAll().First();

            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluationCreate  = evaluationService.Create("some_evaluation_name", project);

            Evaluation evaluationGet = evaluationService.GetEvaluation(evaluationCreate.Id);

            Assert.Equal(evaluationCreate, evaluationGet);
        }
        public void Create()
        {
            Project           project           = GetProject();
            EvaluationService evaluationService = new EvaluationService(fixture.context);

            int nEvaluationsBefore = evaluationService.GetAll().Count();

            evaluationService.Create("some_name", project, "");
            int nEvaluationsAfter = evaluationService.GetAll().Count();

            Assert.Equal(nEvaluationsBefore + 1, nEvaluationsAfter);
        }
        public void SaveEvaluation_GameDoesNotExists_Exception()
        {
            var target     = new EvaluationService();
            var evaluation = new Evaluation()
            {
                GameKey = 1
            };

            ExceptionAssert.IsThrowing(new SpecificationNotSatisfiedException("An evaluation should have a valid Game. The game with key '1' does not exists."), () => {
                target.SaveEvaluation(evaluation);
            });
        }
        public void CreateGetsCorrectEvaluationId()
        {
            ParticipantService participantService = new ParticipantService(_context);
            EvaluationService  evaluationService  = new EvaluationService(_context);
            Evaluation         evaluation         = evaluationService.GetAll().First();

            string      evaluationIdBefore = evaluation.Id;
            Participant participant        = participantService.Create("CreateGetsCorrectEvaluationId_id", evaluation, Organization.Engineering, Role.Participant);
            string      evaluationIdAfter  = participant.Evaluation.Id;

            Assert.Equal(evaluationIdBefore, evaluationIdAfter);
        }
        public void GetExist()
        {
            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluation        = evaluationService.GetAll().First();

            ParticipantService participantService = new ParticipantService(_context);
            Participant        participantCreate  = participantService.Create("GetExist_id", evaluation, Organization.Engineering, Role.Participant);

            Participant participantGet = participantService.GetParticipant(participantCreate.Id);

            Assert.Equal(participantCreate, participantGet);
        }
Exemple #30
0
        public void ParticipantAddedToEvaluation()
        {
            EvaluationService  evaluationService  = new EvaluationService(_context);
            Evaluation         evaluation         = evaluationService.GetAll().First();
            ParticipantService participantService = new ParticipantService(_context);

            int participantsBefore = evaluation.Participants.Count;

            participantService.Create("ParticipantAddedToEvaluation_id", evaluation, Organization.Engineering, Role.Participant);
            int participantsAfter = evaluation.Participants.Count;

            Assert.Equal(participantsBefore + 1, participantsAfter);
        }
        public static EvaluationService Create_EvaluationService()
        {
            var evalInteractor = new MockEvaluationInteractor();

            var scoreInteractor = new MockScoreInteractor();

            var service = new EvaluationService();

            service.EvaluationInteractor = evalInteractor;
            service.ScoreInteractor      = scoreInteractor;

            return(service);
        }