Skip to content

Commit

Permalink
refactor(api): remove stopAtChallenge parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrecoin authored Nov 21, 2024
1 parent fcd8150 commit 99e2c1a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ async function simulateFlashAssessmentScenario(
},
) {
const {
stopAtChallenge,
initialCapacity,
numberOfIterations = 1,
challengePickProbability,
Expand Down Expand Up @@ -52,7 +51,6 @@ async function simulateFlashAssessmentScenario(
pickAnswerStatus,
pickChallenge,
locale,
stopAtChallenge,
initialCapacity,
challengesBetweenSameCompetence,
limitToOneQuestionPerTube,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const _successRatesConfigurationValidator = Joi.object({

const _baseScenarioParametersValidator = Joi.object().keys({
initialCapacity: Joi.number().integer().min(-8).max(8),
stopAtChallenge: Joi.number().integer().min(0),
numberOfIterations: Joi.number().integer().min(0),
challengePickProbability: Joi.number().min(0).max(100),
challengesBetweenSameCompetence: Joi.number().min(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export async function simulateFlashAssessmentScenario({
locale,
pickChallenge,
pickAnswerStatus,
stopAtChallenge,
initialCapacity,
challengesBetweenSameCompetence = 0,
limitToOneQuestionPerTube = true,
Expand All @@ -31,7 +30,7 @@ export async function simulateFlashAssessmentScenario({
variationPercentUntil: undefined,
doubleMeasuresUntil: 0,
challengesBetweenSameCompetence,
maximumAssessmentLength: stopAtChallenge,
maximumAssessmentLength: configurationUsedInProduction.maximumAssessmentLength,
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@ const {
describe('Acceptance | Controller | scenario-simulator-controller', function () {
let server;
let adminAuthorization;
let validCapacityPayload;
let stopAtChallenge;
let validPayload;

beforeEach(async function () {
const { id: adminId } = databaseBuilder.factory.buildUser.withRole({
role: SUPER_ADMIN,
});

stopAtChallenge = databaseBuilder.factory.buildFlashAlgorithmConfiguration({
databaseBuilder.factory.buildFlashAlgorithmConfiguration({
maximumAssessmentLength: 2,
createdAt: new Date('2022-02-01'),
}).maximumAssessmentLength;
});

adminAuthorization = generateValidRequestAuthorizationHeader(adminId);
await databaseBuilder.commit();

validCapacityPayload = {
validPayload = {
capacity: 4.5,
stopAtChallenge,
};

const learningContent = {
Expand Down Expand Up @@ -151,10 +149,6 @@ describe('Acceptance | Controller | scenario-simulator-controller', function ()
describe('when a number of challenges to pass is specified', function () {
it('should return a payload with the same number of simulation scenario results', async function () {
// given
const validPayload = {
...validCapacityPayload,
stopAtChallenge,
};
options.headers.authorization = adminAuthorization;
options.payload = validPayload;

Expand All @@ -179,7 +173,7 @@ describe('Acceptance | Controller | scenario-simulator-controller', function ()
it('should return a payload with simulation the capacity scenario results', async function () {
// given
options.headers.authorization = adminAuthorization;
options.payload = validCapacityPayload;
options.payload = validPayload;

// when
const response = await server.inject(options);
Expand Down Expand Up @@ -209,7 +203,7 @@ describe('Acceptance | Controller | scenario-simulator-controller', function ()
const { id: userId } = databaseBuilder.factory.buildUser();
options.headers.authorization = generateValidRequestAuthorizationHeader(userId);
await databaseBuilder.commit();
options.payload = validCapacityPayload;
options.payload = validPayload;

// when
const response = await server.inject(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {

// when
const result = await simulateFlashAssessmentScenario({
stopAtChallenge: 3,
challengeRepository,
locale,
pickChallenge,
Expand Down Expand Up @@ -73,7 +72,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {

// when
const result = await simulateFlashAssessmentScenario({
stopAtChallenge: 3,
challengeRepository,
sharedFlashAlgorithmConfigurationRepository,
locale,
Expand Down Expand Up @@ -141,7 +139,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {

// when
const result = await simulateFlashAssessmentScenario({
stopAtChallenge: 3,
challengeRepository,
sharedFlashAlgorithmConfigurationRepository,
locale,
Expand Down Expand Up @@ -187,7 +184,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {

// when
const result = await simulateFlashAssessmentScenario({
stopAtChallenge: 3,
challengeRepository,
sharedFlashAlgorithmConfigurationRepository,
locale,
Expand Down Expand Up @@ -337,7 +333,10 @@ function prepareStubs({
),
);

sharedFlashAlgorithmConfigurationRepository.getMostRecent.resolves({ enablePassageByAllCompetences: true });
sharedFlashAlgorithmConfigurationRepository.getMostRecent.resolves({
enablePassageByAllCompetences: true,
maximumAssessmentLength: 3,
});

flashAlgorithmService.getCapacityAndErrorRate
.withArgs({
Expand Down

0 comments on commit 99e2c1a

Please sign in to comment.