Esempio n. 1
0
        public async Task <NOMSurveyReplyResult> UpdateSurveyAsync(NOMSurveyReply reply, Guid identityWorkId)
        {
            var middlewareManager = new MiddlewareManager <NOMSurveyReply>(new BaseRecordManager <NOMSurveyReply>(), new NOMSurveyReplyValidator());
            await middlewareManager.UpdateAsync(new List <NOMSurveyReply>() { reply }, identityWorkId);

            return(new NOMSurveyReplyResult());
        }
Esempio n. 2
0
        public NOMSurveyReply ProcessFinalizationRP(NOMSurveyReply answeredSurvey, List <NOMAnswer> answers,
                                                    List <NOMEvaluationQuestion> aTSQuestions, List <NOMEvaluationCategory> categories, List <NOMEvaluationDomain> domains)
        {
            RPEvaluator evaluator = new RPEvaluator();

            return(evaluator.ProcessFinalization(answeredSurvey, answers, aTSQuestions, categories, domains));
        }
Esempio n. 3
0
        public NOMSurveyReply BuildNomSurveyReply(Guid identityWorkId, Guid instanceId, Guid employeeId,
                                                  Guid periodId, Guid evaluationSurveyID)
        {
            var nomSurveyReply = new NOMSurveyReply()
            {
                ID                    = Guid.NewGuid(),
                Active                = true,
                Timestamp             = DateTime.UtcNow,
                Description           = String.Empty,
                CreationDate          = DateTime.Now,
                EmployeeID            = employeeId,
                NOMEvaluationPeriodID = periodId,
                NOMEvaluationSurveyID = evaluationSurveyID,
                company               = identityWorkId,
                user                  = Guid.NewGuid(),
                InstanceID            = instanceId,
                Result                = 0,
                ResultType            = NOMSurveyReplyResultType.Numeric,
                EvaluationState       = EvaluationStateType.New,
                Name                  = "",
                StatusID              = 1,
            };

            return(nomSurveyReply);
        }
Esempio n. 4
0
        public NOMSurveyReply ProcessFinalizationATS(NOMSurveyReply answeredSurvey, List <NOMAnswer> answers,
                                                     List <NOMEvaluationQuestion> aTSQuestions,
                                                     List <NOMEvaluationPhase> aTSPhases)
        {
            ATSEvaluator evaluator = new ATSEvaluator();

            return(evaluator.ProcessFinalizationATS(answeredSurvey, answers, aTSQuestions, aTSPhases));
        }
Esempio n. 5
0
        public NOMSurveyReply ProcessFinalization(NOMSurveyReply answeredSurvey, List <NOMAnswer> answers,
                                                  List <NOMEvaluationQuestion> aTSQuestions, List <NOMEvaluationCategory> categories, List <NOMEvaluationDomain> domains)
        {
            NOMSurveyCategoryResult category1Result = new NOMSurveyCategoryResult();
            NOMSurveyCategoryResult category2Result = new NOMSurveyCategoryResult();
            NOMSurveyCategoryResult category3Result = new NOMSurveyCategoryResult();
            NOMSurveyCategoryResult category4Result = new NOMSurveyCategoryResult();

            NOMSurveyDomainResult domain1Result = new NOMSurveyDomainResult();
            NOMSurveyDomainResult domain2Result = new NOMSurveyDomainResult();
            NOMSurveyDomainResult domain3Result = new NOMSurveyDomainResult();
            NOMSurveyDomainResult domain4Result = new NOMSurveyDomainResult();
            NOMSurveyDomainResult domain5Result = new NOMSurveyDomainResult();
            NOMSurveyDomainResult domain6Result = new NOMSurveyDomainResult();
            NOMSurveyDomainResult domain7Result = new NOMSurveyDomainResult();
            NOMSurveyDomainResult domain8Result = new NOMSurveyDomainResult();


            answeredSurvey.NOMSurveyCategoryResult = new List <NOMSurveyCategoryResult>();
            answeredSurvey.NOMSurveyDomainResult   = new List <NOMSurveyDomainResult>();


            answeredSurvey.NOMSurveyCategoryResult.Add(category1Result);
            answeredSurvey.NOMSurveyCategoryResult.Add(category2Result);
            answeredSurvey.NOMSurveyCategoryResult.Add(category3Result);
            answeredSurvey.NOMSurveyCategoryResult.Add(category4Result);

            answeredSurvey.NOMSurveyDomainResult.Add(domain1Result);
            answeredSurvey.NOMSurveyDomainResult.Add(domain2Result);
            answeredSurvey.NOMSurveyDomainResult.Add(domain3Result);
            answeredSurvey.NOMSurveyDomainResult.Add(domain4Result);
            answeredSurvey.NOMSurveyDomainResult.Add(domain5Result);
            answeredSurvey.NOMSurveyDomainResult.Add(domain6Result);
            answeredSurvey.NOMSurveyDomainResult.Add(domain7Result);
            answeredSurvey.NOMSurveyDomainResult.Add(domain8Result);

            var firstCategoryID  = categories.FirstOrDefault(x => x.Number == 1).ID;
            var secondCategoryID = categories.FirstOrDefault(x => x.Number == 2).ID;
            var thirdCategoryID  = categories.FirstOrDefault(x => x.Number == 3).ID;
            var fourthCategoryID = categories.FirstOrDefault(x => x.Number == 4).ID;

            var firstDomainID   = domains.FirstOrDefault(x => x.Number == 1).ID;
            var secondDomainID  = domains.FirstOrDefault(x => x.Number == 2).ID;
            var thirdDomainID   = domains.FirstOrDefault(x => x.Number == 3).ID;
            var fourthDomainID  = domains.FirstOrDefault(x => x.Number == 4).ID;
            var fifthDomainID   = domains.FirstOrDefault(x => x.Number == 5).ID;
            var sixthDomainID   = domains.FirstOrDefault(x => x.Number == 6).ID;
            var seventhDomainID = domains.FirstOrDefault(x => x.Number == 7).ID;
            var eigthDomainID   = domains.FirstOrDefault(x => x.Number == 8).ID;

            AssignPoints(answers, aTSQuestions, firstCategoryID, secondCategoryID, thirdCategoryID,
                         fourthCategoryID, firstDomainID, secondDomainID, thirdDomainID, fourthDomainID,
                         fifthDomainID, sixthDomainID, seventhDomainID, eigthDomainID, category1Result, category2Result, category3Result, category4Result,
                         domain1Result, domain2Result, domain3Result, domain4Result, domain5Result, domain6Result,
                         domain7Result, domain8Result, answeredSurvey);

            return(answeredSurvey);
        }
Esempio n. 6
0
        public NOMSurveyReply ProcessFinalizationATS(NOMSurveyReply answeredSurvey, List <NOMAnswer> answers,
                                                     List <NOMEvaluationQuestion> aTSQuestions,
                                                     List <NOMEvaluationPhase> aTSPhases)
        {
            var evaluationFirstAsemptionRes = FirstPhaseEvaluation(answeredSurvey, answers,
                                                                   aTSQuestions, aTSPhases);
            var needMoreValidation = evaluationFirstAsemptionRes.need;

            answeredSurvey = evaluationFirstAsemptionRes.survey;

            if (needMoreValidation)
            {
                var evaluationSecondAsemptionRes = FirstToFourthPhaseEvaluation(answeredSurvey, answers,
                                                                                aTSQuestions, aTSPhases, 2, 0);

                needMoreValidation = evaluationSecondAsemptionRes.need;
                answeredSurvey     = evaluationSecondAsemptionRes.survey;

                if (needMoreValidation)
                {
                    var(survey, need) = FirstToFourthPhaseEvaluation(answeredSurvey, answers,
                                                                     aTSQuestions, aTSPhases, 3, 2);

                    needMoreValidation = need;
                    answeredSurvey     = survey;

                    if (needMoreValidation)
                    {
                        var evaluationFourthAsemptionRes = FirstToFourthPhaseEvaluation(answeredSurvey, answers,
                                                                                        aTSQuestions, aTSPhases, 4, 1);
                        needMoreValidation = evaluationFourthAsemptionRes.need;
                        answeredSurvey     = evaluationFourthAsemptionRes.survey;
                    }
                }
            }

            return(answeredSurvey);
        }
Esempio n. 7
0
        private (NOMSurveyReply survey, bool need) FirstToFourthPhaseEvaluation(NOMSurveyReply answeredSurvey, List <NOMAnswer> answers,
                                                                                List <NOMEvaluationQuestion> aTSQuestions,
                                                                                List <NOMEvaluationPhase> aTSPhases, int phaseNumber, int validBoundary)
        {
            var  phaseATS             = aTSPhases.FirstOrDefault(x => x.Number == phaseNumber);
            var  phaseATSQuestions    = aTSQuestions.Where(x => x.NOMEvaluationPhaseID == phaseATS.ID).ToList();
            var  phaseATSQuestionsIds = phaseATSQuestions.Select(_ => _.ID);
            var  phaseATSAnswers      = answers.Where(x => phaseATSQuestionsIds.Contains(x.NOMEvaluationQuestionID));
            bool needMoreValidation   = phaseNumber == 4 ? false:true;

            if (!phaseATSAnswers.Any())
            {
                throw new CotorraException(0111, "Eval", "La evaluacion no contiene preguntas de Fase " + phaseNumber, null);
            }
            var sumVal = phaseATSAnswers.Sum(x => x.Value);

            if (sumVal > validBoundary)
            {
                answeredSurvey.EvaluationState = EvaluationStateType.Answered;
                answeredSurvey.Result          = 1;
                needMoreValidation             = false;
            }
            return(survey : answeredSurvey, need : needMoreValidation);
        }
Esempio n. 8
0
        private (NOMSurveyReply survey, bool need) FirstPhaseEvaluation(NOMSurveyReply answeredSurvey, List <NOMAnswer> answers,
                                                                        List <NOMEvaluationQuestion> aTSQuestions,
                                                                        List <NOMEvaluationPhase> aTSPhases)
        {
            var  firstPhaseATS             = aTSPhases.FirstOrDefault(x => x.Number == 1);
            var  firstPhaseATSQuestions    = aTSQuestions.Where(x => x.NOMEvaluationPhaseID == firstPhaseATS.ID).ToList();
            var  firstPhaseATSQuestionsIds = firstPhaseATSQuestions.Select(_ => _.ID);
            var  firstPhaseATSAnswers      = answers.Where(x => firstPhaseATSQuestionsIds.Contains(x.NOMEvaluationQuestionID));
            bool needMoreValidation        = true;

            if (!firstPhaseATSAnswers.Any())
            {
                throw new CotorraException(0111, "Eval", "La evaluacion no contiene preguntas de Fase I", null);
            }
            var sumVal = firstPhaseATSAnswers.Sum(x => x.Value);

            if (sumVal == 0)
            {
                answeredSurvey.EvaluationState = EvaluationStateType.Answered;
                answeredSurvey.Result          = 0;
                needMoreValidation             = false;
            }
            return(survey : answeredSurvey, need : needMoreValidation);
        }
Esempio n. 9
0
        private async Task SetAnswers(NOMSurveyReply nOMSurveyReply)
        {
            List <NOMAnswer> answers = await GetAnswers(nOMSurveyReply.company, nOMSurveyReply.InstanceID, nOMSurveyReply.ID);

            nOMSurveyReply.NOMAnswer = answers;
        }
Esempio n. 10
0
        private void AssignPoints(List <NOMAnswer> answers, List <NOMEvaluationQuestion> aTSQuestions, Guid firstCategoryID, Guid secondCategoryID, Guid thirdCategoryID, Guid fourthCategoryID, Guid firstDomainID, Guid secondDomainID,
                                  Guid thirdDomainID, Guid fourthDomainID, Guid fifthDomainID, Guid sixthDomainID,
                                  Guid seventhDomainID, Guid eigthDomainID, NOMSurveyCategoryResult category1Result, NOMSurveyCategoryResult category2Result, NOMSurveyCategoryResult category3Result, NOMSurveyCategoryResult category4Result, NOMSurveyDomainResult domain1Result,
                                  NOMSurveyDomainResult domain2Result, NOMSurveyDomainResult domain3Result, NOMSurveyDomainResult domain4Result, NOMSurveyDomainResult domain5Result, NOMSurveyDomainResult domain6Result,
                                  NOMSurveyDomainResult domain7Result, NOMSurveyDomainResult domain8Result, NOMSurveyReply answeredSurvey)
        {
            var totalPoints     = 0;
            var category1Points = 0;
            var category2Points = 0;
            var category3Points = 0;
            var category4Points = 0;
            var domain1Points   = 0;
            var domain2Points   = 0;
            var domain3Points   = 0;
            var domain4Points   = 0;
            var domain5Points   = 0;
            var domain6Points   = 0;
            var domain7Points   = 0;
            var domain8Points   = 0;

            //answers.ForEach(answer =>
            Parallel.ForEach(answers, answer =>
            {
                var question       = aTSQuestions.FirstOrDefault(x => x.ID == answer.NOMEvaluationQuestionID);
                var questionPoints = GetPoints(question.Number, answer.Value);
                Interlocked.Add(ref totalPoints, questionPoints);
                if (question.NOMEvaluationCategoryID == firstCategoryID)
                {
                    Interlocked.Add(ref category1Points, questionPoints);
                }
                if (question.NOMEvaluationCategoryID == secondCategoryID)
                {
                    Interlocked.Add(ref category2Points, questionPoints);
                }
                if (question.NOMEvaluationCategoryID == thirdCategoryID)
                {
                    Interlocked.Add(ref category3Points, questionPoints);
                }
                if (question.NOMEvaluationCategoryID == fourthCategoryID)
                {
                    Interlocked.Add(ref category4Points, questionPoints);
                }
                if (question.NOMEvaluationDomainID == firstDomainID)
                {
                    Interlocked.Add(ref domain1Points, questionPoints);
                }
                if (question.NOMEvaluationDomainID == secondDomainID)
                {
                    Interlocked.Add(ref domain2Points, questionPoints);
                }
                if (question.NOMEvaluationDomainID == thirdDomainID)
                {
                    Interlocked.Add(ref domain3Points, questionPoints);
                }
                if (question.NOMEvaluationDomainID == fourthDomainID)
                {
                    Interlocked.Add(ref domain4Points, questionPoints);
                }
                if (question.NOMEvaluationDomainID == fifthDomainID)
                {
                    Interlocked.Add(ref domain5Points, questionPoints);
                }
                if (question.NOMEvaluationDomainID == sixthDomainID)
                {
                    Interlocked.Add(ref domain6Points, questionPoints);
                }
                if (question.NOMEvaluationDomainID == seventhDomainID)
                {
                    Interlocked.Add(ref domain7Points, questionPoints);
                }
                if (question.NOMEvaluationDomainID == eigthDomainID)
                {
                    Interlocked.Add(ref domain8Points, questionPoints);
                }
            });
            SetValuesForResults(firstCategoryID, secondCategoryID, thirdCategoryID, fourthCategoryID, firstDomainID, secondDomainID, thirdDomainID, fourthDomainID, fifthDomainID, sixthDomainID, seventhDomainID, eigthDomainID, category1Result, category2Result, category3Result, category4Result, domain1Result, domain2Result, domain3Result, domain4Result, domain5Result, domain6Result, domain7Result, domain8Result, category1Points, category2Points, category3Points, category4Points, domain1Points, domain2Points, domain3Points, domain4Points, domain5Points, domain6Points, domain7Points, domain8Points);

            answeredSurvey.Result = totalPoints;
        }