From 6dd867934ba1baaef59b3912f096882cb9ce47a7 Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Fri, 15 Nov 2024 14:20:21 +0100 Subject: [PATCH] refactor(api): replace enablePassageByAllCompetences parameter by value used in production --- .../scenario-simulator-controller.js | 2 - .../application/scenario-simulator-route.js | 1 - .../simulate-flash-assessment-scenario.js | 5 +- .../scenario-simulator-controller_test.js | 59 ------------------- ...simulate-flash-assessment-scenario_test.js | 9 --- 5 files changed, 3 insertions(+), 73 deletions(-) diff --git a/api/src/certification/flash-certification/application/scenario-simulator-controller.js b/api/src/certification/flash-certification/application/scenario-simulator-controller.js index 0804f182f16..efd008ed8d3 100644 --- a/api/src/certification/flash-certification/application/scenario-simulator-controller.js +++ b/api/src/certification/flash-certification/application/scenario-simulator-controller.js @@ -29,7 +29,6 @@ async function simulateFlashAssessmentScenario( challengesBetweenSameCompetence, limitToOneQuestionPerTube, minimumEstimatedSuccessRateRanges: minimumEstimatedSuccessRateRangesDto, - enablePassageByAllCompetences, doubleMeasuresUntil, variationPercent, variationPercentUntil, @@ -60,7 +59,6 @@ async function simulateFlashAssessmentScenario( challengesBetweenSameCompetence, limitToOneQuestionPerTube, minimumEstimatedSuccessRateRanges, - enablePassageByAllCompetences, doubleMeasuresUntil, variationPercent, variationPercentUntil, diff --git a/api/src/certification/flash-certification/application/scenario-simulator-route.js b/api/src/certification/flash-certification/application/scenario-simulator-route.js index dee25a79a74..4e830212a7d 100644 --- a/api/src/certification/flash-certification/application/scenario-simulator-route.js +++ b/api/src/certification/flash-certification/application/scenario-simulator-route.js @@ -17,7 +17,6 @@ const _baseScenarioParametersValidator = Joi.object().keys({ challengesBetweenSameCompetence: Joi.number().min(0), limitToOneQuestionPerTube: Joi.boolean(), minimumEstimatedSuccessRateRanges: Joi.array().items(_successRatesConfigurationValidator), - enablePassageByAllCompetences: Joi.boolean(), doubleMeasuresUntil: Joi.number().min(0), variationPercent: Joi.number().min(0).max(1), variationPercentUntil: Joi.number().min(0), diff --git a/api/src/certification/flash-certification/domain/usecases/simulate-flash-assessment-scenario.js b/api/src/certification/flash-certification/domain/usecases/simulate-flash-assessment-scenario.js index 310c755d715..1b23dacd5ff 100644 --- a/api/src/certification/flash-certification/domain/usecases/simulate-flash-assessment-scenario.js +++ b/api/src/certification/flash-certification/domain/usecases/simulate-flash-assessment-scenario.js @@ -13,7 +13,6 @@ export async function simulateFlashAssessmentScenario({ challengesBetweenSameCompetence = 0, limitToOneQuestionPerTube = true, minimumEstimatedSuccessRateRanges = [], - enablePassageByAllCompetences = false, doubleMeasuresUntil = 0, variationPercent, variationPercentUntil, @@ -22,12 +21,14 @@ export async function simulateFlashAssessmentScenario({ }) { const challenges = await challengeRepository.findActiveFlashCompatible({ locale }); + const enablePassageByAllCompetencesValueInProduction = true; + const flashAssessmentAlgorithm = new FlashAssessmentAlgorithm({ flashAlgorithmImplementation: flashAlgorithmService, configuration: new FlashAssessmentAlgorithmConfiguration({ limitToOneQuestionPerTube, minimumEstimatedSuccessRateRanges, - enablePassageByAllCompetences, + enablePassageByAllCompetences: enablePassageByAllCompetencesValueInProduction, variationPercent, variationPercentUntil, doubleMeasuresUntil, diff --git a/api/tests/certification/flash-certification/integration/application/scenario-simulator-controller_test.js b/api/tests/certification/flash-certification/integration/application/scenario-simulator-controller_test.js index c5683c51451..9d8c45c63dc 100644 --- a/api/tests/certification/flash-certification/integration/application/scenario-simulator-controller_test.js +++ b/api/tests/certification/flash-certification/integration/application/scenario-simulator-controller_test.js @@ -376,65 +376,6 @@ describe('Integration | Application | scenario-simulator-controller', function ( }); }); - context('When configuring the passage by all competences', function () { - it('should call simulateFlashAssessmentScenario usecase with correct arguments', async function () { - // given - const enablePassageByAllCompetences = true; - - const pickChallengeImplementation = sinon.stub(); - pickChallengeService.chooseNextChallenge.withArgs().returns(pickChallengeImplementation); - const pickAnswerStatusForCapacityImplementation = sinon.stub(); - pickAnswerStatusService.pickAnswerStatusForCapacity - .withArgs(6) - .returns(pickAnswerStatusForCapacityImplementation); - - usecases.simulateFlashAssessmentScenario - .withArgs({ - pickAnswerStatus: pickAnswerStatusForCapacityImplementation, - locale: 'en', - pickChallenge: pickChallengeImplementation, - initialCapacity, - enablePassageByAllCompetences, - }) - .resolves(simulationResults); - securityPreHandlers.checkAdminMemberHasRoleSuperAdmin.returns(() => true); - - // when - const response = await httpTestServer.request( - 'POST', - '/api/scenario-simulator', - { - initialCapacity, - capacity: 6, - enablePassageByAllCompetences, - }, - null, - { 'accept-language': 'en' }, - ); - - // then - expect(response.statusCode).to.equal(200); - const parsedResult = parseJsonStream(response); - expect(parsedResult).to.deep.equal([ - { - index: 0, - simulationReport: [ - { - challengeId: challenge1.id, - errorRate: errorRate1, - capacity: capacity1, - minimumCapability: 0.6190392084062237, - answerStatus: 'ok', - reward: reward1, - difficulty: challenge1.difficulty, - discriminant: challenge1.discriminant, - }, - ], - }, - ]); - }); - }); - context('When the scenario is capacity', function () { context('When the route is called with correct arguments', function () { context('When the route is called without an initial capacity', function () { diff --git a/api/tests/unit/domain/usecases/simulate-flash-assessment-scenario_test.js b/api/tests/unit/domain/usecases/simulate-flash-assessment-scenario_test.js index 20aa7d1dbfd..835a4efbd31 100644 --- a/api/tests/unit/domain/usecases/simulate-flash-assessment-scenario_test.js +++ b/api/tests/unit/domain/usecases/simulate-flash-assessment-scenario_test.js @@ -26,7 +26,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { pickChallenge, pickAnswerStatus, flashAlgorithmService, - enablePassageByAllCompetences: false, }); // then @@ -69,7 +68,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { initialCapacity, flashAlgorithmService, limitToOneQuestionPerTube: false, - enablePassageByAllCompetences: false, }); // then @@ -88,7 +86,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { it('should return an array of estimated level, challenge, reward and error rate for each answer', async function () { // given const limitToOneQuestionPerTube = false; - const enablePassageByAllCompetences = false; const { challengeRepository, @@ -136,7 +133,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { pickAnswerStatus, limitToOneQuestionPerTube, flashAlgorithmService, - enablePassageByAllCompetences, }); // then @@ -155,7 +151,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { it('should return an array of estimated level, challenge, reward and error rate for each answer', async function () { // given const limitToOneQuestionPerTube = false; - const enablePassageByAllCompetences = false; const minimumEstimatedSuccessRateRanges = [ domainBuilder.buildFlashAssessmentAlgorithmSuccessRateHandlerFixed({ startingChallengeIndex: 0, @@ -178,7 +173,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { minimumEstimatedSuccessRateRanges, flashAlgorithmService, limitToOneQuestionPerTube, - enablePassageByAllCompetences, }); // then @@ -208,7 +202,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { pickChallenge, pickAnswerStatus, flashAlgorithmService, - enablePassageByAllCompetences: false, doubleMeasuresUntil: 2, }); @@ -226,7 +219,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { it('should stop simulating', async function () { // given const limitToOneQuestionPerTube = false; - const enablePassageByAllCompetences = false; const challenge = domainBuilder.buildChallenge({ id: 1 }); const challengeRepository = { findActiveFlashCompatible: sinon.stub(), @@ -278,7 +270,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () { pickAnswerStatus, flashAlgorithmService, limitToOneQuestionPerTube, - enablePassageByAllCompetences, }); // then