Esempio n. 1
0
        GetRecommendedLearningForSelfAssessment_returns_correct_recommendation_score_for_resource_with_competency_role_requirements(
            int levelRag,
            decimal expectedScore
            )
        {
            // Given
            GivenResourceForSelfAssessmentIsReturnedByLearningHubApi();
            GivenGetLearningLogItemsReturnsAnItem();

            var questionParameters = Builder <CompetencyResourceAssessmentQuestionParameter>
                                     .CreateListOfSize(1).All()
                                     .With(qp => qp.Essential = true)
                                     .And(qp => qp.CompareToRoleRequirements = true).Build();

            A.CallTo(
                () => competencyLearningResourcesDataService.GetCompetencyResourceAssessmentQuestionParameters(
                    A <IEnumerable <int> > ._
                    )
                ).Returns(questionParameters);

            var roleRequirement = Builder <CompetencyAssessmentQuestionRoleRequirement> .CreateNew()
                                  .With(rr => rr.LevelRag = levelRag).Build();

            A.CallTo(
                () => selfAssessmentDataService.GetCompetencyAssessmentQuestionRoleRequirements(
                    CompetencyId,
                    SelfAssessmentId
                    )
                ).Returns(roleRequirement);

            var expectedResource = GetExpectedResource(true, false, LearningLogId, expectedScore);

            // When
            var result =
                (await recommendedLearningService.GetRecommendedLearningForSelfAssessment(SelfAssessmentId, DelegateId))
                .ToList();

            // Then
            result.Should().HaveCount(1);
            result.Single().Should().BeEquivalentTo(expectedResource);
            A.CallTo(
                () => selfAssessmentDataService.GetCompetencyAssessmentQuestionRoleRequirements(
                    CompetencyId,
                    SelfAssessmentId
                    )
                ).MustHaveHappenedOnceExactly();
        }
Esempio n. 2
0
        GetRecommendedLearningForSelfAssessment_returns_correct_recommendation_score_for_resource_with_competency_role_requirements(
            int levelRag,
            decimal expectedScore
            )
        {
            // Given
            const int confidenceResult = 5;

            GivenResourceForSelfAssessmentIsReturnedByLearningHubApi();
            GivenGetLearningLogItemsReturnsAnItem();
            GivenQuestionParametersAreReturned(true, true, 1, 10);
            GivenSelfAssessmentHasResultsForFirstCompetency(5, confidenceResult);

            var roleRequirement = Builder <CompetencyAssessmentQuestionRoleRequirement> .CreateNew()
                                  .With(rr => rr.LevelRag = levelRag).Build();

            A.CallTo(
                () => selfAssessmentDataService.GetCompetencyAssessmentQuestionRoleRequirements(
                    CompetencyId,
                    SelfAssessmentId,
                    CompetencyAssessmentQuestionId,
                    confidenceResult
                    )
                ).Returns(roleRequirement);

            var expectedResource = GetExpectedResource(true, false, LearningLogId, expectedScore);

            // When
            var result =
                (await recommendedLearningService.GetRecommendedLearningForSelfAssessment(SelfAssessmentId, DelegateId))
                .recommendedResources.ToList();

            // Then
            result.Should().HaveCount(1);
            result.Single().Should().BeEquivalentTo(expectedResource);
            A.CallTo(
                () => selfAssessmentDataService.GetCompetencyAssessmentQuestionRoleRequirements(
                    CompetencyId,
                    SelfAssessmentId,
                    CompetencyAssessmentQuestionId,
                    confidenceResult
                    )
                ).MustHaveHappenedOnceExactly();
        }
Esempio n. 3
0
        private decimal CalculateRoleRequirementValue(int competencyId, int selfAssessmentId)
        {
            var competencyAssessmentQuestionRoleRequirement =
                selfAssessmentDataService.GetCompetencyAssessmentQuestionRoleRequirements(
                    competencyId,
                    selfAssessmentId
                    );

            return((3 - competencyAssessmentQuestionRoleRequirement?.LevelRag) * 25 ?? 0);
        }
Esempio n. 4
0
        private decimal CalculateRoleRequirementValue(
            int competencyId,
            int selfAssessmentId,
            SelfAssessmentResult?latestConfidenceResult
            )
        {
            if (latestConfidenceResult == null)
            {
                return(0);
            }

            var competencyAssessmentQuestionRoleRequirement =
                selfAssessmentDataService.GetCompetencyAssessmentQuestionRoleRequirements(
                    competencyId,
                    selfAssessmentId,
                    latestConfidenceResult.AssessmentQuestionId,
                    latestConfidenceResult.Result
                    );

            return((3 - competencyAssessmentQuestionRoleRequirement?.LevelRag) * 25 ?? 0);
        }