From c3fbe777473ef4dc95499115e3b43de9af3a375b Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 28 Nov 2024 09:30:51 +0100 Subject: [PATCH 1/8] refactor(api): remove unused script --- .../generate-flash-algorithm-configuration.js | 48 ------------------- ...rate-flash-algorithm-configuration_test.js | 29 ----------- 2 files changed, 77 deletions(-) delete mode 100644 api/scripts/certification/next-gen/generate-flash-algorithm-configuration.js delete mode 100644 api/tests/integration/scripts/certification/next-gen/generate-flash-algorithm-configuration_test.js diff --git a/api/scripts/certification/next-gen/generate-flash-algorithm-configuration.js b/api/scripts/certification/next-gen/generate-flash-algorithm-configuration.js deleted file mode 100644 index 727662ee2e1..00000000000 --- a/api/scripts/certification/next-gen/generate-flash-algorithm-configuration.js +++ /dev/null @@ -1,48 +0,0 @@ -import * as url from 'node:url'; - -import { disconnect } from '../../../db/knex-database-connection.js'; -import * as flashAlgorithmConfigurationRepository from '../../../src/certification/flash-certification/infrastructure/repositories/flash-algorithm-configuration-repository.js'; -import { FlashAssessmentAlgorithmConfiguration } from '../../../src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js'; -import { logger } from '../../../src/shared/infrastructure/utils/logger.js'; - -const modulePath = url.fileURLToPath(import.meta.url); -const isLaunchedFromCommandLine = process.argv[1] === modulePath; -const __filename = modulePath; - -async function main() { - logger.info(`Script ${__filename} est lancé !`); - - const configurationData = { - warmUpLength: null, - forcedCompetences: [], - maximumAssessmentLength: 32, - challengesBetweenSameCompetence: null, - minimumEstimatedSuccessRateRanges: [], - limitToOneQuestionPerTube: true, - enablePassageByAllCompetences: true, - doubleMeasuresUntil: null, - variationPercent: 0.5, - variationPercentUntil: null, - }; - - const configuration = new FlashAssessmentAlgorithmConfiguration(configurationData); - - await flashAlgorithmConfigurationRepository.save(configuration); - - logger.info('La configuration a été créée.'); -} - -(async () => { - if (isLaunchedFromCommandLine) { - try { - await main(); - } catch (error) { - console.error(error); - process.exitCode = 1; - } finally { - await disconnect(); - } - } -})(); - -export { main }; diff --git a/api/tests/integration/scripts/certification/next-gen/generate-flash-algorithm-configuration_test.js b/api/tests/integration/scripts/certification/next-gen/generate-flash-algorithm-configuration_test.js deleted file mode 100644 index af04ff93fa8..00000000000 --- a/api/tests/integration/scripts/certification/next-gen/generate-flash-algorithm-configuration_test.js +++ /dev/null @@ -1,29 +0,0 @@ -import _ from 'lodash'; - -import { main } from '../../../../../scripts/certification/next-gen/generate-flash-algorithm-configuration.js'; -import { expect, knex } from '../../../../test-helper.js'; - -describe('Integration | Scripts | Certification | generate-flash-algorithm-configuration', function () { - const TABLE_NAME = 'flash-algorithm-configurations'; - - it('should create a flash algorithm configuration', async function () { - // when - await main(); - - // then - const expectedFlashAlgorithmConfiguration = { - warmUpLength: null, - forcedCompetences: [], - maximumAssessmentLength: 32, - challengesBetweenSameCompetence: null, - minimumEstimatedSuccessRateRanges: [], - limitToOneQuestionPerTube: true, - enablePassageByAllCompetences: true, - doubleMeasuresUntil: null, - variationPercent: 0.5, - variationPercentUntil: null, - }; - const flashAlgorithmConfiguration = await knex(TABLE_NAME).first(); - expect(_.omit(flashAlgorithmConfiguration, ['id', 'createdAt'])).to.deep.equal(expectedFlashAlgorithmConfiguration); - }); -}); From b248698e435bd7b64dbed56b154d7f8f6fdbbf24 Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 28 Nov 2024 09:31:25 +0100 Subject: [PATCH 2/8] refactor(api): remove doubleMeasuresUntil parameter from flash algorithm --- .../flash-algorithm-configuration/form.gjs | 10 - .../flash-algorithm-configuration/index.gjs | 1 - .../models/flash-algorithm-configuration.js | 1 - .../flash-algorithm-configuration_test.gjs | 5 - .../flash-algorithm-configuration-test.js | 2 - admin/translations/en.json | 1 - admin/translations/fr.json | 1 - .../build-flash-algorithm-configuration.js | 2 - .../data/team-certification/data-builder.js | 1 - .../flash-assessment-configuration-route.js | 1 - .../domain/models/FlashAssessmentAlgorithm.js | 2 - .../services/algorithm-methods/flash.js | 68 +- ...lash-algorithm-configuration-serializer.js | 1 - .../FlashAssessmentAlgorithmConfiguration.js | 6 - .../services/scoring/scoring-v3_test.js | 22 - .../usecases/get-next-challenge_test.js | 6 - ...algorithm-configuration-repository_test.js | 6 - .../services/algorithm-methods/flash_test.js | 1036 ++++++++--------- ...algorithm-configuration-serializer_test.js | 2 - .../scoring-degradation-service_test.js | 1 - ...algorithm-configuration-repository_test.js | 3 - .../models/FlashAssessmentAlgorithm_test.js | 1 - .../build-flash-algorithm-configuration.js | 2 - ...-challenge-for-campaign-assessment_test.js | 2 - 24 files changed, 487 insertions(+), 696 deletions(-) diff --git a/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs b/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs index 46b41586062..979e42c2208 100644 --- a/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs +++ b/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs @@ -56,16 +56,6 @@ import { t } from 'ember-intl'; }} - - <:label>{{t "pages.administration.certification.flash-algorithm-configuration.form.doubleMeasuresUntil"}} - - { challengesBetweenSameCompetence: Joi.number().integer().min(0).allow(null).optional(), limitToOneQuestionPerTube: Joi.boolean().optional(), enablePassageByAllCompetences: Joi.boolean().optional(), - doubleMeasuresUntil: Joi.number().min(0).allow(null).optional(), variationPercent: Joi.number().min(0).max(1).allow(null).optional(), variationPercentUntil: Joi.number().min(0).allow(null).optional(), }), diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js index 1af8f7a45fd..cfa1ee4a1c4 100644 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js +++ b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js @@ -113,7 +113,6 @@ class FlashAssessmentAlgorithm { capacity: initialCapacity, variationPercent: this._configuration.variationPercent, variationPercentUntil: this._configuration.variationPercentUntil, - doubleMeasuresUntil: this._configuration.doubleMeasuresUntil, }); } @@ -128,7 +127,6 @@ class FlashAssessmentAlgorithm { capacity: initialCapacity, variationPercent: this._configuration.variationPercent, variationPercentUntil: this._configuration.variationPercentUntil, - doubleMeasuresUntil: this._configuration.doubleMeasuresUntil, }); } diff --git a/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js b/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js index 8e01a8166f5..9583936eb39 100644 --- a/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js +++ b/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js @@ -47,7 +47,6 @@ function getCapacityAndErrorRate({ allAnswers, challenges, capacity = DEFAULT_CAPACITY, - doubleMeasuresUntil = 0, variationPercent, variationPercentUntil, }) { @@ -59,7 +58,6 @@ function getCapacityAndErrorRate({ allAnswers, challenges, capacity, - doubleMeasuresUntil, variationPercent, variationPercentUntil, }); @@ -71,7 +69,6 @@ function getCapacityAndErrorRateHistory({ allAnswers, challenges, capacity = DEFAULT_CAPACITY, - doubleMeasuresUntil = 0, variationPercent, variationPercentUntil, }) { @@ -92,31 +89,16 @@ function getCapacityAndErrorRateHistory({ answerIndex, ); - if (!_shouldUseDoubleMeasure({ doubleMeasuresUntil, answerIndex, answersLength: allAnswers.length })) { - ({ latestCapacity, likelihood, normalizedPosteriori } = _singleMeasure({ - challenges, - answer, - latestCapacity, - likelihood, - normalizedPosteriori, - variationPercent: variationPercentForCurrentAnswer, - })); - - answerIndex++; - } else { - answer = allAnswers[answerIndex]; - const answer2 = allAnswers[answerIndex + 1]; - ({ latestCapacity, likelihood, normalizedPosteriori } = _doubleMeasure({ - challenges, - answers: [answer, answer2], - latestCapacity, - likelihood, - normalizedPosteriori, - variationPercent: variationPercentForCurrentAnswer, - })); - - answerIndex += 2; - } + ({ latestCapacity, likelihood, normalizedPosteriori } = _singleMeasure({ + challenges, + answer, + latestCapacity, + likelihood, + normalizedPosteriori, + variationPercent: variationPercentForCurrentAnswer, + })); + + answerIndex++; capacityHistory.push({ answerId: answer.id, @@ -136,11 +118,6 @@ function _defineVariationPercentForCurrentAnswer(variationPercent, variationPerc return variationPercentUntil >= answerIndex ? variationPercent : undefined; } -function _shouldUseDoubleMeasure({ doubleMeasuresUntil, answerIndex, answersLength }) { - const isLastAnswer = answersLength === answerIndex + 1; - return doubleMeasuresUntil > answerIndex && !isLastAnswer; -} - function _singleMeasure({ challenges, answer, latestCapacity, likelihood, normalizedPosteriori, variationPercent }) { const answeredChallenge = _findChallengeForAnswer(challenges, answer); @@ -154,20 +131,6 @@ function _singleMeasure({ challenges, answer, latestCapacity, likelihood, normal return { latestCapacity, likelihood, normalizedPosteriori }; } -function _doubleMeasure({ challenges, answers, latestCapacity, likelihood, normalizedPosteriori, variationPercent }) { - const answeredChallenge1 = _findChallengeForAnswer(challenges, answers[0]); - const answeredChallenge2 = _findChallengeForAnswer(challenges, answers[1]); - - const normalizedPrior = _computeNormalizedPrior(latestCapacity); - - likelihood = _computeDoubleMeasureLikelihood([answeredChallenge1, answeredChallenge2], answers, likelihood); - - normalizedPosteriori = _computeNormalizedPosteriori(likelihood, normalizedPrior); - - latestCapacity = _computeCapacity(latestCapacity, variationPercent, normalizedPosteriori); - return { latestCapacity, likelihood, normalizedPosteriori }; -} - function _computeNormalizedPrior(gaussianMean) { return _normalizeDistribution( samples.map((sample) => @@ -186,17 +149,6 @@ function _computeLikelihood(answeredChallenge, answer, previousLikelihood) { return previousLikelihood[index] * probability; }); } - -function _computeDoubleMeasureLikelihood(answeredChallenges, answers, previousLikelihood) { - return samples.map((sample, index) => { - let probability1 = _getProbability(sample, answeredChallenges[0].discriminant, answeredChallenges[0].difficulty); - let probability2 = _getProbability(sample, answeredChallenges[1].discriminant, answeredChallenges[1].difficulty); - probability1 = answers[0].isOk() ? probability1 : 1 - probability1; - probability2 = answers[1].isOk() ? probability2 : 1 - probability2; - return (previousLikelihood[index] * (probability1 + probability2)) / 2; - }); -} - function _computeNormalizedPosteriori(likelihood, normalizedGaussian) { const posteriori = samples.map((_, index) => likelihood[index] * normalizedGaussian[index]); diff --git a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js index 022c971a7dd..b682bb26064 100644 --- a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js +++ b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js @@ -11,7 +11,6 @@ const serialize = function ({ flashAlgorithmConfiguration }) { 'minimumEstimatedSuccessRateRanges', 'limitToOneQuestionPerTube', 'enablePassageByAllCompetences', - 'doubleMeasuresUntil', 'variationPercent', 'variationPercentUntil', ]; diff --git a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js index bfb5194b577..26f9bee3ea0 100644 --- a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js +++ b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js @@ -9,7 +9,6 @@ import { FlashAssessmentSuccessRateHandler } from '../../../flash-certification/ * @param limitToOneQuestionPerTube - limits questions to one per tube * @param flashImplementation - the flash algorithm implementation * @param enablePassageByAllCompetences - enable or disable the passage through all competences - * @param doubleMeasuresUntil - use the double measure strategy for specified number of challenges * @param variationPercent - maximum variation of estimated level between two answers * @param variationPercentUntil - maximum variation of estimated level between two answers for a specified number of challenges */ @@ -22,7 +21,6 @@ export class FlashAssessmentAlgorithmConfiguration { minimumEstimatedSuccessRateRanges = [], limitToOneQuestionPerTube = false, enablePassageByAllCompetences = false, - doubleMeasuresUntil, variationPercent, variationPercentUntil, createdAt, @@ -34,7 +32,6 @@ export class FlashAssessmentAlgorithmConfiguration { this.minimumEstimatedSuccessRateRanges = minimumEstimatedSuccessRateRanges; this.limitToOneQuestionPerTube = limitToOneQuestionPerTube; this.enablePassageByAllCompetences = enablePassageByAllCompetences; - this.doubleMeasuresUntil = doubleMeasuresUntil; this.variationPercent = variationPercent; this.variationPercentUntil = variationPercentUntil; this.createdAt = createdAt; @@ -51,7 +48,6 @@ export class FlashAssessmentAlgorithmConfiguration { ), limitToOneQuestionPerTube: this.limitToOneQuestionPerTube, enablePassageByAllCompetences: this.enablePassageByAllCompetences, - doubleMeasuresUntil: this.doubleMeasuresUntil, variationPercent: this.variationPercent, variationPercentUntil: this.variationPercentUntil, createdAt: this.createdAt, @@ -66,7 +62,6 @@ export class FlashAssessmentAlgorithmConfiguration { minimumEstimatedSuccessRateRanges, limitToOneQuestionPerTube, enablePassageByAllCompetences, - doubleMeasuresUntil, variationPercent, variationPercentUntil, createdAt, @@ -81,7 +76,6 @@ export class FlashAssessmentAlgorithmConfiguration { : minimumEstimatedSuccessRateRanges, limitToOneQuestionPerTube, enablePassageByAllCompetences, - doubleMeasuresUntil, variationPercent, variationPercentUntil, createdAt, diff --git a/api/tests/certification/evaluation/unit/domain/services/scoring/scoring-v3_test.js b/api/tests/certification/evaluation/unit/domain/services/scoring/scoring-v3_test.js index 21290f6a002..3c831bd3d98 100644 --- a/api/tests/certification/evaluation/unit/domain/services/scoring/scoring-v3_test.js +++ b/api/tests/certification/evaluation/unit/domain/services/scoring/scoring-v3_test.js @@ -174,7 +174,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -187,7 +186,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -290,7 +288,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -304,7 +301,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -397,7 +393,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -410,7 +405,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -552,7 +546,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -565,7 +558,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -668,7 +660,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -681,7 +672,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -790,7 +780,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -803,7 +792,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -910,7 +898,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -923,7 +910,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -1035,7 +1021,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -1047,7 +1032,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -1159,7 +1143,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -1172,7 +1155,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -1282,7 +1264,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -1295,7 +1276,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { @@ -1400,7 +1380,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -1413,7 +1392,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct capacity: sinon.match.number, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns([ { diff --git a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js index b1b747a546d..db8a3265309 100644 --- a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js +++ b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js @@ -104,7 +104,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: 0 }); @@ -196,7 +195,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: 0 }); @@ -356,7 +354,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: 0 }); @@ -440,7 +437,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: 0 }); @@ -543,7 +539,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: 0 }); @@ -722,7 +717,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: configuration.variationPercent, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: 0 }); diff --git a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index a40ad47ecc7..78d94a134f4 100644 --- a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -11,7 +11,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, forcedCompetences: ['comp1', 'comp2'], minimumEstimatedSuccessRateRanges: [ { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, @@ -37,7 +36,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R enablePassageByAllCompetences: false, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, }); }); @@ -49,7 +47,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, minimumEstimatedSuccessRateRanges: [ { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, ], @@ -74,7 +71,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R enablePassageByAllCompetences: false, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, }); }); @@ -86,7 +82,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, forcedCompetences: ['comp1', 'comp2'], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, @@ -107,7 +102,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R enablePassageByAllCompetences: false, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, }); }); }); diff --git a/api/tests/certification/flash-certification/unit/domain/services/algorithm-methods/flash_test.js b/api/tests/certification/flash-certification/unit/domain/services/algorithm-methods/flash_test.js index 8967b492788..f6db2943e2d 100644 --- a/api/tests/certification/flash-certification/unit/domain/services/algorithm-methods/flash_test.js +++ b/api/tests/certification/flash-certification/unit/domain/services/algorithm-methods/flash_test.js @@ -91,290 +91,447 @@ describe('Integration | Domain | Algorithm-methods | Flash', function () { }); describe('#getCapacityAndErrorRate', function () { - context('when single measure', function () { - it('should return 0 when there is no answers', function () { - // given - const allAnswers = []; + it('should return 0 when there is no answers', function () { + // given + const allAnswers = []; - // when - const result = flash.getCapacityAndErrorRate({ allAnswers }); + // when + const result = flash.getCapacityAndErrorRate({ allAnswers }); - // then - expect(result).to.deep.equal({ - capacity: 0, - errorRate: 5, - }); + // then + expect(result).to.deep.equal({ + capacity: 0, + errorRate: 5, }); + }); - it('should return the correct capacity when there is one answer', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - ]; + it('should return the correct capacity when there is one answer', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), + ]; - const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id })]; + const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id })]; - // when - const { capacity, errorRate } = flash.getCapacityAndErrorRate({ allAnswers, challenges }); + // when + const { capacity, errorRate } = flash.getCapacityAndErrorRate({ allAnswers, challenges }); - // then - expect(capacity).to.be.closeTo(0.859419960298745, 0.00000000001); - expect(errorRate).to.be.closeTo(0.9327454634914153, 0.00000000001); - }); + // then + expect(capacity).to.be.closeTo(0.859419960298745, 0.00000000001); + expect(errorRate).to.be.closeTo(0.9327454634914153, 0.00000000001); + }); - it('should return the correct capacity when there is two answers', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - id: 'ChallengeFirstAnswers', - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - domainBuilder.buildChallenge({ - id: 'ChallengeSecondAnswers', - discriminant: 2.25422414740233, - difficulty: 0.823376599163319, - }), - ]; + it('should return the correct capacity when there is two answers', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + id: 'ChallengeFirstAnswers', + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), + domainBuilder.buildChallenge({ + id: 'ChallengeSecondAnswers', + discriminant: 2.25422414740233, + difficulty: 0.823376599163319, + }), + ]; - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - ]; + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), + ]; - // when - const { capacity, errorRate } = flash.getCapacityAndErrorRate({ allAnswers, challenges }); + // when + const { capacity, errorRate } = flash.getCapacityAndErrorRate({ allAnswers, challenges }); - // then - expect(capacity).to.be.closeTo(1.802340122865396, 0.00000000001); - expect(errorRate).to.be.closeTo(0.8549014053951466, 0.00000000001); - }); + // then + expect(capacity).to.be.closeTo(1.802340122865396, 0.00000000001); + expect(errorRate).to.be.closeTo(0.8549014053951466, 0.00000000001); + }); - it('should return the correct capacity when there is three answers', function () { - // given - const challenges = [ + it('should return the correct capacity when there is three answers', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + id: 'ChallengeFirstAnswers', + discriminant: 1.06665273005823, + difficulty: -0.030736508016524, + }), + domainBuilder.buildChallenge({ + id: 'ChallengeSecondAnswers', + discriminant: 1.50948587856458, + difficulty: 1.62670103354638, + }), + domainBuilder.buildChallenge({ + id: 'ChallengeThirdAnswers', + discriminant: 0.950709518595358, + difficulty: 1.90647729810166, + }), + ]; + + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), + ]; + + // when + const { capacity, errorRate } = flash.getCapacityAndErrorRate({ allAnswers, challenges }); + + // then + expect(capacity).to.be.closeTo(2.851063556136754, 0.00000000001); + expect(errorRate).to.be.closeTo(0.9271693210547304, 0.00000000001); + }); + + context('when the user answers a lot of challenges', function () { + it('should return the correct capacity and errorRate', function () { + const listSkills = { + url5: domainBuilder.buildSkill({ id: 'url5' }), + web3: domainBuilder.buildSkill({ id: 'web3' }), + sourceinfo5: domainBuilder.buildSkill({ id: 'sourceinfo5' }), + installogiciel2: domainBuilder.buildSkill({ id: 'installogiciel2' }), + fichier4: domainBuilder.buildSkill({ id: 'fichier4' }), + sauvegarde5: domainBuilder.buildSkill({ id: 'sauvegarde5' }), + langbalise6: domainBuilder.buildSkill({ id: 'langbalise6' }), + pratiquesinternet4: domainBuilder.buildSkill({ id: 'pratiquesinternet4' }), + langbalise7: domainBuilder.buildSkill({ id: 'langbalise7' }), + }; + + const listChallenges = [ domainBuilder.buildChallenge({ - id: 'ChallengeFirstAnswers', - discriminant: 1.06665273005823, + id: 'recA', + skill: listSkills.url5, + difficulty: -0.917927344545694, + discriminant: 1.02282430250024, + }), + domainBuilder.buildChallenge({ + id: 'recB', + skill: listSkills.web3, + difficulty: 0.301604780272093, + discriminant: 0.815896135600247, + }), + domainBuilder.buildChallenge({ + id: 'recC', + skill: listSkills.sourceinfo5, + difficulty: -1.69218011589622, + discriminant: 1.38594509996278, + }), + domainBuilder.buildChallenge({ + id: 'recD', + skill: listSkills.installogiciel2, + difficulty: -5.4464574841729, + discriminant: 0.427255285029657, + }), + domainBuilder.buildChallenge({ + id: 'recE', + skill: listSkills.fichier4, + difficulty: -1.5526216455839, + discriminant: 1.21015304225808, + }), + domainBuilder.buildChallenge({ + id: 'recF', + skill: listSkills.fichier4, + difficulty: -1.36561917255237, + discriminant: 1.09320650236677, + }), + domainBuilder.buildChallenge({ + id: 'recG', + skill: listSkills.fichier4, + difficulty: -4.20230915443229, + discriminant: 0.562929008226957, + }), + domainBuilder.buildChallenge({ + id: 'recH', + skill: listSkills.fichier4, + difficulty: 0.262904155422314, + discriminant: 0.901542609459213, + }), + domainBuilder.buildChallenge({ + id: 'recI', + skill: listSkills.fichier4, + difficulty: -0.754355900389256, + discriminant: 0.834990152043718, + }), + domainBuilder.buildChallenge({ + id: 'recJ', + skill: listSkills.sauvegarde5, + difficulty: 3.174339929941, + discriminant: 0.827526706077148, + }), + domainBuilder.buildChallenge({ + id: 'recK', + skill: listSkills.sauvegarde5, + difficulty: -1.16967416012961, + discriminant: 1.17433370794629, + }), + domainBuilder.buildChallenge({ + id: 'recL', + skill: listSkills.sauvegarde5, difficulty: -0.030736508016524, + discriminant: 1.06665273005823, }), domainBuilder.buildChallenge({ - id: 'ChallengeSecondAnswers', - discriminant: 1.50948587856458, + id: 'recM', + skill: listSkills.sauvegarde5, + difficulty: -2.37249657419562, + discriminant: 0.656224379307742, + }), + domainBuilder.buildChallenge({ + id: 'recN', + skill: listSkills.langbalise6, difficulty: 1.62670103354638, + discriminant: 1.50948587856458, }), domainBuilder.buildChallenge({ - id: 'ChallengeThirdAnswers', - discriminant: 0.950709518595358, + id: 'recO', + skill: listSkills.langbalise6, + difficulty: 2.811956480867, + discriminant: 1.04445171700575, + }), + domainBuilder.buildChallenge({ + id: 'recP', + skill: listSkills.langbalise6, + difficulty: 0.026713944730478, + discriminant: 0.703441785686095, + }), + domainBuilder.buildChallenge({ + id: 'recQ', + skill: listSkills.pratiquesinternet4, + difficulty: -1.83253533603, + discriminant: 0.711777117426424, + }), + domainBuilder.buildChallenge({ + id: 'recR', + skill: listSkills.pratiquesinternet4, + difficulty: 0.251708600387063, + discriminant: 0.369707224301943, + }), + domainBuilder.buildChallenge({ + id: 'recS', + skill: listSkills.pratiquesinternet4, difficulty: 1.90647729810166, + discriminant: 0.950709518595358, + }), + domainBuilder.buildChallenge({ + id: 'recT', + skill: listSkills.langbalise6, + difficulty: -1.82670103354638, + discriminant: 2.50948587856458, }), ]; - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), + const answers = [ + domainBuilder.buildAnswer({ challengeId: 'recL', result: AnswerStatus.KO }), + domainBuilder.buildAnswer({ challengeId: 'recC', result: AnswerStatus.OK }), + domainBuilder.buildAnswer({ challengeId: 'recT', result: AnswerStatus.KO }), + domainBuilder.buildAnswer({ challengeId: 'recE', result: AnswerStatus.OK }), + domainBuilder.buildAnswer({ challengeId: 'recA', result: AnswerStatus.OK }), + domainBuilder.buildAnswer({ challengeId: 'recQ', result: AnswerStatus.OK }), + ]; + const expectedCapacity = [ + 0, -0.6086049191210775, -0.6653800198379971, -1.7794873733366134, -1.8036203882448785, -1.557864373635504, + -1.3925555729766932, ]; - // when - const { capacity, errorRate } = flash.getCapacityAndErrorRate({ allAnswers, challenges }); + const expectedErrorRate = [ + 5, 1.0659524854635638, 0.9249688328247474, 0.6682031829777919, 0.6193894938423906, 0.5934694499356048, + 0.5880298028515323, + ]; - // then - expect(capacity).to.be.closeTo(2.851063556136754, 0.00000000001); - expect(errorRate).to.be.closeTo(0.9271693210547304, 0.00000000001); + const allAnswers = []; + let result; + + for (let i = 0; i < answers.length; i++) { + result = flash.getCapacityAndErrorRate({ challenges: listChallenges, allAnswers }); + + // then + expect(result.capacity).to.be.closeTo(expectedCapacity[i], 0.000000001); + expect(result.errorRate).to.be.closeTo(expectedErrorRate[i], 0.000000001); + + allAnswers.push(answers[i]); + } }); + }); - context('when the user answers a lot of challenges', function () { - it('should return the correct capacity and errorRate', function () { - const listSkills = { - url5: domainBuilder.buildSkill({ id: 'url5' }), - web3: domainBuilder.buildSkill({ id: 'web3' }), - sourceinfo5: domainBuilder.buildSkill({ id: 'sourceinfo5' }), - installogiciel2: domainBuilder.buildSkill({ id: 'installogiciel2' }), - fichier4: domainBuilder.buildSkill({ id: 'fichier4' }), - sauvegarde5: domainBuilder.buildSkill({ id: 'sauvegarde5' }), - langbalise6: domainBuilder.buildSkill({ id: 'langbalise6' }), - pratiquesinternet4: domainBuilder.buildSkill({ id: 'pratiquesinternet4' }), - langbalise7: domainBuilder.buildSkill({ id: 'langbalise7' }), - }; - - const listChallenges = [ - domainBuilder.buildChallenge({ - id: 'recA', - skill: listSkills.url5, - difficulty: -0.917927344545694, - discriminant: 1.02282430250024, - }), - domainBuilder.buildChallenge({ - id: 'recB', - skill: listSkills.web3, - difficulty: 0.301604780272093, - discriminant: 0.815896135600247, - }), - domainBuilder.buildChallenge({ - id: 'recC', - skill: listSkills.sourceinfo5, - difficulty: -1.69218011589622, - discriminant: 1.38594509996278, - }), - domainBuilder.buildChallenge({ - id: 'recD', - skill: listSkills.installogiciel2, - difficulty: -5.4464574841729, - discriminant: 0.427255285029657, - }), - domainBuilder.buildChallenge({ - id: 'recE', - skill: listSkills.fichier4, - difficulty: -1.5526216455839, - discriminant: 1.21015304225808, - }), - domainBuilder.buildChallenge({ - id: 'recF', - skill: listSkills.fichier4, - difficulty: -1.36561917255237, - discriminant: 1.09320650236677, - }), - domainBuilder.buildChallenge({ - id: 'recG', - skill: listSkills.fichier4, - difficulty: -4.20230915443229, - discriminant: 0.562929008226957, - }), - domainBuilder.buildChallenge({ - id: 'recH', - skill: listSkills.fichier4, - difficulty: 0.262904155422314, - discriminant: 0.901542609459213, - }), - domainBuilder.buildChallenge({ - id: 'recI', - skill: listSkills.fichier4, - difficulty: -0.754355900389256, - discriminant: 0.834990152043718, - }), - domainBuilder.buildChallenge({ - id: 'recJ', - skill: listSkills.sauvegarde5, - difficulty: 3.174339929941, - discriminant: 0.827526706077148, - }), - domainBuilder.buildChallenge({ - id: 'recK', - skill: listSkills.sauvegarde5, - difficulty: -1.16967416012961, - discriminant: 1.17433370794629, - }), - domainBuilder.buildChallenge({ - id: 'recL', - skill: listSkills.sauvegarde5, - difficulty: -0.030736508016524, - discriminant: 1.06665273005823, - }), - domainBuilder.buildChallenge({ - id: 'recM', - skill: listSkills.sauvegarde5, - difficulty: -2.37249657419562, - discriminant: 0.656224379307742, - }), - domainBuilder.buildChallenge({ - id: 'recN', - skill: listSkills.langbalise6, - difficulty: 1.62670103354638, - discriminant: 1.50948587856458, - }), - domainBuilder.buildChallenge({ - id: 'recO', - skill: listSkills.langbalise6, - difficulty: 2.811956480867, - discriminant: 1.04445171700575, - }), - domainBuilder.buildChallenge({ - id: 'recP', - skill: listSkills.langbalise6, - difficulty: 0.026713944730478, - discriminant: 0.703441785686095, - }), - domainBuilder.buildChallenge({ - id: 'recQ', - skill: listSkills.pratiquesinternet4, - difficulty: -1.83253533603, - discriminant: 0.711777117426424, - }), - domainBuilder.buildChallenge({ - id: 'recR', - skill: listSkills.pratiquesinternet4, - difficulty: 0.251708600387063, - discriminant: 0.369707224301943, - }), - domainBuilder.buildChallenge({ - id: 'recS', - skill: listSkills.pratiquesinternet4, - difficulty: 1.90647729810166, - discriminant: 0.950709518595358, - }), + context('when limiting the estimated level variation to a given number of challenges', function () { + context('when giving a right answer', function () { + it('should return the limited capacity for the correct number of challenges', function () { + // given + const challenges = [ domainBuilder.buildChallenge({ - id: 'recT', - skill: listSkills.langbalise6, - difficulty: -1.82670103354638, - discriminant: 2.50948587856458, + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, }), ]; - const answers = [ - domainBuilder.buildAnswer({ challengeId: 'recL', result: AnswerStatus.KO }), - domainBuilder.buildAnswer({ challengeId: 'recC', result: AnswerStatus.OK }), - domainBuilder.buildAnswer({ challengeId: 'recT', result: AnswerStatus.KO }), - domainBuilder.buildAnswer({ challengeId: 'recE', result: AnswerStatus.OK }), - domainBuilder.buildAnswer({ challengeId: 'recA', result: AnswerStatus.OK }), - domainBuilder.buildAnswer({ challengeId: 'recQ', result: AnswerStatus.OK }), - ]; - const expectedCapacity = [ - 0, -0.6086049191210775, -0.6653800198379971, -1.7794873733366134, -1.8036203882448785, -1.557864373635504, - -1.3925555729766932, - ]; + const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id })]; + + const variationPercent = 0.5; + const variationPercentUntil = 1; - const expectedErrorRate = [ - 5, 1.0659524854635638, 0.9249688328247474, 0.6682031829777919, 0.6193894938423906, 0.5934694499356048, - 0.5880298028515323, + // when + const { capacity } = flash.getCapacityAndErrorRate({ + allAnswers, + challenges, + variationPercent, + variationPercentUntil, + }); + + // then + expect(capacity).to.be.closeTo(0.5, 0.00000000001); + }); + }); + + context('when giving a wrong answer', function () { + it('should return the limited capacity', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), ]; - const allAnswers = []; - let result; + const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id })]; - for (let i = 0; i < answers.length; i++) { - result = flash.getCapacityAndErrorRate({ challenges: listChallenges, allAnswers }); + const variationPercent = 0.5; + const variationPercentUntil = 1; - // then - expect(result.capacity).to.be.closeTo(expectedCapacity[i], 0.000000001); - expect(result.errorRate).to.be.closeTo(expectedErrorRate[i], 0.000000001); + // when + const { capacity } = flash.getCapacityAndErrorRate({ + allAnswers, + challenges, + variationPercent, + variationPercentUntil, + }); - allAnswers.push(answers[i]); - } + // then + expect(capacity).to.be.closeTo(-0.5, 0.00000000001); }); }); + }); + }); + + describe('#getCapacityAndErrorRateHistory', function () { + it('should return 0 when there is no answers', function () { + // given + const allAnswers = []; + + // when + const result = flash.getCapacityAndErrorRateHistory({ allAnswers }); + + // then + expect(result).to.deep.equal([]); + }); + + it('should return the correct capacity when there is one answer', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), + ]; + + const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id })]; + + // when + const [{ capacity, errorRate }] = flash.getCapacityAndErrorRateHistory({ allAnswers, challenges }); + + // then + expect(capacity).to.be.closeTo(0.859419960298745, 0.00000000001); + expect(errorRate).to.be.closeTo(0.9327454634914153, 0.00000000001); + }); + + it('should return the correct capacity when there are two answers', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + id: 'ChallengeFirstAnswers', + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), + domainBuilder.buildChallenge({ + id: 'ChallengeSecondAnswers', + discriminant: 2.25422414740233, + difficulty: 0.823376599163319, + }), + ]; + + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), + ]; + + // when + const results = flash.getCapacityAndErrorRateHistory({ allAnswers, challenges }); + + // then + expect(results[0].capacity).to.be.closeTo(0.859419960298745, 0.00000000001); + expect(results[0].errorRate).to.be.closeTo(0.9327454634914153, 0.00000000001); + expect(results[1].capacity).to.be.closeTo(1.802340122865396, 0.00000000001); + expect(results[1].errorRate).to.be.closeTo(0.8549014053951466, 0.00000000001); + }); + + it('should return the answer id when there is at least one answer', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + id: 'ChallengeFirstAnswer', + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), + ]; + + const answerId = 1969; + + const allAnswers = [ + domainBuilder.buildAnswer({ id: answerId, result: AnswerStatus.OK, challengeId: challenges[0].id }), + ]; + + // when + const results = flash.getCapacityAndErrorRateHistory({ allAnswers, challenges }); + + // then + expect(results[0].answerId).to.equal(answerId); + }); - context('when limiting the estimated level variation to a given number of challenges', function () { - context('when giving a right answer', function () { - it('should return the limited capacity for the correct number of challenges', function () { + describe('when limiting the capacity variation', function () { + describe('when limiting to a given number of challenges', function () { + describe('when giving right answers', function () { + it('should return the limited capacities for the correct number of challenges', function () { // given const challenges = [ domainBuilder.buildChallenge({ discriminant: 1.86350005965093, difficulty: 0.194712138508747, }), + + domainBuilder.buildChallenge({ + discriminant: 2.056, + difficulty: 0.6973893, + }), + + domainBuilder.buildChallenge({ + discriminant: 2.5689203, + difficulty: 1.36973893, + }), ]; - const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id })]; + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), + ]; const variationPercent = 0.5; const variationPercentUntil = 1; // when - const { capacity } = flash.getCapacityAndErrorRate({ + const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ allAnswers, challenges, variationPercent, @@ -382,27 +539,42 @@ describe('Integration | Domain | Algorithm-methods | Flash', function () { }); // then - expect(capacity).to.be.closeTo(0.5, 0.00000000001); + const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); + expect(capacities).to.deep.equal([0.5, 0.75, 1.7005749291039245]); }); }); - context('when giving a wrong answer', function () { - it('should return the limited capacity', function () { + describe('when giving wrong answers', function () { + it('should return the limited capacities for the correct number of challenges', function () { // given const challenges = [ domainBuilder.buildChallenge({ discriminant: 1.86350005965093, difficulty: 0.194712138508747, }), + + domainBuilder.buildChallenge({ + discriminant: 2.056, + difficulty: 0.6973893, + }), + + domainBuilder.buildChallenge({ + discriminant: 2.5689203, + difficulty: 1.36973893, + }), ]; - const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id })]; + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[1].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[2].id }), + ]; const variationPercent = 0.5; const variationPercentUntil = 1; // when - const { capacity } = flash.getCapacityAndErrorRate({ + const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ allAnswers, challenges, variationPercent, @@ -410,350 +582,96 @@ describe('Integration | Domain | Algorithm-methods | Flash', function () { }); // then - expect(capacity).to.be.closeTo(-0.5, 0.00000000001); + const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); + expect(capacities).to.deep.equal([-0.5, -0.75, -1.5100020666768261]); }); }); }); - }); - context('when double measure', function () { - it('should return the correct capacity when there is three answers', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - id: 'ChallengeFirstAnswers', - discriminant: 1.06665273005823, - difficulty: -0.03, - }), - domainBuilder.buildChallenge({ - id: 'ChallengeSecondAnswers', - discriminant: 1.06665273005823, - difficulty: -0.06, - }), - domainBuilder.buildChallenge({ - id: 'ChallengeThirdAnswers', - discriminant: 0.950709518595358, - difficulty: 1.90647729810166, - }), - ]; + describe('when not limiting to a number of challenges', function () { + describe('when giving right answers', function () { + it('should return the unlimited capacities for all challenges', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), - ]; + domainBuilder.buildChallenge({ + discriminant: 2.056, + difficulty: 0.6973893, + }), - // when - const { capacity } = flash.getCapacityAndErrorRate({ - allAnswers, - challenges, - doubleMeasuresUntil: 2, - }); + domainBuilder.buildChallenge({ + discriminant: 2.5689203, + difficulty: 1.36973893, + }), + ]; - // then - expect(capacity).to.be.closeTo(1.663469355503838, 0.00000000001); - }); + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), + ]; - context('when double measure is active with an odd number of challenges', function () { - it('should return the correct capacity when there is three answers', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - id: 'ChallengeFirstAnswers', - discriminant: 1.06665273005823, - difficulty: -0.03, - }), - domainBuilder.buildChallenge({ - id: 'ChallengeSecondAnswers', - discriminant: 1.06665273005823, - difficulty: -0.06, - }), - domainBuilder.buildChallenge({ - id: 'ChallengeThirdAnswers', - discriminant: 0.950709518595358, - difficulty: 1.90647729810166, - }), - ]; + const variationPercent = 0.5; + const variationPercentUntil = null; - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), - ]; + // when + const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ + allAnswers, + challenges, + variationPercent, + variationPercentUntil, + }); - // when - const { capacity } = flash.getCapacityAndErrorRate({ - allAnswers, - challenges, - doubleMeasuresUntil: 4, + // then + const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); + expect(capacities).to.deep.equal([0.5, 0.75, 1.125]); }); - - // then - expect(capacity).to.be.closeTo(1.663469355503838, 0.00000000001); }); - }); - }); - }); - - describe('#getCapacityAndErrorRateHistory', function () { - context('when single measure', function () { - it('should return 0 when there is no answers', function () { - // given - const allAnswers = []; - - // when - const result = flash.getCapacityAndErrorRateHistory({ allAnswers }); - - // then - expect(result).to.deep.equal([]); - }); - - it('should return the correct capacity when there is one answer', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - ]; - - const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id })]; - // when - const [{ capacity, errorRate }] = flash.getCapacityAndErrorRateHistory({ allAnswers, challenges }); - - // then - expect(capacity).to.be.closeTo(0.859419960298745, 0.00000000001); - expect(errorRate).to.be.closeTo(0.9327454634914153, 0.00000000001); - }); - - it('should return the correct capacity when there are two answers', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - id: 'ChallengeFirstAnswers', - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - domainBuilder.buildChallenge({ - id: 'ChallengeSecondAnswers', - discriminant: 2.25422414740233, - difficulty: 0.823376599163319, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - ]; - - // when - const results = flash.getCapacityAndErrorRateHistory({ allAnswers, challenges }); - - // then - expect(results[0].capacity).to.be.closeTo(0.859419960298745, 0.00000000001); - expect(results[0].errorRate).to.be.closeTo(0.9327454634914153, 0.00000000001); - expect(results[1].capacity).to.be.closeTo(1.802340122865396, 0.00000000001); - expect(results[1].errorRate).to.be.closeTo(0.8549014053951466, 0.00000000001); - }); - - it('should return the answer id when there is at least one answer', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - id: 'ChallengeFirstAnswer', - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - ]; - - const answerId = 1969; - - const allAnswers = [ - domainBuilder.buildAnswer({ id: answerId, result: AnswerStatus.OK, challengeId: challenges[0].id }), - ]; + describe('when giving wrong answers', function () { + it('should return the unlimited capacities for all challenges', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), - // when - const results = flash.getCapacityAndErrorRateHistory({ allAnswers, challenges }); + domainBuilder.buildChallenge({ + discriminant: 2.056, + difficulty: 0.6973893, + }), - // then - expect(results[0].answerId).to.equal(answerId); - }); + domainBuilder.buildChallenge({ + discriminant: 2.5689203, + difficulty: 1.36973893, + }), + ]; - describe('when limiting the capacity variation', function () { - describe('when limiting to a given number of challenges', function () { - describe('when giving right answers', function () { - it('should return the limited capacities for the correct number of challenges', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.056, - difficulty: 0.6973893, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.5689203, - difficulty: 1.36973893, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), - ]; - - const variationPercent = 0.5; - const variationPercentUntil = 1; - - // when - const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - variationPercent, - variationPercentUntil, - }); - - // then - const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); - expect(capacities).to.deep.equal([0.5, 0.75, 1.7005749291039245]); - }); - }); + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[1].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[2].id }), + ]; - describe('when giving wrong answers', function () { - it('should return the limited capacities for the correct number of challenges', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.056, - difficulty: 0.6973893, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.5689203, - difficulty: 1.36973893, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[2].id }), - ]; - - const variationPercent = 0.5; - const variationPercentUntil = 1; - - // when - const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - variationPercent, - variationPercentUntil, - }); - - // then - const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); - expect(capacities).to.deep.equal([-0.5, -0.75, -1.5100020666768261]); - }); - }); - }); + const variationPercent = 0.5; + const variationPercentUntil = null; - describe('when not limiting to a number of challenges', function () { - describe('when giving right answers', function () { - it('should return the unlimited capacities for all challenges', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.056, - difficulty: 0.6973893, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.5689203, - difficulty: 1.36973893, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), - ]; - - const variationPercent = 0.5; - const variationPercentUntil = null; - - // when - const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - variationPercent, - variationPercentUntil, - }); - - // then - const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); - expect(capacities).to.deep.equal([0.5, 0.75, 1.125]); + // when + const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ + allAnswers, + challenges, + variationPercent, + variationPercentUntil, }); - }); - describe('when giving wrong answers', function () { - it('should return the unlimited capacities for all challenges', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.056, - difficulty: 0.6973893, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.5689203, - difficulty: 1.36973893, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[2].id }), - ]; - - const variationPercent = 0.5; - const variationPercentUntil = null; - - // when - const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - variationPercent, - variationPercentUntil, - }); - - // then - const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); - expect(capacities).to.deep.equal([-0.5, -0.75, -1.125]); - }); + // then + const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); + expect(capacities).to.deep.equal([-0.5, -0.75, -1.125]); }); }); }); diff --git a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js index 3dde211dca9..c6e3a637d94 100644 --- a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js +++ b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js @@ -15,7 +15,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori 'forced-competences': 2, 'maximum-assessment-length': 3, 'challenges-between-same-competence': 4, - 'double-measures-until': 5, 'variation-percent': 6, 'variation-percent-until': 7, 'minimum-estimated-success-rate-ranges': [], @@ -30,7 +29,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori forcedCompetences: 2, maximumAssessmentLength: 3, challengesBetweenSameCompetence: 4, - doubleMeasuresUntil: 5, variationPercent: 6, variationPercentUntil: 7, minimumEstimatedSuccessRateRanges: [], diff --git a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js index 9238ea5946f..80e1e74a90b 100644 --- a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js +++ b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js @@ -16,7 +16,6 @@ describe('Integration | Domain | services | scoringDegradationService', function minimumEstimatedSuccessRateRanges: [], limitToOneQuestionPerTube: false, enablePassageByAllCompetences: false, - doubleMeasuresUntil: null, variationPercent: null, variationPercentUntil: null, createdAt: new Date('2020-01-01T00:00:00Z'), diff --git a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index 8a048071d8b..f41068b5e18 100644 --- a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -16,7 +16,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, forcedCompetences: ['comp1', 'comp2'], minimumEstimatedSuccessRateRanges: [ { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, @@ -50,7 +49,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, forcedCompetences: ['comp1', 'comp2'], minimumEstimatedSuccessRateRanges: [ { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, @@ -66,7 +64,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - doubleMeasuresUntil: 5, forcedCompetences: ['comp1', 'comp2'], minimumEstimatedSuccessRateRanges: [ { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, diff --git a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js index 6e86211ddeb..75945935f9d 100644 --- a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js +++ b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js @@ -332,6 +332,5 @@ const _getAlgorithmConfig = (options) => { const _getCapacityAndErrorRateParams = (params) => ({ variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, ...params, }); diff --git a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js index caef8f0c00e..5285f11521d 100644 --- a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js +++ b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js @@ -9,7 +9,6 @@ export const buildFlashAlgorithmConfiguration = ({ minimumEstimatedSuccessRateRanges = [], limitToOneQuestionPerTube, enablePassageByAllCompetences, - doubleMeasuresUntil, variationPercent, variationPercentUntil, createdAt, @@ -24,7 +23,6 @@ export const buildFlashAlgorithmConfiguration = ({ ), limitToOneQuestionPerTube, enablePassageByAllCompetences, - doubleMeasuresUntil, variationPercent, variationPercentUntil, createdAt, diff --git a/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js b/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js index 20fb6d355af..2073fad09bb 100644 --- a/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js +++ b/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js @@ -153,7 +153,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge-for-campaign-assessment capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, variationPercentUntil: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: 0, @@ -265,7 +264,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge-for-campaign-assessment allAnswers, capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, - doubleMeasuresUntil: undefined, }) .returns({ capacity: 0, From 312d7559e7c0d1ef306cde60073e24e58abee711 Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 28 Nov 2024 10:47:31 +0100 Subject: [PATCH 3/8] refactor(api): remove warmUpLength parameter from flash algorithm --- .../flash-algorithm-configuration/form.gjs | 4 ---- .../flash-algorithm-configuration/index.gjs | 1 - .../models/flash-algorithm-configuration.js | 1 - .../flash-algorithm-configuration_test.gjs | 5 ----- .../flash-algorithm-configuration-test.js | 2 +- .../flash-algorithm-configuration-test.js | 2 -- admin/translations/en.json | 3 +-- admin/translations/fr.json | 3 +-- .../build-flash-algorithm-configuration.js | 2 -- .../data/team-certification/data-builder.js | 1 - ...-next-challenge-for-campaign-assessment.js | 1 - .../flash-assessment-configuration-route.js | 1 - .../domain/models/FlashAssessmentAlgorithm.js | 2 -- ...ssessmentAlgorithmForcedCompetencesRule.js | 14 ++++-------- ...entAlgorithmPassageByAllCompetencesRule.js | 14 ++++-------- ...lash-algorithm-configuration-serializer.js | 1 - .../FlashAssessmentAlgorithmConfiguration.js | 5 ----- ...ash-assessment-configuration-route_test.js | 6 ++--- ...ssessment-configuration-controller_test.js | 6 ++--- ...algorithm-configuration-repository_test.js | 6 ----- ...mentAlgorithmForcedCompetencesRule_test.js | 22 ++----------------- ...gorithmPassageByAllCompetencesRule_test.js | 18 +-------------- ...ive-flash-assessment-configuration_test.js | 4 ++-- ...algorithm-configuration-serializer_test.js | 2 -- .../scoring-degradation-service_test.js | 1 - ...algorithm-configuration-repository_test.js | 3 --- .../models/FlashAssessmentAlgorithm_test.js | 1 - .../build-flash-algorithm-configuration.js | 2 -- 28 files changed, 22 insertions(+), 111 deletions(-) diff --git a/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs b/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs index 979e42c2208..bd64ae4cba1 100644 --- a/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs +++ b/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs @@ -18,10 +18,6 @@ import { t } from 'ember-intl'; }} - - <:label>{{t "pages.administration.certification.flash-algorithm-configuration.form.warmUpLength"}} - - { test('should call the post url with the correct payload', async function (assert) { // given - const flashAlgorithmConfiguration = { warmUpLength: 2 }; + const flashAlgorithmConfiguration = { enablePassageByAllCompetences: true }; const payload = { data: flashAlgorithmConfiguration }; const adapter = this.owner.lookup('adapter:flash-algorithm-configuration'); sinon.stub(adapter, 'ajax'); diff --git a/admin/tests/unit/components/administration/certification/flash-algorithm-configuration-test.js b/admin/tests/unit/components/administration/certification/flash-algorithm-configuration-test.js index 2c2155cc507..39ab9829c32 100644 --- a/admin/tests/unit/components/administration/certification/flash-algorithm-configuration-test.js +++ b/admin/tests/unit/components/administration/certification/flash-algorithm-configuration-test.js @@ -28,7 +28,6 @@ module('Unit | Component | authenticated/certifications/flash-algorithm-configur const flashAlgorithmConfiguration = { maximumAssessmentLength: 0, - warmUpLength: 1, challengesBetweenSameCompetence: 2, variationPercent: 3, variationPercentUntil: 4, @@ -71,7 +70,6 @@ module('Unit | Component | authenticated/certifications/flash-algorithm-configur const flashAlgorithmConfiguration = { maximumAssessmentLength: 0, - warmUpLength: 1, challengesBetweenSameCompetence: 2, variationPercent: 3, variationPercentUntil: 4, diff --git a/admin/translations/en.json b/admin/translations/en.json index ddd5fd58e12..10a9aaec7ce 100644 --- a/admin/translations/en.json +++ b/admin/translations/en.json @@ -406,8 +406,7 @@ "limitToOneQuestionPerTube": "Limiter à une question par sujet", "maximumAssessmentLength": "Nombre de questions", "variationPercent": "Capage de la capacité (en % )", - "variationPercentUntil": "Nombre de questions pour le capage de la capacité", - "warmUpLength": "Nombre de questions d'entraînement" + "variationPercentUntil": "Nombre de questions pour le capage de la capacité" } }, "sco-whitelist": { diff --git a/admin/translations/fr.json b/admin/translations/fr.json index 4e17643a6e7..19d3c052664 100644 --- a/admin/translations/fr.json +++ b/admin/translations/fr.json @@ -416,8 +416,7 @@ "limitToOneQuestionPerTube": "Limiter à une question par sujet", "maximumAssessmentLength": "Nombre de questions", "variationPercent": "Capage de la capacité (en % )", - "variationPercentUntil": "Nombre de questions pour le capage de la capacité", - "warmUpLength": "Nombre de questions d'entraînement" + "variationPercentUntil": "Nombre de questions pour le capage de la capacité" } }, "sco-whitelist": { diff --git a/api/db/database-builder/factory/build-flash-algorithm-configuration.js b/api/db/database-builder/factory/build-flash-algorithm-configuration.js index be6d30661c7..bd7d2728db6 100644 --- a/api/db/database-builder/factory/build-flash-algorithm-configuration.js +++ b/api/db/database-builder/factory/build-flash-algorithm-configuration.js @@ -2,7 +2,6 @@ import { config } from '../../../src/shared/config.js'; import { databaseBuffer } from '../database-buffer.js'; const buildFlashAlgorithmConfiguration = function ({ - warmUpLength = null, forcedCompetences = [], maximumAssessmentLength = config.v3Certification.numberOfChallengesPerCourse, challengesBetweenSameCompetence = null, @@ -14,7 +13,6 @@ const buildFlashAlgorithmConfiguration = function ({ createdAt = new Date(), } = {}) { const values = { - warmUpLength, maximumAssessmentLength, challengesBetweenSameCompetence, forcedCompetences: JSON.stringify(forcedCompetences), diff --git a/api/db/seeds/data/team-certification/data-builder.js b/api/db/seeds/data/team-certification/data-builder.js index 95022bb5d68..3a4f169edfa 100644 --- a/api/db/seeds/data/team-certification/data-builder.js +++ b/api/db/seeds/data/team-certification/data-builder.js @@ -118,7 +118,6 @@ async function _createScoCertificationCenter({ databaseBuilder }) { function _createV3CertificationConfiguration({ databaseBuilder }) { databaseBuilder.factory.buildFlashAlgorithmConfiguration({ - warmUpLength: null, forcedCompetences: [], maximumAssessmentLength: 32, challengesBetweenSameCompetence: null, diff --git a/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js b/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js index d38106bedf1..51f7f449027 100644 --- a/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js +++ b/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js @@ -65,7 +65,6 @@ const _hasAnsweredToAllChallenges = ({ possibleChallenges }) => { const _createDefaultAlgorithmConfiguration = () => { return new FlashAssessmentAlgorithmConfiguration({ - warmUpLength: 0, forcedCompetences: [], limitToOneQuestionPerTube: false, minimumEstimatedSuccessRateRanges: [], diff --git a/api/src/certification/flash-certification/application/flash-assessment-configuration-route.js b/api/src/certification/flash-certification/application/flash-assessment-configuration-route.js index c8a5509521e..3ffdbeee803 100644 --- a/api/src/certification/flash-certification/application/flash-assessment-configuration-route.js +++ b/api/src/certification/flash-certification/application/flash-assessment-configuration-route.js @@ -35,7 +35,6 @@ const register = async (server) => { ], validate: { payload: Joi.object({ - warmUpLength: Joi.number().integer().min(0).allow(null).optional(), forcedCompetences: Joi.array().items(Joi.string()).optional(), maximumAssessmentLength: Joi.number().integer().min(0).allow(null).optional(), challengesBetweenSameCompetence: Joi.number().integer().min(0).allow(null).optional(), diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js index cfa1ee4a1c4..346f67c7ac0 100644 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js +++ b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js @@ -17,7 +17,6 @@ const availableRules = [ class FlashAssessmentAlgorithm { /** * Model to interact with the flash algorithm - * @param warmUpLength - define a warmup when the algorithm do not go through the competences * @param configuration - options to configure algorithm challenge selection and behaviour */ constructor({ flashAlgorithmImplementation, configuration = {} } = {}) { @@ -28,7 +27,6 @@ class FlashAssessmentAlgorithm { limitToOneQuestionPerTube: configuration.limitToOneQuestionPerTube, challengesBetweenSameCompetence: configuration.challengesBetweenSameCompetence, forcedCompetences: configuration.forcedCompetences, - warmUpLength: configuration.warmUpLength, enablePassageByAllCompetences: configuration.enablePassageByAllCompetences, }); } diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js index 87746b646ec..db36471f740 100644 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js +++ b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js @@ -1,25 +1,19 @@ import lodash from 'lodash'; export class FlashAssessmentAlgorithmForcedCompetencesRule { - static isApplicable({ answers, forcedCompetences, warmUpLength }) { - return forcedCompetences.length > 0 && answers.length >= warmUpLength; + static isApplicable({ forcedCompetences }) { + return forcedCompetences.length > 0; } - static execute({ allChallenges, assessmentAnswers, availableChallenges, warmUpLength, forcedCompetences }) { - const answersAfterWarmup = this._getAnswersAfterWarmup({ assessmentAnswers, warmUpLength }); - + static execute({ allChallenges, assessmentAnswers, availableChallenges, forcedCompetences }) { return this._filterAlreadyAnsweredCompetences({ - assessmentAnswers: answersAfterWarmup, + assessmentAnswers, availableChallenges, allChallenges, forcedCompetences, }); } - static _getAnswersAfterWarmup({ assessmentAnswers, warmUpLength }) { - return assessmentAnswers.slice(warmUpLength); - } - static _filterAlreadyAnsweredCompetences({ assessmentAnswers, allChallenges, diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmPassageByAllCompetencesRule.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmPassageByAllCompetencesRule.js index 0f990cbbfd4..e1dc26705a0 100644 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmPassageByAllCompetencesRule.js +++ b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmPassageByAllCompetencesRule.js @@ -1,24 +1,18 @@ import lodash from 'lodash'; export class FlashAssessmentAlgorithmPassageByAllCompetencesRule { - static isApplicable({ answers, enablePassageByAllCompetences, warmUpLength }) { - return enablePassageByAllCompetences && answers.length >= warmUpLength; + static isApplicable({ enablePassageByAllCompetences }) { + return enablePassageByAllCompetences; } - static execute({ allChallenges, assessmentAnswers, availableChallenges, warmUpLength }) { - const answersAfterWarmup = this._getAnswersAfterWarmup({ assessmentAnswers, warmUpLength }); - + static execute({ allChallenges, assessmentAnswers, availableChallenges }) { return this._filterAlreadyAnsweredCompetences({ - assessmentAnswers: answersAfterWarmup, + assessmentAnswers, availableChallenges, allChallenges, }); } - static _getAnswersAfterWarmup({ assessmentAnswers, warmUpLength }) { - return assessmentAnswers.slice(warmUpLength); - } - static _filterAlreadyAnsweredCompetences({ assessmentAnswers, allChallenges, availableChallenges }) { const answeredCompetenceIds = assessmentAnswers.map( ({ challengeId }) => lodash.find(allChallenges, { id: challengeId }).competenceId, diff --git a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js index b682bb26064..407a65a73de 100644 --- a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js +++ b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js @@ -4,7 +4,6 @@ const { Serializer } = jsonapiSerializer; const serialize = function ({ flashAlgorithmConfiguration }) { const attributes = [ - 'warmUpLength', 'forcedCompetences', 'maximumAssessmentLength', 'challengesBetweenSameCompetence', diff --git a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js index 26f9bee3ea0..bd2081d95bb 100644 --- a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js +++ b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js @@ -14,7 +14,6 @@ import { FlashAssessmentSuccessRateHandler } from '../../../flash-certification/ */ export class FlashAssessmentAlgorithmConfiguration { constructor({ - warmUpLength = 0, forcedCompetences = [], maximumAssessmentLength = config.v3Certification.numberOfChallengesPerCourse, challengesBetweenSameCompetence = config.v3Certification.challengesBetweenSameCompetence, @@ -25,7 +24,6 @@ export class FlashAssessmentAlgorithmConfiguration { variationPercentUntil, createdAt, } = {}) { - this.warmUpLength = warmUpLength; this.forcedCompetences = forcedCompetences; this.maximumAssessmentLength = maximumAssessmentLength; this.challengesBetweenSameCompetence = challengesBetweenSameCompetence; @@ -39,7 +37,6 @@ export class FlashAssessmentAlgorithmConfiguration { toDTO() { return { - warmUpLength: this.warmUpLength, forcedCompetences: JSON.stringify(this.forcedCompetences), maximumAssessmentLength: this.maximumAssessmentLength, challengesBetweenSameCompetence: this.challengesBetweenSameCompetence, @@ -55,7 +52,6 @@ export class FlashAssessmentAlgorithmConfiguration { } static fromDTO({ - warmUpLength, forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, @@ -67,7 +63,6 @@ export class FlashAssessmentAlgorithmConfiguration { createdAt, }) { return new FlashAssessmentAlgorithmConfiguration({ - warmUpLength, forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, diff --git a/api/tests/certification/flash-certification/acceptance/application/flash-assessment-configuration-route_test.js b/api/tests/certification/flash-certification/acceptance/application/flash-assessment-configuration-route_test.js index 1b10ffaef37..506795f5ceb 100644 --- a/api/tests/certification/flash-certification/acceptance/application/flash-assessment-configuration-route_test.js +++ b/api/tests/certification/flash-certification/acceptance/application/flash-assessment-configuration-route_test.js @@ -52,7 +52,7 @@ describe('Acceptance | Application | flash-assessment-configuration-route', func describe('when there is an available configuration', function () { it('should return a 200', async function () { // given - const warmUpLength = 12; + const enablePassageByAllCompetences = true; const superAdmin = databaseBuilder.factory.buildUser.withRole({ role: PIX_ADMIN.ROLES.SUPER_ADMIN, }); @@ -63,7 +63,7 @@ describe('Acceptance | Application | flash-assessment-configuration-route', func databaseBuilder.factory.buildFlashAlgorithmConfiguration({ createdAt: new Date('2021-01-01'), - warmUpLength, + enablePassageByAllCompetences, }); await databaseBuilder.commit(); @@ -83,7 +83,7 @@ describe('Acceptance | Application | flash-assessment-configuration-route', func // then expect(response.statusCode).to.equal(200); - expect(response.result.data.attributes['warm-up-length']).to.equal(warmUpLength); + expect(response.result.data.attributes['enable-passage-by-all-competences']).to.be.true; }); }); }); diff --git a/api/tests/certification/flash-certification/integration/application/flash-assessment-configuration-controller_test.js b/api/tests/certification/flash-certification/integration/application/flash-assessment-configuration-controller_test.js index 586fab9f08f..739f1ae0d21 100644 --- a/api/tests/certification/flash-certification/integration/application/flash-assessment-configuration-controller_test.js +++ b/api/tests/certification/flash-certification/integration/application/flash-assessment-configuration-controller_test.js @@ -9,7 +9,7 @@ describe('Integration | Application | FlashAssessmentConfigurationController', f data: { type: 'flash-algorithm-configurations', attributes: { - 'warm-up-length': 12, + 'enable-passage-by-all-competences': true, }, }, }; @@ -20,7 +20,7 @@ describe('Integration | Application | FlashAssessmentConfigurationController', f }; const flashAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ - warmUpLength: 12, + enablePassageByAllCompetences: true, }); usecases.getActiveFlashAssessmentConfiguration.resolves(flashAlgorithmConfiguration); @@ -42,7 +42,7 @@ describe('Integration | Application | FlashAssessmentConfigurationController', f sinon.stub(usecases, 'createFlashAssessmentConfiguration'); const payload = { - warmUpLength: 12, + enablePassageByAllCompetences: true, }; const response = await flashAssessmentConfigurationController.createFlashAssessmentConfiguration( diff --git a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index 78d94a134f4..ef04c82d7ef 100644 --- a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -6,7 +6,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R it('should create a flash algorithm configuration', async function () { // given const flashAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ - warmUpLength: 1, maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, @@ -25,7 +24,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R // then const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ - warmUpLength: 1, forcedCompetences: ['comp1', 'comp2'], minimumEstimatedSuccessRateRanges: [ { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, @@ -42,7 +40,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R it('should create a flash algorithm configuration without forced competences', async function () { // given const flashAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ - warmUpLength: 1, maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, @@ -60,7 +57,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R // then const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ - warmUpLength: 1, forcedCompetences: [], minimumEstimatedSuccessRateRanges: [ { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, @@ -77,7 +73,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R it('should create a flash algorithm configuration without minimum estimated success rate ranges', async function () { // given const flashAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ - warmUpLength: 1, maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, @@ -93,7 +88,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R // then const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ - warmUpLength: 1, forcedCompetences: ['comp1', 'comp2'], minimumEstimatedSuccessRateRanges: [], maximumAssessmentLength: 2, diff --git a/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule_test.js b/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule_test.js index 3c5621a59fa..02881dad8d0 100644 --- a/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule_test.js +++ b/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule_test.js @@ -7,32 +7,16 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg it('should return false', function () { const configuration = { forcedCompetences: [], - warmUpLength: 1, - answers: [], }; expect(FlashAssessmentAlgorithmForcedCompetencesRule.isApplicable(configuration)).to.be.false; }); }); - describe('when there is forcedCompetences AND answers length is smaller than warmUpLength', function () { - it('should return false', function () { - const configuration = { - forcedCompetences: ['comp1'], - warmUpLength: 2, - answers: [], - }; - - expect(FlashAssessmentAlgorithmForcedCompetencesRule.isApplicable(configuration)).to.be.false; - }); - }); - - describe('when there is forcedCompetence AND answers length is bigger or equal than warmUpLength', function () { + describe('when there is at least one forcedCompetence', function () { it('should return true', function () { const configuration = { forcedCompetences: ['comp1'], - warmUpLength: 0, - answers: [], }; expect(FlashAssessmentAlgorithmForcedCompetencesRule.isApplicable(configuration)).to.be.true; @@ -80,13 +64,12 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg allChallenges, assessmentAnswers, availableChallenges: allChallenges, - warmUpLength: 0, forcedCompetences: ['comp1'], }), ).to.deep.equal([unansweredCompetenceUnansweredForcedChallenge]); }); - it('should all the challenges if they are all answered', function () { + it('should return all the challenges if they are all answered', function () { const unansweredCompetenceUnansweredChallenge = domainBuilder.buildChallenge({ id: 'challenge1', competenceId: 'competenceId1', @@ -128,7 +111,6 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg allChallenges, assessmentAnswers, availableChallenges: allChallenges, - warmUpLength: 0, forcedCompetences: ['comp1'], }), ).to.deep.equal(allChallenges); diff --git a/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmPassageByAllCompetencesRule_test.js b/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmPassageByAllCompetencesRule_test.js index 4fc5ed5642f..a0c96f1037a 100644 --- a/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmPassageByAllCompetencesRule_test.js +++ b/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmPassageByAllCompetencesRule_test.js @@ -7,7 +7,6 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg it('should return false', function () { const configuration = { enablePassageByAllCompetences: false, - warmUpLength: 1, answers: [], }; @@ -15,24 +14,10 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg }); }); - describe('when enablePassageByAllCompetences is true AND answers length is smaller than warmUpLength', function () { - it('should return false', function () { - const configuration = { - enablePassageByAllCompetences: true, - warmUpLength: 2, - answers: [], - }; - - expect(FlashAssessmentAlgorithmPassageByAllCompetencesRule.isApplicable(configuration)).to.be.false; - }); - }); - - describe('when the enablePassageByAllCompetences is true AND answers length is bigger or equal than warmUpLength', function () { + describe('when enablePassageByAllCompetences is true', function () { it('should return true', function () { const configuration = { enablePassageByAllCompetences: true, - warmUpLength: 0, - answers: [], }; expect(FlashAssessmentAlgorithmPassageByAllCompetencesRule.isApplicable(configuration)).to.be.true; @@ -74,7 +59,6 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg allChallenges, assessmentAnswers, availableChallenges: allChallenges, - warmUpLength: 0, }), ).to.deep.equal([unansweredCompetenceUnansweredChallenge]); }); diff --git a/api/tests/certification/flash-certification/unit/domain/usecases/update-active-flash-assessment-configuration_test.js b/api/tests/certification/flash-certification/unit/domain/usecases/update-active-flash-assessment-configuration_test.js index 725c7a01f70..8c38626ce7c 100644 --- a/api/tests/certification/flash-certification/unit/domain/usecases/update-active-flash-assessment-configuration_test.js +++ b/api/tests/certification/flash-certification/unit/domain/usecases/update-active-flash-assessment-configuration_test.js @@ -14,11 +14,11 @@ describe('Unit | Domain | UseCases | create-flash-assessment-configuration', fun }; const configuration = { - warmUpLength: 12, + enablePassageByAllCompetences: true, }; const previousConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ - warmUpLength: 10, + enablePassageByAllCompetences: false, variationPercent: 0.5, }); diff --git a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js index c6e3a637d94..086583794fd 100644 --- a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js +++ b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js @@ -11,7 +11,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori id: '0', type: 'flash-algorithm-configurations', attributes: { - 'warm-up-length': 1, 'forced-competences': 2, 'maximum-assessment-length': 3, 'challenges-between-same-competence': 4, @@ -25,7 +24,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori }; const flashAlgorithmConfiguration = new FlashAssessmentAlgorithmConfiguration({ - warmUpLength: 1, forcedCompetences: 2, maximumAssessmentLength: 3, challengesBetweenSameCompetence: 4, diff --git a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js index 80e1e74a90b..858e41437ef 100644 --- a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js +++ b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js @@ -9,7 +9,6 @@ describe('Integration | Domain | services | scoringDegradationService', function const allChallenges = _buildChallenges(); const allAnswers = _buildAnswers(); const flashAssessmentAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ - warmUpLength: 0, forcedCompetences: [], maximumAssessmentLength: 4, challengesBetweenSameCompetence: 0, diff --git a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index f41068b5e18..98155f4d6be 100644 --- a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -11,7 +11,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F it('should return a flash algorithm configuration', async function () { // given const flashAlgorithmConfiguration = databaseBuilder.factory.buildFlashAlgorithmConfiguration({ - warmUpLength: 1, maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, @@ -44,7 +43,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F it('should return the latest', async function () { // given const latestFlashAlgorithmConfiguration = databaseBuilder.factory.buildFlashAlgorithmConfiguration({ - warmUpLength: 1, maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, @@ -59,7 +57,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F }); databaseBuilder.factory.buildFlashAlgorithmConfiguration({ - warmUpLength: 1, maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, diff --git a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js index 75945935f9d..f0ddee71b19 100644 --- a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js +++ b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js @@ -5,7 +5,6 @@ import { config } from '../../../../../../src/shared/config.js'; import { catchErrSync, domainBuilder, expect, sinon } from '../../../../../test-helper.js'; const baseFlashAssessmentAlgorithmConfig = { - warmUpLength: 0, forcedCompetences: [], minimumEstimatedSuccessRateRanges: [], limitToOneQuestionPerTube: false, diff --git a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js index 5285f11521d..37341fb18a9 100644 --- a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js +++ b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js @@ -2,7 +2,6 @@ import { FlashAssessmentSuccessRateHandler } from '../../../../src/certification import { FlashAssessmentAlgorithmConfiguration } from '../../../../src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js'; export const buildFlashAlgorithmConfiguration = ({ - warmUpLength, forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, @@ -14,7 +13,6 @@ export const buildFlashAlgorithmConfiguration = ({ createdAt, } = {}) => { return new FlashAssessmentAlgorithmConfiguration({ - warmUpLength, forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, From 4a271a28ddc25d950fb2d99a3c10607fffab84b5 Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 28 Nov 2024 14:15:46 +0100 Subject: [PATCH 4/8] refactor(api): remove minimumEstimatedSuccessRangeCompetence from flash algorithm --- .../models/flash-algorithm-configuration.js | 1 - .../build-flash-algorithm-configuration.js | 2 - .../data/team-certification/data-builder.js | 1 - ...-next-challenge-for-campaign-assessment.js | 1 - .../domain/models/FlashAssessmentAlgorithm.js | 20 +---- .../FlashAssessmentSuccessRateHandler.js | 42 ---------- ...sessmentSuccessRateHandlerFixedStrategy.js | 16 ---- ...lash-algorithm-configuration-serializer.js | 1 - .../FlashAssessmentAlgorithmConfiguration.js | 11 --- .../usecases/get-next-challenge_test.js | 8 -- ...algorithm-configuration-repository_test.js | 13 --- .../FlashAssessmentSuccessRateHandler_test.js | 83 ------------------- ...algorithm-configuration-serializer_test.js | 2 - .../scoring-degradation-service_test.js | 1 - ...algorithm-configuration-repository_test.js | 13 --- .../models/FlashAssessmentAlgorithm_test.js | 74 ----------------- .../build-flash-algorithm-configuration.js | 5 -- ...sessment-algorithm-success-rate-handler.js | 9 -- .../tooling/domain-builder/factory/index.js | 2 - 19 files changed, 1 insertion(+), 304 deletions(-) delete mode 100644 api/src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js delete mode 100644 api/src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandlerFixedStrategy.js delete mode 100644 api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentSuccessRateHandler_test.js delete mode 100644 api/tests/tooling/domain-builder/factory/build-flash-assessment-algorithm-success-rate-handler.js diff --git a/admin/app/models/flash-algorithm-configuration.js b/admin/app/models/flash-algorithm-configuration.js index cd244af3fd4..2b2aa528bd6 100644 --- a/admin/app/models/flash-algorithm-configuration.js +++ b/admin/app/models/flash-algorithm-configuration.js @@ -8,5 +8,4 @@ export default class FlashAlgorithmConfiguration extends Model { @attr('boolean') limitToOneQuestionPerTube; @attr('boolean') enablePassageByAllCompetences; @attr('array') forcedCompetences; - @attr('array') minimumEstimatedSuccessRateRanges; } diff --git a/api/db/database-builder/factory/build-flash-algorithm-configuration.js b/api/db/database-builder/factory/build-flash-algorithm-configuration.js index bd7d2728db6..c552f59a456 100644 --- a/api/db/database-builder/factory/build-flash-algorithm-configuration.js +++ b/api/db/database-builder/factory/build-flash-algorithm-configuration.js @@ -5,7 +5,6 @@ const buildFlashAlgorithmConfiguration = function ({ forcedCompetences = [], maximumAssessmentLength = config.v3Certification.numberOfChallengesPerCourse, challengesBetweenSameCompetence = null, - minimumEstimatedSuccessRateRanges = [], limitToOneQuestionPerTube = null, enablePassageByAllCompetences = false, variationPercent = null, @@ -16,7 +15,6 @@ const buildFlashAlgorithmConfiguration = function ({ maximumAssessmentLength, challengesBetweenSameCompetence, forcedCompetences: JSON.stringify(forcedCompetences), - minimumEstimatedSuccessRateRanges: JSON.stringify(minimumEstimatedSuccessRateRanges), limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, diff --git a/api/db/seeds/data/team-certification/data-builder.js b/api/db/seeds/data/team-certification/data-builder.js index 3a4f169edfa..4eab7df322b 100644 --- a/api/db/seeds/data/team-certification/data-builder.js +++ b/api/db/seeds/data/team-certification/data-builder.js @@ -121,7 +121,6 @@ function _createV3CertificationConfiguration({ databaseBuilder }) { forcedCompetences: [], maximumAssessmentLength: 32, challengesBetweenSameCompetence: null, - minimumEstimatedSuccessRateRanges: [], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: true, variationPercent: 0.5, diff --git a/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js b/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js index 51f7f449027..80f60124fc3 100644 --- a/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js +++ b/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js @@ -67,7 +67,6 @@ const _createDefaultAlgorithmConfiguration = () => { return new FlashAssessmentAlgorithmConfiguration({ forcedCompetences: [], limitToOneQuestionPerTube: false, - minimumEstimatedSuccessRateRanges: [], enablePassageByAllCompetences: false, }); }; diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js index 346f67c7ac0..ae8b9f828d7 100644 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js +++ b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js @@ -57,14 +57,12 @@ class FlashAssessmentAlgorithm { throw new RangeError('No eligible challenges in referential'); } - const minimalSuccessRate = this.#computeMinimalSuccessRate(assessmentAnswers.length); - return this.flashAlgorithmImplementation.getPossibleNextChallenges({ availableChallenges: challengesAfterRulesApplication, capacity, options: { challengesBetweenSameCompetence: this._configuration.challengesBetweenSameCompetence, - minimalSuccessRate, + minimalSuccessRate: 0, }, }); } @@ -84,22 +82,6 @@ class FlashAssessmentAlgorithm { }); } - #computeMinimalSuccessRate(questionIndex) { - const filterConfiguration = this.#findApplicableSuccessRateConfiguration(questionIndex); - - if (!filterConfiguration) { - return 0; - } - - return filterConfiguration.getMinimalSuccessRate(questionIndex); - } - - #findApplicableSuccessRateConfiguration(questionIndex) { - return this._configuration.minimumEstimatedSuccessRateRanges.find((successRateRange) => - successRateRange.isApplicable(questionIndex), - ); - } - getCapacityAndErrorRate({ allAnswers, challenges, diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js deleted file mode 100644 index d5d8ae461a4..00000000000 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js +++ /dev/null @@ -1,42 +0,0 @@ -import { FlashAssessmentSuccessRateHandlerFixedStrategy } from './FlashAssessmentSuccessRateHandlerFixedStrategy.js'; - -class FlashAssessmentSuccessRateHandler { - constructor({ startingChallengeIndex, endingChallengeIndex, strategy }) { - this.startingChallengeIndex = startingChallengeIndex; - this.endingChallengeIndex = endingChallengeIndex; - this._strategy = strategy; - } - - isApplicable(questionIndex) { - return this.startingChallengeIndex <= questionIndex && this.endingChallengeIndex >= questionIndex; - } - - getMinimalSuccessRate(questionIndex) { - return this._strategy.getMinimalSuccessRate(this.startingChallengeIndex, this.endingChallengeIndex, questionIndex); - } - - static create(successRateRange) { - const { startingChallengeIndex, endingChallengeIndex, value } = successRateRange; - return new FlashAssessmentSuccessRateHandler({ - startingChallengeIndex, - endingChallengeIndex, - strategy: new FlashAssessmentSuccessRateHandlerFixedStrategy({ - value, - }), - }); - } - - toDTO() { - return { - startingChallengeIndex: this.startingChallengeIndex, - endingChallengeIndex: this.endingChallengeIndex, - ...this._strategy.toDTO(), - }; - } - - static fromDTO(config) { - return FlashAssessmentSuccessRateHandler.create(config); - } -} - -export { FlashAssessmentSuccessRateHandler }; diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandlerFixedStrategy.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandlerFixedStrategy.js deleted file mode 100644 index 3f6f06935fa..00000000000 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandlerFixedStrategy.js +++ /dev/null @@ -1,16 +0,0 @@ -export class FlashAssessmentSuccessRateHandlerFixedStrategy { - constructor({ value }) { - this.value = value; - } - - getMinimalSuccessRate() { - return this.value; - } - - toDTO() { - return { - type: 'fixed', - value: this.value, - }; - } -} diff --git a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js index 407a65a73de..449f33f5c9c 100644 --- a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js +++ b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js @@ -7,7 +7,6 @@ const serialize = function ({ flashAlgorithmConfiguration }) { 'forcedCompetences', 'maximumAssessmentLength', 'challengesBetweenSameCompetence', - 'minimumEstimatedSuccessRateRanges', 'limitToOneQuestionPerTube', 'enablePassageByAllCompetences', 'variationPercent', diff --git a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js index bd2081d95bb..8b97ca5b06c 100644 --- a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js +++ b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js @@ -1,11 +1,9 @@ import { config } from '../../../../shared/config.js'; -import { FlashAssessmentSuccessRateHandler } from '../../../flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js'; /** * @param forcedCompetences - force the algorithm to ask questions on the specified competences * @param maximumAssessmentLength - override the default limit for an assessment length * @param challengesBetweenSameCompetence - define a number of questions before getting another one on the same competence - * @param minimumEstimatedSuccessRateRanges - force a minimal estimated success rate for challenges chosen at specific indexes * @param limitToOneQuestionPerTube - limits questions to one per tube * @param flashImplementation - the flash algorithm implementation * @param enablePassageByAllCompetences - enable or disable the passage through all competences @@ -17,7 +15,6 @@ export class FlashAssessmentAlgorithmConfiguration { forcedCompetences = [], maximumAssessmentLength = config.v3Certification.numberOfChallengesPerCourse, challengesBetweenSameCompetence = config.v3Certification.challengesBetweenSameCompetence, - minimumEstimatedSuccessRateRanges = [], limitToOneQuestionPerTube = false, enablePassageByAllCompetences = false, variationPercent, @@ -27,7 +24,6 @@ export class FlashAssessmentAlgorithmConfiguration { this.forcedCompetences = forcedCompetences; this.maximumAssessmentLength = maximumAssessmentLength; this.challengesBetweenSameCompetence = challengesBetweenSameCompetence; - this.minimumEstimatedSuccessRateRanges = minimumEstimatedSuccessRateRanges; this.limitToOneQuestionPerTube = limitToOneQuestionPerTube; this.enablePassageByAllCompetences = enablePassageByAllCompetences; this.variationPercent = variationPercent; @@ -40,9 +36,6 @@ export class FlashAssessmentAlgorithmConfiguration { forcedCompetences: JSON.stringify(this.forcedCompetences), maximumAssessmentLength: this.maximumAssessmentLength, challengesBetweenSameCompetence: this.challengesBetweenSameCompetence, - minimumEstimatedSuccessRateRanges: JSON.stringify( - this.minimumEstimatedSuccessRateRanges.map((successRateRange) => successRateRange.toDTO()), - ), limitToOneQuestionPerTube: this.limitToOneQuestionPerTube, enablePassageByAllCompetences: this.enablePassageByAllCompetences, variationPercent: this.variationPercent, @@ -55,7 +48,6 @@ export class FlashAssessmentAlgorithmConfiguration { forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, - minimumEstimatedSuccessRateRanges, limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, @@ -66,9 +58,6 @@ export class FlashAssessmentAlgorithmConfiguration { forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, - minimumEstimatedSuccessRateRanges: minimumEstimatedSuccessRateRanges - ? minimumEstimatedSuccessRateRanges.map((config) => FlashAssessmentSuccessRateHandler.fromDTO(config)) - : minimumEstimatedSuccessRateRanges, limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, diff --git a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js index db8a3265309..073f4bd04ba 100644 --- a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js +++ b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js @@ -657,14 +657,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { Object.entries({ forcedCompetences: [competenceId], challengesBetweenSameCompetence: 2, - minimumEstimatedSuccessRateRanges: [ - { - type: 'fixed', - startingChallengeIndex: 0, - endingChallengeIndex: 10, - value: 0.1, - }, - ], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: true, variationPercent: 20, diff --git a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index ef04c82d7ef..31c7b86f650 100644 --- a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -11,9 +11,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R variationPercent: 4, variationPercentUntil: 3, forcedCompetences: ['comp1', 'comp2'], - minimumEstimatedSuccessRateRanges: [ - { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, - ], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -25,9 +22,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ forcedCompetences: ['comp1', 'comp2'], - minimumEstimatedSuccessRateRanges: [ - { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, - ], maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, limitToOneQuestionPerTube: true, @@ -44,9 +38,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - minimumEstimatedSuccessRateRanges: [ - { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, - ], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -58,9 +49,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ forcedCompetences: [], - minimumEstimatedSuccessRateRanges: [ - { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, - ], maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, limitToOneQuestionPerTube: true, @@ -89,7 +77,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ forcedCompetences: ['comp1', 'comp2'], - minimumEstimatedSuccessRateRanges: [], maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, limitToOneQuestionPerTube: true, diff --git a/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentSuccessRateHandler_test.js b/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentSuccessRateHandler_test.js deleted file mode 100644 index fcd16a56a2a..00000000000 --- a/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentSuccessRateHandler_test.js +++ /dev/null @@ -1,83 +0,0 @@ -import { FlashAssessmentSuccessRateHandler } from '../../../../../../src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js'; -import { expect } from '../../../../../test-helper.js'; - -describe('Unit | Domain | Models | FlashAssessmentAlgorithmSuccessRateHandler', function () { - describe('#isApplicable', function () { - let flashAssessmentSuccessRateHandler; - - beforeEach(function () { - const fixedConfig = { - startingChallengeIndex: 0, - endingChallengeIndex: 7, - value: 0.8, - }; - - flashAssessmentSuccessRateHandler = FlashAssessmentSuccessRateHandler.create(fixedConfig); - }); - - describe('when currentIndex is inside the application range', function () { - it('should return true', function () { - const currentIndex = 5; - - const isApplicable = flashAssessmentSuccessRateHandler.isApplicable(currentIndex); - - expect(isApplicable).to.be.true; - }); - }); - - describe('when filter is outside the application range', function () { - it('should return false', function () { - const currentIndex = 8; - - const isApplicable = flashAssessmentSuccessRateHandler.isApplicable(currentIndex); - - expect(isApplicable).to.be.false; - }); - }); - }); - - describe('#getMinimalSuccessRate', function () { - describe('when strategy is fixed', function () { - let flashAssessmentSuccessRateHandler; - const configSuccessRate = 0.8; - - beforeEach(function () { - const fixedConfig = { - startingChallengeIndex: 0, - endingChallengeIndex: 7, - value: configSuccessRate, - }; - - flashAssessmentSuccessRateHandler = FlashAssessmentSuccessRateHandler.create(fixedConfig); - }); - - it('should return the fixed value', function () { - const questionIndex = 5; - const successRate = flashAssessmentSuccessRateHandler.getMinimalSuccessRate(questionIndex); - - expect(successRate).to.equal(configSuccessRate); - }); - }); - }); - - describe('#create', function () { - describe('when type is fixed', function () { - it('should return the fixed value', function () { - const configSuccessRate = 0.8; - const fixedConfig = { - type: 'fixed', - startingChallengeIndex: 0, - endingChallengeIndex: 7, - value: configSuccessRate, - }; - - const flashAssessmentSuccessRateHandler = FlashAssessmentSuccessRateHandler.create(fixedConfig); - - const questionIndex = 5; - const successRate = flashAssessmentSuccessRateHandler.getMinimalSuccessRate(questionIndex); - - expect(successRate).to.equal(configSuccessRate); - }); - }); - }); -}); diff --git a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js index 086583794fd..0b9e7f8ee67 100644 --- a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js +++ b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js @@ -16,7 +16,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori 'challenges-between-same-competence': 4, 'variation-percent': 6, 'variation-percent-until': 7, - 'minimum-estimated-success-rate-ranges': [], 'limit-to-one-question-per-tube': false, 'enable-passage-by-all-competences': true, }, @@ -29,7 +28,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori challengesBetweenSameCompetence: 4, variationPercent: 6, variationPercentUntil: 7, - minimumEstimatedSuccessRateRanges: [], limitToOneQuestionPerTube: false, enablePassageByAllCompetences: true, }); diff --git a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js index 858e41437ef..e2a3baac49b 100644 --- a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js +++ b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js @@ -12,7 +12,6 @@ describe('Integration | Domain | services | scoringDegradationService', function forcedCompetences: [], maximumAssessmentLength: 4, challengesBetweenSameCompetence: 0, - minimumEstimatedSuccessRateRanges: [], limitToOneQuestionPerTube: false, enablePassageByAllCompetences: false, variationPercent: null, diff --git a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index 98155f4d6be..04feb16dee3 100644 --- a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -16,9 +16,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F variationPercent: 4, variationPercentUntil: 3, forcedCompetences: ['comp1', 'comp2'], - minimumEstimatedSuccessRateRanges: [ - { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, - ], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -26,7 +23,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F const expectedFlashAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ ...flashAlgorithmConfiguration, forcedCompetences: JSON.parse(flashAlgorithmConfiguration.forcedCompetences), - minimumEstimatedSuccessRateRanges: JSON.parse(flashAlgorithmConfiguration.minimumEstimatedSuccessRateRanges), }); await databaseBuilder.commit(); @@ -48,9 +44,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F variationPercent: 4, variationPercentUntil: 3, forcedCompetences: ['comp1', 'comp2'], - minimumEstimatedSuccessRateRanges: [ - { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, - ], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, createdAt: new Date('2021-01-01'), @@ -62,9 +55,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F variationPercent: 4, variationPercentUntil: 3, forcedCompetences: ['comp1', 'comp2'], - minimumEstimatedSuccessRateRanges: [ - { type: 'fixed', startingChallengeIndex: 0, endingChallengeIndex: 7, value: 0.8 }, - ], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, createdAt: new Date('2020-01-01'), @@ -73,9 +63,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F const expectedFlashAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ ...latestFlashAlgorithmConfiguration, forcedCompetences: JSON.parse(latestFlashAlgorithmConfiguration.forcedCompetences), - minimumEstimatedSuccessRateRanges: JSON.parse( - latestFlashAlgorithmConfiguration.minimumEstimatedSuccessRateRanges, - ), }); await databaseBuilder.commit(); diff --git a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js index f0ddee71b19..18a37300b03 100644 --- a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js +++ b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js @@ -1,12 +1,10 @@ import { FlashAssessmentAlgorithm } from '../../../../../../src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js'; -import { FlashAssessmentSuccessRateHandler } from '../../../../../../src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js'; import { FlashAssessmentAlgorithmConfiguration } from '../../../../../../src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js'; import { config } from '../../../../../../src/shared/config.js'; import { catchErrSync, domainBuilder, expect, sinon } from '../../../../../test-helper.js'; const baseFlashAssessmentAlgorithmConfig = { forcedCompetences: [], - minimumEstimatedSuccessRateRanges: [], limitToOneQuestionPerTube: false, enablePassageByAllCompetences: false, }; @@ -246,78 +244,6 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg }); }); }); - - context('when specifying a minimal success rate', function () { - context('when a fixed minimal success rate has been set', function () { - it('should choose a challenge that has the required success rate first', function () { - // Given - const easyDifficulty = -3; - const hardDifficulty = 3; - const discriminant = 1; - const initialCapacity = 3; - - const easyChallenge = domainBuilder.buildChallenge({ - id: 'easyChallenge', - skill: domainBuilder.buildSkill({ - id: 'skillEasy', - }), - competenceId: 'compEasy', - discriminant, - difficulty: easyDifficulty, - }); - - const hardChallenge = domainBuilder.buildChallenge({ - id: 'hardChallenge', - skill: domainBuilder.buildSkill({ - id: 'skillHard', - }), - competenceId: 'compHard', - discriminant, - difficulty: hardDifficulty, - }); - - const challenges = [hardChallenge, easyChallenge]; - const assessmentAnswers = []; - - // when - const algorithm = new FlashAssessmentAlgorithm({ - flashAlgorithmImplementation, - configuration: _getAlgorithmConfig({ - limitToOneQuestionPerTube: true, - minimumEstimatedSuccessRateRanges: [ - FlashAssessmentSuccessRateHandler.create({ - startingChallengeIndex: 0, - endingChallengeIndex: 1, - value: 0.8, - }), - ], - }), - }); - - flashAlgorithmImplementation.getCapacityAndErrorRate.returns({ - capacity: 0, - }); - flashAlgorithmImplementation.getPossibleNextChallenges - .withArgs({ - availableChallenges: challenges, - capacity: 0, - options: { - ...baseGetNextChallengeOptions, - minimalSuccessRate: 0.8, - }, - }) - .returns([easyChallenge, hardChallenge]); - - const nextChallenges = algorithm.getPossibleNextChallenges({ - assessmentAnswers, - challenges, - initialCapacity, - }); - - expect(nextChallenges).to.deep.equal([easyChallenge, hardChallenge]); - }); - }); - }); }); }); diff --git a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js index 37341fb18a9..2321bc42ca8 100644 --- a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js +++ b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js @@ -1,11 +1,9 @@ -import { FlashAssessmentSuccessRateHandler } from '../../../../src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js'; import { FlashAssessmentAlgorithmConfiguration } from '../../../../src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js'; export const buildFlashAlgorithmConfiguration = ({ forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, - minimumEstimatedSuccessRateRanges = [], limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, @@ -16,9 +14,6 @@ export const buildFlashAlgorithmConfiguration = ({ forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, - minimumEstimatedSuccessRateRanges: minimumEstimatedSuccessRateRanges.map((successRateConfig) => - FlashAssessmentSuccessRateHandler.create(successRateConfig), - ), limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, diff --git a/api/tests/tooling/domain-builder/factory/build-flash-assessment-algorithm-success-rate-handler.js b/api/tests/tooling/domain-builder/factory/build-flash-assessment-algorithm-success-rate-handler.js deleted file mode 100644 index 21f35e0f351..00000000000 --- a/api/tests/tooling/domain-builder/factory/build-flash-assessment-algorithm-success-rate-handler.js +++ /dev/null @@ -1,9 +0,0 @@ -import { FlashAssessmentSuccessRateHandler } from '../../../../src/certification/flash-certification/domain/models/FlashAssessmentSuccessRateHandler.js'; - -export const buildFlashAssessmentAlgorithmSuccessRateHandlerFixed = ({ - startingChallengeIndex, - endingChallengeIndex, - value, -}) => { - return FlashAssessmentSuccessRateHandler.create({ startingChallengeIndex, endingChallengeIndex, value }); -}; diff --git a/api/tests/tooling/domain-builder/factory/index.js b/api/tests/tooling/domain-builder/factory/index.js index a11679e3edd..a969c5c1113 100644 --- a/api/tests/tooling/domain-builder/factory/index.js +++ b/api/tests/tooling/domain-builder/factory/index.js @@ -93,7 +93,6 @@ import * as buildDataProtectionOfficer from './build-data-protection-officer.js' import { buildFeedback } from './build-feedback.js'; import { buildFinalizedSession } from './build-finalized-session.js'; import { buildFlashAlgorithmConfiguration } from './build-flash-algorithm-configuration.js'; -import { buildFlashAssessmentAlgorithmSuccessRateHandlerFixed } from './build-flash-assessment-algorithm-success-rate-handler.js'; import { buildFramework } from './build-framework.js'; import { buildHabilitation } from './build-habilitation.js'; import { buildHint } from './build-hint.js'; @@ -359,7 +358,6 @@ export { buildFinalizedSession, buildFlashAlgorithmConfiguration, buildFlashAssessmentAlgorithm, - buildFlashAssessmentAlgorithmSuccessRateHandlerFixed, buildFramework, buildHint, buildJuryCertification, From 79ef2422ce4e7308cb6d72f3a2bc4273a3c3ccce Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 28 Nov 2024 15:37:33 +0100 Subject: [PATCH 5/8] refactor(api): remove forcedCompetences parameter from flash algorithm --- .../models/flash-algorithm-configuration.js | 1 - .../build-flash-algorithm-configuration.js | 2 - .../data/team-certification/data-builder.js | 1 - ...-next-challenge-for-campaign-assessment.js | 1 - .../flash-assessment-configuration-route.js | 1 - .../domain/models/FlashAssessmentAlgorithm.js | 3 - ...ssessmentAlgorithmForcedCompetencesRule.js | 38 ------ ...lash-algorithm-configuration-serializer.js | 1 - .../FlashAssessmentAlgorithmConfiguration.js | 6 - .../usecases/get-next-challenge_test.js | 1 - ...algorithm-configuration-repository_test.js | 5 - ...mentAlgorithmForcedCompetencesRule_test.js | 119 ------------------ ...algorithm-configuration-serializer_test.js | 2 - .../scoring-degradation-service_test.js | 1 - ...algorithm-configuration-repository_test.js | 5 - .../models/FlashAssessmentAlgorithm_test.js | 1 - .../build-flash-algorithm-configuration.js | 2 - 17 files changed, 190 deletions(-) delete mode 100644 api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js delete mode 100644 api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule_test.js diff --git a/admin/app/models/flash-algorithm-configuration.js b/admin/app/models/flash-algorithm-configuration.js index 2b2aa528bd6..4825956febb 100644 --- a/admin/app/models/flash-algorithm-configuration.js +++ b/admin/app/models/flash-algorithm-configuration.js @@ -7,5 +7,4 @@ export default class FlashAlgorithmConfiguration extends Model { @attr('number') variationPercentUntil; @attr('boolean') limitToOneQuestionPerTube; @attr('boolean') enablePassageByAllCompetences; - @attr('array') forcedCompetences; } diff --git a/api/db/database-builder/factory/build-flash-algorithm-configuration.js b/api/db/database-builder/factory/build-flash-algorithm-configuration.js index c552f59a456..c81f6dbb222 100644 --- a/api/db/database-builder/factory/build-flash-algorithm-configuration.js +++ b/api/db/database-builder/factory/build-flash-algorithm-configuration.js @@ -2,7 +2,6 @@ import { config } from '../../../src/shared/config.js'; import { databaseBuffer } from '../database-buffer.js'; const buildFlashAlgorithmConfiguration = function ({ - forcedCompetences = [], maximumAssessmentLength = config.v3Certification.numberOfChallengesPerCourse, challengesBetweenSameCompetence = null, limitToOneQuestionPerTube = null, @@ -14,7 +13,6 @@ const buildFlashAlgorithmConfiguration = function ({ const values = { maximumAssessmentLength, challengesBetweenSameCompetence, - forcedCompetences: JSON.stringify(forcedCompetences), limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, diff --git a/api/db/seeds/data/team-certification/data-builder.js b/api/db/seeds/data/team-certification/data-builder.js index 4eab7df322b..06dce7878d5 100644 --- a/api/db/seeds/data/team-certification/data-builder.js +++ b/api/db/seeds/data/team-certification/data-builder.js @@ -118,7 +118,6 @@ async function _createScoCertificationCenter({ databaseBuilder }) { function _createV3CertificationConfiguration({ databaseBuilder }) { databaseBuilder.factory.buildFlashAlgorithmConfiguration({ - forcedCompetences: [], maximumAssessmentLength: 32, challengesBetweenSameCompetence: null, limitToOneQuestionPerTube: true, diff --git a/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js b/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js index 80f60124fc3..60be75ede08 100644 --- a/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js +++ b/api/lib/domain/usecases/get-next-challenge-for-campaign-assessment.js @@ -65,7 +65,6 @@ const _hasAnsweredToAllChallenges = ({ possibleChallenges }) => { const _createDefaultAlgorithmConfiguration = () => { return new FlashAssessmentAlgorithmConfiguration({ - forcedCompetences: [], limitToOneQuestionPerTube: false, enablePassageByAllCompetences: false, }); diff --git a/api/src/certification/flash-certification/application/flash-assessment-configuration-route.js b/api/src/certification/flash-certification/application/flash-assessment-configuration-route.js index 3ffdbeee803..70e42183f65 100644 --- a/api/src/certification/flash-certification/application/flash-assessment-configuration-route.js +++ b/api/src/certification/flash-certification/application/flash-assessment-configuration-route.js @@ -35,7 +35,6 @@ const register = async (server) => { ], validate: { payload: Joi.object({ - forcedCompetences: Joi.array().items(Joi.string()).optional(), maximumAssessmentLength: Joi.number().integer().min(0).allow(null).optional(), challengesBetweenSameCompetence: Joi.number().integer().min(0).allow(null).optional(), limitToOneQuestionPerTube: Joi.boolean().optional(), diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js index ae8b9f828d7..ab4112c7717 100644 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js +++ b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js @@ -1,6 +1,5 @@ import { config } from '../../../../shared/config.js'; import { FlashAssessmentAlgorithmChallengesBetweenCompetencesRule } from './FlashAssessmentAlgorithmChallengesBetweenCompetencesRule.js'; -import { FlashAssessmentAlgorithmForcedCompetencesRule } from './FlashAssessmentAlgorithmForcedCompetencesRule.js'; import { FlashAssessmentAlgorithmNonAnsweredSkillsRule } from './FlashAssessmentAlgorithmNonAnsweredSkillsRule.js'; import { FlashAssessmentAlgorithmOneQuestionPerTubeRule } from './FlashAssessmentAlgorithmOneQuestionPerTubeRule.js'; import { FlashAssessmentAlgorithmPassageByAllCompetencesRule } from './FlashAssessmentAlgorithmPassageByAllCompetencesRule.js'; @@ -10,7 +9,6 @@ const availableRules = [ FlashAssessmentAlgorithmOneQuestionPerTubeRule, FlashAssessmentAlgorithmNonAnsweredSkillsRule, FlashAssessmentAlgorithmPassageByAllCompetencesRule, - FlashAssessmentAlgorithmForcedCompetencesRule, FlashAssessmentAlgorithmChallengesBetweenCompetencesRule, ]; @@ -26,7 +24,6 @@ class FlashAssessmentAlgorithm { this.ruleEngine = new FlashAssessmentAlgorithmRuleEngine(availableRules, { limitToOneQuestionPerTube: configuration.limitToOneQuestionPerTube, challengesBetweenSameCompetence: configuration.challengesBetweenSameCompetence, - forcedCompetences: configuration.forcedCompetences, enablePassageByAllCompetences: configuration.enablePassageByAllCompetences, }); } diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js deleted file mode 100644 index db36471f740..00000000000 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js +++ /dev/null @@ -1,38 +0,0 @@ -import lodash from 'lodash'; - -export class FlashAssessmentAlgorithmForcedCompetencesRule { - static isApplicable({ forcedCompetences }) { - return forcedCompetences.length > 0; - } - - static execute({ allChallenges, assessmentAnswers, availableChallenges, forcedCompetences }) { - return this._filterAlreadyAnsweredCompetences({ - assessmentAnswers, - availableChallenges, - allChallenges, - forcedCompetences, - }); - } - - static _filterAlreadyAnsweredCompetences({ - assessmentAnswers, - allChallenges, - forcedCompetences, - availableChallenges, - }) { - const answeredCompetenceIds = assessmentAnswers.map( - ({ challengeId }) => lodash.find(allChallenges, { id: challengeId }).competenceId, - ); - - const remainingCompetenceIds = forcedCompetences.filter( - (competenceId) => !answeredCompetenceIds.includes(competenceId), - ); - - const allCompetencesAreAnswered = remainingCompetenceIds.length === 0; - - if (allCompetencesAreAnswered) { - return availableChallenges; - } - return availableChallenges.filter(({ competenceId }) => remainingCompetenceIds.includes(competenceId)); - } -} diff --git a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js index 449f33f5c9c..43aae7d7267 100644 --- a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js +++ b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js @@ -4,7 +4,6 @@ const { Serializer } = jsonapiSerializer; const serialize = function ({ flashAlgorithmConfiguration }) { const attributes = [ - 'forcedCompetences', 'maximumAssessmentLength', 'challengesBetweenSameCompetence', 'limitToOneQuestionPerTube', diff --git a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js index 8b97ca5b06c..db2d3e887da 100644 --- a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js +++ b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js @@ -1,7 +1,6 @@ import { config } from '../../../../shared/config.js'; /** - * @param forcedCompetences - force the algorithm to ask questions on the specified competences * @param maximumAssessmentLength - override the default limit for an assessment length * @param challengesBetweenSameCompetence - define a number of questions before getting another one on the same competence * @param limitToOneQuestionPerTube - limits questions to one per tube @@ -12,7 +11,6 @@ import { config } from '../../../../shared/config.js'; */ export class FlashAssessmentAlgorithmConfiguration { constructor({ - forcedCompetences = [], maximumAssessmentLength = config.v3Certification.numberOfChallengesPerCourse, challengesBetweenSameCompetence = config.v3Certification.challengesBetweenSameCompetence, limitToOneQuestionPerTube = false, @@ -21,7 +19,6 @@ export class FlashAssessmentAlgorithmConfiguration { variationPercentUntil, createdAt, } = {}) { - this.forcedCompetences = forcedCompetences; this.maximumAssessmentLength = maximumAssessmentLength; this.challengesBetweenSameCompetence = challengesBetweenSameCompetence; this.limitToOneQuestionPerTube = limitToOneQuestionPerTube; @@ -33,7 +30,6 @@ export class FlashAssessmentAlgorithmConfiguration { toDTO() { return { - forcedCompetences: JSON.stringify(this.forcedCompetences), maximumAssessmentLength: this.maximumAssessmentLength, challengesBetweenSameCompetence: this.challengesBetweenSameCompetence, limitToOneQuestionPerTube: this.limitToOneQuestionPerTube, @@ -45,7 +41,6 @@ export class FlashAssessmentAlgorithmConfiguration { } static fromDTO({ - forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, limitToOneQuestionPerTube, @@ -55,7 +50,6 @@ export class FlashAssessmentAlgorithmConfiguration { createdAt, }) { return new FlashAssessmentAlgorithmConfiguration({ - forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, limitToOneQuestionPerTube, diff --git a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js index 073f4bd04ba..cc97352e053 100644 --- a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js +++ b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js @@ -655,7 +655,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { const competenceId = 'cmp1'; // eslint-disable-next-line mocha/no-setup-in-describe Object.entries({ - forcedCompetences: [competenceId], challengesBetweenSameCompetence: 2, limitToOneQuestionPerTube: true, enablePassageByAllCompetences: true, diff --git a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index 31c7b86f650..1d0b8a2d6fe 100644 --- a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -10,7 +10,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - forcedCompetences: ['comp1', 'comp2'], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -21,7 +20,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R // then const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ - forcedCompetences: ['comp1', 'comp2'], maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, limitToOneQuestionPerTube: true, @@ -48,7 +46,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R // then const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ - forcedCompetences: [], maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, limitToOneQuestionPerTube: true, @@ -65,7 +62,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - forcedCompetences: ['comp1', 'comp2'], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -76,7 +72,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R // then const createdConfiguration = await knex('flash-algorithm-configurations').first(); expect(createdConfiguration).to.deep.contains({ - forcedCompetences: ['comp1', 'comp2'], maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, limitToOneQuestionPerTube: true, diff --git a/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule_test.js b/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule_test.js deleted file mode 100644 index 02881dad8d0..00000000000 --- a/api/tests/certification/flash-certification/unit/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule_test.js +++ /dev/null @@ -1,119 +0,0 @@ -import { FlashAssessmentAlgorithmForcedCompetencesRule } from '../../../../../../src/certification/flash-certification/domain/models/FlashAssessmentAlgorithmForcedCompetencesRule.js'; -import { domainBuilder, expect } from '../../../../../test-helper.js'; - -describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlgorithmForcedCompetencesRule', function () { - describe('#isApplicable', function () { - describe('when there is NO forcedCompetences', function () { - it('should return false', function () { - const configuration = { - forcedCompetences: [], - }; - - expect(FlashAssessmentAlgorithmForcedCompetencesRule.isApplicable(configuration)).to.be.false; - }); - }); - - describe('when there is at least one forcedCompetence', function () { - it('should return true', function () { - const configuration = { - forcedCompetences: ['comp1'], - }; - - expect(FlashAssessmentAlgorithmForcedCompetencesRule.isApplicable(configuration)).to.be.true; - }); - }); - }); - - describe('#execute', function () { - it('should return the challenges with forced competences ONLY', function () { - const unansweredCompetenceUnansweredChallenge = domainBuilder.buildChallenge({ - id: 'challenge1', - competenceId: 'competenceId1', - }); - - const unansweredCompetenceUnansweredForcedChallenge = domainBuilder.buildChallenge({ - id: 'challenge1forced', - competenceId: 'comp1', - }); - - const answeredCompetenceUnansweredChallenge = domainBuilder.buildChallenge({ - id: 'challenge2', - competenceId: 'competenceId2', - }); - - const answeredCompetenceAnsweredChallenge = domainBuilder.buildChallenge({ - id: 'challenge3', - competenceId: 'competenceId2', - }); - - const allChallenges = [ - unansweredCompetenceUnansweredChallenge, - unansweredCompetenceUnansweredForcedChallenge, - answeredCompetenceUnansweredChallenge, - answeredCompetenceAnsweredChallenge, - ]; - - const assessmentAnswers = [ - domainBuilder.buildAnswer({ - challengeId: answeredCompetenceAnsweredChallenge.id, - }), - ]; - - expect( - FlashAssessmentAlgorithmForcedCompetencesRule.execute({ - allChallenges, - assessmentAnswers, - availableChallenges: allChallenges, - forcedCompetences: ['comp1'], - }), - ).to.deep.equal([unansweredCompetenceUnansweredForcedChallenge]); - }); - - it('should return all the challenges if they are all answered', function () { - const unansweredCompetenceUnansweredChallenge = domainBuilder.buildChallenge({ - id: 'challenge1', - competenceId: 'competenceId1', - }); - - const answeredCompetenceUnansweredForcedChallenge = domainBuilder.buildChallenge({ - id: 'challenge1forced', - competenceId: 'comp1', - }); - - const answeredCompetenceUnansweredChallenge = domainBuilder.buildChallenge({ - id: 'challenge2', - competenceId: 'competenceId2', - }); - - const answeredCompetenceAnsweredChallenge = domainBuilder.buildChallenge({ - id: 'challenge3', - competenceId: 'competenceId2', - }); - - const allChallenges = [ - unansweredCompetenceUnansweredChallenge, - answeredCompetenceUnansweredForcedChallenge, - answeredCompetenceUnansweredChallenge, - answeredCompetenceAnsweredChallenge, - ]; - - const assessmentAnswers = [ - domainBuilder.buildAnswer({ - challengeId: answeredCompetenceAnsweredChallenge.id, - }), - domainBuilder.buildAnswer({ - challengeId: answeredCompetenceUnansweredForcedChallenge.id, - }), - ]; - - expect( - FlashAssessmentAlgorithmForcedCompetencesRule.execute({ - allChallenges, - assessmentAnswers, - availableChallenges: allChallenges, - forcedCompetences: ['comp1'], - }), - ).to.deep.equal(allChallenges); - }); - }); -}); diff --git a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js index 0b9e7f8ee67..43cea75613b 100644 --- a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js +++ b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js @@ -11,7 +11,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori id: '0', type: 'flash-algorithm-configurations', attributes: { - 'forced-competences': 2, 'maximum-assessment-length': 3, 'challenges-between-same-competence': 4, 'variation-percent': 6, @@ -23,7 +22,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori }; const flashAlgorithmConfiguration = new FlashAssessmentAlgorithmConfiguration({ - forcedCompetences: 2, maximumAssessmentLength: 3, challengesBetweenSameCompetence: 4, variationPercent: 6, diff --git a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js index e2a3baac49b..1866986e956 100644 --- a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js +++ b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js @@ -9,7 +9,6 @@ describe('Integration | Domain | services | scoringDegradationService', function const allChallenges = _buildChallenges(); const allAnswers = _buildAnswers(); const flashAssessmentAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ - forcedCompetences: [], maximumAssessmentLength: 4, challengesBetweenSameCompetence: 0, limitToOneQuestionPerTube: false, diff --git a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index 04feb16dee3..ac0cd818957 100644 --- a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -15,14 +15,12 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - forcedCompetences: ['comp1', 'comp2'], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); const expectedFlashAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ ...flashAlgorithmConfiguration, - forcedCompetences: JSON.parse(flashAlgorithmConfiguration.forcedCompetences), }); await databaseBuilder.commit(); @@ -43,7 +41,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - forcedCompetences: ['comp1', 'comp2'], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, createdAt: new Date('2021-01-01'), @@ -54,7 +51,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F challengesBetweenSameCompetence: 3, variationPercent: 4, variationPercentUntil: 3, - forcedCompetences: ['comp1', 'comp2'], limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, createdAt: new Date('2020-01-01'), @@ -62,7 +58,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F const expectedFlashAlgorithmConfiguration = domainBuilder.buildFlashAlgorithmConfiguration({ ...latestFlashAlgorithmConfiguration, - forcedCompetences: JSON.parse(latestFlashAlgorithmConfiguration.forcedCompetences), }); await databaseBuilder.commit(); diff --git a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js index 18a37300b03..cc234ead5a3 100644 --- a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js +++ b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js @@ -4,7 +4,6 @@ import { config } from '../../../../../../src/shared/config.js'; import { catchErrSync, domainBuilder, expect, sinon } from '../../../../../test-helper.js'; const baseFlashAssessmentAlgorithmConfig = { - forcedCompetences: [], limitToOneQuestionPerTube: false, enablePassageByAllCompetences: false, }; diff --git a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js index 2321bc42ca8..c225c546f86 100644 --- a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js +++ b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js @@ -1,7 +1,6 @@ import { FlashAssessmentAlgorithmConfiguration } from '../../../../src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js'; export const buildFlashAlgorithmConfiguration = ({ - forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, limitToOneQuestionPerTube, @@ -11,7 +10,6 @@ export const buildFlashAlgorithmConfiguration = ({ createdAt, } = {}) => { return new FlashAssessmentAlgorithmConfiguration({ - forcedCompetences, maximumAssessmentLength, challengesBetweenSameCompetence, limitToOneQuestionPerTube, From 10c22350b1a95e005873f3f76228884c99a5b387 Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 28 Nov 2024 16:05:49 +0100 Subject: [PATCH 6/8] refactor(api): remove variationPercentUntil parameter from flash algorithm --- .../flash-algorithm-configuration/form.gjs | 12 - .../flash-algorithm-configuration/index.gjs | 1 - .../models/flash-algorithm-configuration.js | 1 - .../flash-algorithm-configuration_test.gjs | 5 - .../flash-algorithm-configuration-test.js | 2 - admin/translations/en.json | 3 +- admin/translations/fr.json | 3 +- .../build-flash-algorithm-configuration.js | 2 - .../data/team-certification/data-builder.js | 1 - .../flash-assessment-configuration-route.js | 1 - .../domain/models/FlashAssessmentAlgorithm.js | 2 - .../services/algorithm-methods/flash.js | 32 +-- ...lash-algorithm-configuration-serializer.js | 1 - .../FlashAssessmentAlgorithmConfiguration.js | 6 - .../services/scoring/scoring-v3_test.js | 22 -- .../usecases/get-next-challenge_test.js | 6 - ...algorithm-configuration-repository_test.js | 6 - .../services/algorithm-methods/flash_test.js | 242 ++++++------------ ...algorithm-configuration-serializer_test.js | 2 - .../scoring-degradation-service_test.js | 1 - ...algorithm-configuration-repository_test.js | 3 - .../models/FlashAssessmentAlgorithm_test.js | 1 - .../build-flash-algorithm-configuration.js | 2 - ...-challenge-for-campaign-assessment_test.js | 1 - 24 files changed, 77 insertions(+), 281 deletions(-) diff --git a/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs b/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs index bd64ae4cba1..e867cef7e0d 100644 --- a/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs +++ b/admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs @@ -40,18 +40,6 @@ import { t } from 'ember-intl'; <:label>{{t "pages.administration.certification.flash-algorithm-configuration.form.variationPercent"}} - - <:label>{{t - "pages.administration.certification.flash-algorithm-configuration.form.variationPercentUntil" - }} - - { limitToOneQuestionPerTube: Joi.boolean().optional(), enablePassageByAllCompetences: Joi.boolean().optional(), variationPercent: Joi.number().min(0).max(1).allow(null).optional(), - variationPercentUntil: Joi.number().min(0).allow(null).optional(), }), }, handler: flashAssessmentConfigurationController.createFlashAssessmentConfiguration, diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js index ab4112c7717..93e4c4abb73 100644 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js +++ b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js @@ -89,7 +89,6 @@ class FlashAssessmentAlgorithm { challenges, capacity: initialCapacity, variationPercent: this._configuration.variationPercent, - variationPercentUntil: this._configuration.variationPercentUntil, }); } @@ -103,7 +102,6 @@ class FlashAssessmentAlgorithm { challenges, capacity: initialCapacity, variationPercent: this._configuration.variationPercent, - variationPercentUntil: this._configuration.variationPercentUntil, }); } diff --git a/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js b/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js index 9583936eb39..ac92a207192 100644 --- a/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js +++ b/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js @@ -43,13 +43,7 @@ function getPossibleNextChallenges({ return _findBestPossibleChallenges(challengesWithReward, minimalSuccessRate, capacity); } -function getCapacityAndErrorRate({ - allAnswers, - challenges, - capacity = DEFAULT_CAPACITY, - variationPercent, - variationPercentUntil, -}) { +function getCapacityAndErrorRate({ allAnswers, challenges, capacity = DEFAULT_CAPACITY, variationPercent }) { if (allAnswers.length === 0) { return { capacity, errorRate: DEFAULT_ERROR_RATE }; } @@ -59,19 +53,12 @@ function getCapacityAndErrorRate({ challenges, capacity, variationPercent, - variationPercentUntil, }); return capacityHistory.at(-1); } -function getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - capacity = DEFAULT_CAPACITY, - variationPercent, - variationPercentUntil, -}) { +function getCapacityAndErrorRateHistory({ allAnswers, challenges, capacity = DEFAULT_CAPACITY, variationPercent }) { let latestCapacity = capacity; let likelihood = samples.map(() => DEFAULT_PROBABILITY_TO_ANSWER); @@ -83,11 +70,6 @@ function getCapacityAndErrorRateHistory({ while (answerIndex < allAnswers.length) { answer = allAnswers[answerIndex]; - const variationPercentForCurrentAnswer = _defineVariationPercentForCurrentAnswer( - variationPercent, - variationPercentUntil, - answerIndex, - ); ({ latestCapacity, likelihood, normalizedPosteriori } = _singleMeasure({ challenges, @@ -95,7 +77,7 @@ function getCapacityAndErrorRateHistory({ latestCapacity, likelihood, normalizedPosteriori, - variationPercent: variationPercentForCurrentAnswer, + variationPercent, })); answerIndex++; @@ -110,14 +92,6 @@ function getCapacityAndErrorRateHistory({ return capacityHistory; } -function _defineVariationPercentForCurrentAnswer(variationPercent, variationPercentUntil, answerIndex) { - if (!variationPercentUntil) { - return variationPercent; - } - - return variationPercentUntil >= answerIndex ? variationPercent : undefined; -} - function _singleMeasure({ challenges, answer, latestCapacity, likelihood, normalizedPosteriori, variationPercent }) { const answeredChallenge = _findChallengeForAnswer(challenges, answer); diff --git a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js index 43aae7d7267..a95abd09832 100644 --- a/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js +++ b/api/src/certification/flash-certification/infrastructure/serializers/flash-algorithm-configuration-serializer.js @@ -9,7 +9,6 @@ const serialize = function ({ flashAlgorithmConfiguration }) { 'limitToOneQuestionPerTube', 'enablePassageByAllCompetences', 'variationPercent', - 'variationPercentUntil', ]; return new Serializer('flash-algorithm-configurations', { transform(config) { diff --git a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js index db2d3e887da..acff170d980 100644 --- a/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js +++ b/api/src/certification/shared/domain/models/FlashAssessmentAlgorithmConfiguration.js @@ -7,7 +7,6 @@ import { config } from '../../../../shared/config.js'; * @param flashImplementation - the flash algorithm implementation * @param enablePassageByAllCompetences - enable or disable the passage through all competences * @param variationPercent - maximum variation of estimated level between two answers - * @param variationPercentUntil - maximum variation of estimated level between two answers for a specified number of challenges */ export class FlashAssessmentAlgorithmConfiguration { constructor({ @@ -16,7 +15,6 @@ export class FlashAssessmentAlgorithmConfiguration { limitToOneQuestionPerTube = false, enablePassageByAllCompetences = false, variationPercent, - variationPercentUntil, createdAt, } = {}) { this.maximumAssessmentLength = maximumAssessmentLength; @@ -24,7 +22,6 @@ export class FlashAssessmentAlgorithmConfiguration { this.limitToOneQuestionPerTube = limitToOneQuestionPerTube; this.enablePassageByAllCompetences = enablePassageByAllCompetences; this.variationPercent = variationPercent; - this.variationPercentUntil = variationPercentUntil; this.createdAt = createdAt; } @@ -35,7 +32,6 @@ export class FlashAssessmentAlgorithmConfiguration { limitToOneQuestionPerTube: this.limitToOneQuestionPerTube, enablePassageByAllCompetences: this.enablePassageByAllCompetences, variationPercent: this.variationPercent, - variationPercentUntil: this.variationPercentUntil, createdAt: this.createdAt, }; } @@ -46,7 +42,6 @@ export class FlashAssessmentAlgorithmConfiguration { limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, - variationPercentUntil, createdAt, }) { return new FlashAssessmentAlgorithmConfiguration({ @@ -55,7 +50,6 @@ export class FlashAssessmentAlgorithmConfiguration { limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, - variationPercentUntil, createdAt, }); } diff --git a/api/tests/certification/evaluation/unit/domain/services/scoring/scoring-v3_test.js b/api/tests/certification/evaluation/unit/domain/services/scoring/scoring-v3_test.js index 3c831bd3d98..850b6f5a05e 100644 --- a/api/tests/certification/evaluation/unit/domain/services/scoring/scoring-v3_test.js +++ b/api/tests/certification/evaluation/unit/domain/services/scoring/scoring-v3_test.js @@ -173,7 +173,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -185,7 +184,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -287,7 +285,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -300,7 +297,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -392,7 +388,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -404,7 +399,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -545,7 +539,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -557,7 +550,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -659,7 +651,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -671,7 +662,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -779,7 +769,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -791,7 +780,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -897,7 +885,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -909,7 +896,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -1020,7 +1006,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -1031,7 +1016,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -1142,7 +1126,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -1154,7 +1137,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -1263,7 +1245,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -1275,7 +1256,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { @@ -1379,7 +1359,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: expectedCapacity, @@ -1391,7 +1370,6 @@ describe('Certification | Shared | Unit | Domain | Services | Scoring V3', funct allAnswers: answers, capacity: sinon.match.number, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns([ { diff --git a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js index cc97352e053..415e3b00037 100644 --- a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js +++ b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js @@ -103,7 +103,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { challenges: [nextChallengeToAnswer], capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: 0 }); @@ -194,7 +193,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { challenges: [nextChallengeToAnswer, accessibleChallenge], capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: 0 }); @@ -353,7 +351,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { challenges: [alreadyAnsweredChallenge, outdatedChallenge, nextChallengeToAnswer], capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: 0 }); @@ -436,7 +433,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { challenges: [nextChallenge], capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: 0 }); @@ -538,7 +534,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { challenges: [challengeWithOtherSkill], capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: 0 }); @@ -707,7 +702,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { challenges: [nextChallengeToAnswer], capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: configuration.variationPercent, - variationPercentUntil: undefined, }) .returns({ capacity: 0 }); diff --git a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index 1d0b8a2d6fe..bbc514883b8 100644 --- a/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/flash-certification/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -9,7 +9,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, - variationPercentUntil: 3, limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -25,7 +24,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, variationPercent: 4, - variationPercentUntil: 3, }); }); @@ -35,7 +33,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, - variationPercentUntil: 3, limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -51,7 +48,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, variationPercent: 4, - variationPercentUntil: 3, }); }); @@ -61,7 +57,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, - variationPercentUntil: 3, limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -77,7 +72,6 @@ describe('Certification | Flash-certification | Integration | Infrastructure | R limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, variationPercent: 4, - variationPercentUntil: 3, }); }); }); diff --git a/api/tests/certification/flash-certification/unit/domain/services/algorithm-methods/flash_test.js b/api/tests/certification/flash-certification/unit/domain/services/algorithm-methods/flash_test.js index f6db2943e2d..2678f9a2ca6 100644 --- a/api/tests/certification/flash-certification/unit/domain/services/algorithm-methods/flash_test.js +++ b/api/tests/certification/flash-certification/unit/domain/services/algorithm-methods/flash_test.js @@ -370,14 +370,12 @@ describe('Integration | Domain | Algorithm-methods | Flash', function () { const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id })]; const variationPercent = 0.5; - const variationPercentUntil = 1; // when const { capacity } = flash.getCapacityAndErrorRate({ allAnswers, challenges, variationPercent, - variationPercentUntil, }); // then @@ -398,14 +396,12 @@ describe('Integration | Domain | Algorithm-methods | Flash', function () { const allAnswers = [domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id })]; const variationPercent = 0.5; - const variationPercentUntil = 1; // when const { capacity } = flash.getCapacityAndErrorRate({ allAnswers, challenges, variationPercent, - variationPercentUntil, }); // then @@ -500,179 +496,85 @@ describe('Integration | Domain | Algorithm-methods | Flash', function () { }); describe('when limiting the capacity variation', function () { - describe('when limiting to a given number of challenges', function () { - describe('when giving right answers', function () { - it('should return the limited capacities for the correct number of challenges', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.056, - difficulty: 0.6973893, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.5689203, - difficulty: 1.36973893, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), - ]; - - const variationPercent = 0.5; - const variationPercentUntil = 1; - - // when - const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - variationPercent, - variationPercentUntil, - }); - - // then - const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); - expect(capacities).to.deep.equal([0.5, 0.75, 1.7005749291039245]); - }); - }); + describe('when giving right answers', function () { + it('should return the unlimited capacities for all challenges', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), + + domainBuilder.buildChallenge({ + discriminant: 2.056, + difficulty: 0.6973893, + }), - describe('when giving wrong answers', function () { - it('should return the limited capacities for the correct number of challenges', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.056, - difficulty: 0.6973893, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.5689203, - difficulty: 1.36973893, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[2].id }), - ]; - - const variationPercent = 0.5; - const variationPercentUntil = 1; - - // when - const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - variationPercent, - variationPercentUntil, - }); - - // then - const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); - expect(capacities).to.deep.equal([-0.5, -0.75, -1.5100020666768261]); + domainBuilder.buildChallenge({ + discriminant: 2.5689203, + difficulty: 1.36973893, + }), + ]; + + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), + ]; + + const variationPercent = 0.5; + + // when + const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ + allAnswers, + challenges, + variationPercent, }); + + // then + const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); + expect(capacities).to.deep.equal([0.5, 0.75, 1.125]); }); }); - describe('when not limiting to a number of challenges', function () { - describe('when giving right answers', function () { - it('should return the unlimited capacities for all challenges', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.056, - difficulty: 0.6973893, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.5689203, - difficulty: 1.36973893, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.OK, challengeId: challenges[2].id }), - ]; - - const variationPercent = 0.5; - const variationPercentUntil = null; - - // when - const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - variationPercent, - variationPercentUntil, - }); - - // then - const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); - expect(capacities).to.deep.equal([0.5, 0.75, 1.125]); - }); - }); + describe('when giving wrong answers', function () { + it('should return the unlimited capacities for all challenges', function () { + // given + const challenges = [ + domainBuilder.buildChallenge({ + discriminant: 1.86350005965093, + difficulty: 0.194712138508747, + }), + + domainBuilder.buildChallenge({ + discriminant: 2.056, + difficulty: 0.6973893, + }), - describe('when giving wrong answers', function () { - it('should return the unlimited capacities for all challenges', function () { - // given - const challenges = [ - domainBuilder.buildChallenge({ - discriminant: 1.86350005965093, - difficulty: 0.194712138508747, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.056, - difficulty: 0.6973893, - }), - - domainBuilder.buildChallenge({ - discriminant: 2.5689203, - difficulty: 1.36973893, - }), - ]; - - const allAnswers = [ - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[1].id }), - domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[2].id }), - ]; - - const variationPercent = 0.5; - const variationPercentUntil = null; - - // when - const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ - allAnswers, - challenges, - variationPercent, - variationPercentUntil, - }); - - // then - const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); - expect(capacities).to.deep.equal([-0.5, -0.75, -1.125]); + domainBuilder.buildChallenge({ + discriminant: 2.5689203, + difficulty: 1.36973893, + }), + ]; + + const allAnswers = [ + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[0].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[1].id }), + domainBuilder.buildAnswer({ result: AnswerStatus.KO, challengeId: challenges[2].id }), + ]; + + const variationPercent = 0.5; + + // when + const capacityAndErrorRateHistory = flash.getCapacityAndErrorRateHistory({ + allAnswers, + challenges, + variationPercent, }); + + // then + const capacities = capacityAndErrorRateHistory.map(({ capacity }) => capacity); + expect(capacities).to.deep.equal([-0.5, -0.75, -1.125]); }); }); }); diff --git a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js index 43cea75613b..0fbbeac3108 100644 --- a/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js +++ b/api/tests/certification/flash-certification/unit/infrastructure/serializers/flash-algorithm-configuration-serializer_test.js @@ -14,7 +14,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori 'maximum-assessment-length': 3, 'challenges-between-same-competence': 4, 'variation-percent': 6, - 'variation-percent-until': 7, 'limit-to-one-question-per-tube': false, 'enable-passage-by-all-competences': true, }, @@ -25,7 +24,6 @@ describe('Unit | Certification | flash-certification | Serializer | flash-algori maximumAssessmentLength: 3, challengesBetweenSameCompetence: 4, variationPercent: 6, - variationPercentUntil: 7, limitToOneQuestionPerTube: false, enablePassageByAllCompetences: true, }); diff --git a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js index 1866986e956..b27f341bdec 100644 --- a/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js +++ b/api/tests/certification/scoring/integration/application/services/scoring-degradation-service_test.js @@ -14,7 +14,6 @@ describe('Integration | Domain | services | scoringDegradationService', function limitToOneQuestionPerTube: false, enablePassageByAllCompetences: false, variationPercent: null, - variationPercentUntil: null, createdAt: new Date('2020-01-01T00:00:00Z'), }); diff --git a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js index ac0cd818957..87cb2c7ce03 100644 --- a/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js +++ b/api/tests/certification/shared/integration/infrastructure/repositories/flash-algorithm-configuration-repository_test.js @@ -14,7 +14,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, - variationPercentUntil: 3, limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, }); @@ -40,7 +39,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, - variationPercentUntil: 3, limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, createdAt: new Date('2021-01-01'), @@ -50,7 +48,6 @@ describe('Certification | Shared | Integration | Infrastructure | Repository | F maximumAssessmentLength: 2, challengesBetweenSameCompetence: 3, variationPercent: 4, - variationPercentUntil: 3, limitToOneQuestionPerTube: true, enablePassageByAllCompetences: false, createdAt: new Date('2020-01-01'), diff --git a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js index cc234ead5a3..043a82b7558 100644 --- a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js +++ b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js @@ -255,6 +255,5 @@ const _getAlgorithmConfig = (options) => { const _getCapacityAndErrorRateParams = (params) => ({ variationPercent: undefined, - variationPercentUntil: undefined, ...params, }); diff --git a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js index c225c546f86..b4e95856513 100644 --- a/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js +++ b/api/tests/tooling/domain-builder/factory/build-flash-algorithm-configuration.js @@ -6,7 +6,6 @@ export const buildFlashAlgorithmConfiguration = ({ limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, - variationPercentUntil, createdAt, } = {}) => { return new FlashAssessmentAlgorithmConfiguration({ @@ -15,7 +14,6 @@ export const buildFlashAlgorithmConfiguration = ({ limitToOneQuestionPerTube, enablePassageByAllCompetences, variationPercent, - variationPercentUntil, createdAt, }); }; diff --git a/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js b/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js index 2073fad09bb..05667019890 100644 --- a/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js +++ b/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js @@ -152,7 +152,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge-for-campaign-assessment allAnswers, capacity: config.v3Certification.defaultCandidateCapacity, variationPercent: undefined, - variationPercentUntil: undefined, }) .returns({ capacity: 0, From 61b4b557b29d1f52d11eb83e4e6c88f57eab9c47 Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 28 Nov 2024 17:48:21 +0100 Subject: [PATCH 7/8] refactor(api): remove unused options param from getPossibleNextChallenges --- .../domain/models/FlashAssessmentAlgorithm.js | 4 ---- .../domain/services/algorithm-methods/flash.js | 15 ++++++--------- .../domain/usecases/get-next-challenge_test.js | 6 ------ .../models/FlashAssessmentAlgorithm_test.js | 7 ------- ...next-challenge-for-campaign-assessment_test.js | 2 -- 5 files changed, 6 insertions(+), 28 deletions(-) diff --git a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js index 93e4c4abb73..84533ffdad9 100644 --- a/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js +++ b/api/src/certification/flash-certification/domain/models/FlashAssessmentAlgorithm.js @@ -57,10 +57,6 @@ class FlashAssessmentAlgorithm { return this.flashAlgorithmImplementation.getPossibleNextChallenges({ availableChallenges: challengesAfterRulesApplication, capacity, - options: { - challengesBetweenSameCompetence: this._configuration.challengesBetweenSameCompetence, - minimalSuccessRate: 0, - }, }); } diff --git a/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js b/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js index ac92a207192..3417b2d19ff 100644 --- a/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js +++ b/api/src/certification/flash-certification/domain/services/algorithm-methods/flash.js @@ -24,11 +24,7 @@ export { getReward, }; -function getPossibleNextChallenges({ - availableChallenges, - capacity = DEFAULT_CAPACITY, - options: { minimalSuccessRate = 0 } = {}, -} = {}) { +function getPossibleNextChallenges({ availableChallenges, capacity = DEFAULT_CAPACITY } = {}) { const challengesWithReward = availableChallenges.map((challenge) => { return { challenge, @@ -40,7 +36,7 @@ function getPossibleNextChallenges({ }; }); - return _findBestPossibleChallenges(challengesWithReward, minimalSuccessRate, capacity); + return _findBestPossibleChallenges(challengesWithReward, capacity); } function getCapacityAndErrorRate({ allAnswers, challenges, capacity = DEFAULT_CAPACITY, variationPercent }) { @@ -177,8 +173,9 @@ function _limitCapacityVariation(previousCapacity, nextCapacity, variationPercen : Math.max(nextCapacity, previousCapacity - gap); } -function _findBestPossibleChallenges(challengesWithReward, minimumSuccessRate, capacity) { - const hasMinimumSuccessRate = ({ challenge }) => { +function _findBestPossibleChallenges(challengesWithReward, capacity) { + const canChallengeBeSuccessful = ({ challenge }) => { + const minimumSuccessRate = 0; const successProbability = _getProbability(capacity, challenge.discriminant, challenge.difficulty); return successProbability >= minimumSuccessRate; @@ -186,7 +183,7 @@ function _findBestPossibleChallenges(challengesWithReward, minimumSuccessRate, c const orderedChallengesWithReward = orderBy( challengesWithReward, - [hasMinimumSuccessRate, 'reward'], + [canChallengeBeSuccessful, 'reward'], ['desc', 'desc'], ); diff --git a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js index 415e3b00037..214389b9bea 100644 --- a/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js +++ b/api/tests/certification/evaluation/unit/domain/usecases/get-next-challenge_test.js @@ -110,7 +110,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { .withArgs({ availableChallenges: [nextChallengeToAnswer], capacity: 0, - options: sinon.match.any, }) .returns([nextChallengeToAnswer]); @@ -200,7 +199,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { .withArgs({ availableChallenges: [nextChallengeToAnswer, accessibleChallenge], capacity: 0, - options: sinon.match.any, }) .returns([nextChallengeToAnswer]); @@ -358,7 +356,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { .withArgs({ availableChallenges: [nextChallengeToAnswer], capacity: 0, - options: sinon.match.any, }) .returns([nextChallengeToAnswer]); @@ -440,7 +437,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { .withArgs({ availableChallenges: [nextChallenge], capacity: 0, - options: sinon.match.any, }) .returns([nextChallenge]); @@ -541,7 +537,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { .withArgs({ availableChallenges: [challengeWithOtherSkill], capacity: 0, - options: sinon.match.any, }) .returns([challengeWithOtherSkill]); @@ -709,7 +704,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge', function () { .withArgs({ availableChallenges: [nextChallengeToAnswer], capacity: 0, - options: sinon.match.any, }) .returns([nextChallengeToAnswer]); diff --git a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js index 043a82b7558..db7ffa7ed36 100644 --- a/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js +++ b/api/tests/certification/shared/unit/domain/models/FlashAssessmentAlgorithm_test.js @@ -11,11 +11,6 @@ const baseFlashAssessmentAlgorithmConfig = { describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlgorithm', function () { let flashAlgorithmImplementation; - const baseGetNextChallengeOptions = { - challengesBetweenSameCompetence: 2, - minimalSuccessRate: 0, - }; - beforeEach(function () { flashAlgorithmImplementation = { getPossibleNextChallenges: sinon.stub(), @@ -156,7 +151,6 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg .withArgs({ availableChallenges: expectedChallenges, capacity: computedCapacity, - options: baseGetNextChallengeOptions, }) .returns(expectedChallenges); @@ -233,7 +227,6 @@ describe('Unit | Domain | Models | FlashAssessmentAlgorithm | FlashAssessmentAlg .withArgs({ availableChallenges: expectedChallenges, capacity: computedCapacity, - options: baseGetNextChallengeOptions, }) .returns(expectedChallenges); diff --git a/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js b/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js index 05667019890..829184f85f2 100644 --- a/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js +++ b/api/tests/unit/domain/usecases/get-next-challenge-for-campaign-assessment_test.js @@ -162,7 +162,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge-for-campaign-assessment .withArgs({ availableChallenges: [secondChallenge], capacity: 0, - options: sinon.match.object, }) .returns([secondChallenge]); @@ -273,7 +272,6 @@ describe('Unit | Domain | Use Cases | get-next-challenge-for-campaign-assessment .withArgs({ challenges, capacity: 0, - options: sinon.match.object, }) .returns({ hasAssessmentEnded: false, From 4143c8f84f99a31411e9330e58490bc9be2c85fc Mon Sep 17 00:00:00 2001 From: Alexandre COIN Date: Thu, 28 Nov 2024 16:30:25 +0100 Subject: [PATCH 8/8] tech(api): remove unused columns in flash-algo-configurations table --- ...in-flash-algorithm-configurations-table.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 api/db/migrations/20241128152506_remove-unused-columns-in-flash-algorithm-configurations-table.js diff --git a/api/db/migrations/20241128152506_remove-unused-columns-in-flash-algorithm-configurations-table.js b/api/db/migrations/20241128152506_remove-unused-columns-in-flash-algorithm-configurations-table.js new file mode 100644 index 00000000000..2b8dc8c8869 --- /dev/null +++ b/api/db/migrations/20241128152506_remove-unused-columns-in-flash-algorithm-configurations-table.js @@ -0,0 +1,29 @@ +const TABLE_NAME = 'flash-algorithm-configurations'; +const WARM_UP_LENGTH_COLUMN_NAME = 'warmUpLength'; +const FORCED_COMPETENCES_COLUMN_NAME = 'forcedCompetences'; +const MINIMUM_ESTIMATED_SUCCESS_RATE_RANGES_COLUMN_NAME = 'minimumEstimatedSuccessRateRanges'; +const DOUBLE_MEASURES_UNTIL_COLUMN_NAME = 'doubleMeasuresUntil'; +const VARIATION_PERCENT_UNTIL_COLUMN_NAME = 'variationPercentUntil'; + +const up = function (knex) { + return knex.schema.table(TABLE_NAME, (table) => { + table.dropColumn(WARM_UP_LENGTH_COLUMN_NAME); + table.dropColumn(FORCED_COMPETENCES_COLUMN_NAME); + table.dropColumn(MINIMUM_ESTIMATED_SUCCESS_RATE_RANGES_COLUMN_NAME); + table.dropColumn(DOUBLE_MEASURES_UNTIL_COLUMN_NAME); + table.dropColumn(VARIATION_PERCENT_UNTIL_COLUMN_NAME); + table.comment(`Configuration parameters used to alter the behaviour of the flash algorithm.`); + }); +}; + +const down = function (knex) { + return knex.schema.table(TABLE_NAME, (table) => { + table.integer(WARM_UP_LENGTH_COLUMN_NAME); + table.jsonb(FORCED_COMPETENCES_COLUMN_NAME); + table.jsonb(MINIMUM_ESTIMATED_SUCCESS_RATE_RANGES_COLUMN_NAME); + table.integer(DOUBLE_MEASURES_UNTIL_COLUMN_NAME); + table.integer(VARIATION_PERCENT_UNTIL_COLUMN_NAME); + }); +}; + +export { down, up };