Skip to content

Commit

Permalink
refactor(api): remove limitToOneQuestionPerTube parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrecoin authored Nov 21, 2024
1 parent 99e2c1a commit 639fde0
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ async function simulateFlashAssessmentScenario(
numberOfIterations = 1,
challengePickProbability,
challengesBetweenSameCompetence,
limitToOneQuestionPerTube,
minimumEstimatedSuccessRateRanges: minimumEstimatedSuccessRateRangesDto,
variationPercent,
capacity,
Expand All @@ -53,7 +52,6 @@ async function simulateFlashAssessmentScenario(
locale,
initialCapacity,
challengesBetweenSameCompetence,
limitToOneQuestionPerTube,
minimumEstimatedSuccessRateRanges,
variationPercent,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const _baseScenarioParametersValidator = Joi.object().keys({
numberOfIterations: Joi.number().integer().min(0),
challengePickProbability: Joi.number().min(0).max(100),
challengesBetweenSameCompetence: Joi.number().min(0),
limitToOneQuestionPerTube: Joi.boolean(),
minimumEstimatedSuccessRateRanges: Joi.array().items(_successRatesConfigurationValidator),
variationPercent: Joi.number().min(0).max(1),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export async function simulateFlashAssessmentScenario({
pickAnswerStatus,
initialCapacity,
challengesBetweenSameCompetence = 0,
limitToOneQuestionPerTube = true,
minimumEstimatedSuccessRateRanges = [],
variationPercent,
challengeRepository,
Expand All @@ -23,7 +22,7 @@ export async function simulateFlashAssessmentScenario({
const flashAssessmentAlgorithm = new FlashAssessmentAlgorithm({
flashAlgorithmImplementation: flashAlgorithmService,
configuration: new FlashAssessmentAlgorithmConfiguration({
limitToOneQuestionPerTube,
limitToOneQuestionPerTube: configurationUsedInProduction.limitToOneQuestionPerTube,
minimumEstimatedSuccessRateRanges,
enablePassageByAllCompetences: configurationUsedInProduction.enablePassageByAllCompetences,
variationPercent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,65 +175,6 @@ describe('Integration | Application | scenario-simulator-controller', function (
});
});

context('When configuring the limit of challenges per tube', function () {
it('should call simulateFlashAssessmentScenario usecase with correct arguments', async function () {
// given
const limitToOneQuestionPerTube = true;

const pickChallengeImplementation = sinon.stub();
pickChallengeService.chooseNextChallenge.withArgs().returns(pickChallengeImplementation);
const pickAnswerStatusForCapacityImplementation = sinon.stub();
pickAnswerStatusService.pickAnswerStatusForCapacity
.withArgs(6)
.returns(pickAnswerStatusForCapacityImplementation);

usecases.simulateFlashAssessmentScenario
.withArgs({
pickAnswerStatus: pickAnswerStatusForCapacityImplementation,
locale: 'en',
pickChallenge: pickChallengeImplementation,
initialCapacity,
limitToOneQuestionPerTube,
})
.resolves(simulationResults);
securityPreHandlers.checkAdminMemberHasRoleSuperAdmin.returns(() => true);

// when
const response = await httpTestServer.request(
'POST',
'/api/scenario-simulator',
{
initialCapacity,
capacity: 6,
limitToOneQuestionPerTube,
},
null,
{ 'accept-language': 'en' },
);

// then
expect(response.statusCode).to.equal(200);
const parsedResult = parseJsonStream(response);
expect(parsedResult).to.deep.equal([
{
index: 0,
simulationReport: [
{
challengeId: challenge1.id,
errorRate: errorRate1,
capacity: capacity1,
minimumCapability: 0.6190392084062237,
answerStatus: 'ok',
reward: reward1,
difficulty: challenge1.difficulty,
discriminant: challenge1.discriminant,
},
],
},
]);
});
});

context('When configuring the minimum success rates', function () {
context('When providing valid parameters', function () {
it('should call simulateFlashAssessmentScenario usecase with correct arguments', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {
pickAnswerStatus,
initialCapacity,
flashAlgorithmService,
limitToOneQuestionPerTube: false,
});

// then
Expand All @@ -97,8 +96,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {
context('when we don‘t limit the number of challenges per tube', function () {
it('should return an array of estimated level, challenge, reward and error rate for each answer', async function () {
// given
const limitToOneQuestionPerTube = false;

const {
challengeRepository,
sharedFlashAlgorithmConfigurationRepository,
Expand All @@ -107,9 +104,7 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {
flashAlgorithmService: baseFlashAlgorithmService,
getNextChallengesOptionsMatcher,
allChallenges,
} = prepareStubs({
limitToOneQuestionPerTube,
});
} = prepareStubs();

const flashAlgorithmService = {
...baseFlashAlgorithmService,
Expand Down Expand Up @@ -144,7 +139,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {
locale,
pickChallenge,
pickAnswerStatus,
limitToOneQuestionPerTube,
flashAlgorithmService,
});

Expand All @@ -163,7 +157,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {
context('when we set a minimum estimated success rate range', function () {
it('should return an array of estimated level, challenge, reward and error rate for each answer', async function () {
// given
const limitToOneQuestionPerTube = false;
const minimumEstimatedSuccessRateRanges = [
domainBuilder.buildFlashAssessmentAlgorithmSuccessRateHandlerFixed({
startingChallengeIndex: 0,
Expand Down Expand Up @@ -191,7 +184,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {
pickAnswerStatus,
minimumEstimatedSuccessRateRanges,
flashAlgorithmService,
limitToOneQuestionPerTube,
});

// then
Expand All @@ -210,7 +202,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {
context('when there are not enough flash challenges left', function () {
it('should stop simulating', async function () {
// given
const limitToOneQuestionPerTube = false;
const challenge = domainBuilder.buildChallenge({ id: 1 });
const challengeRepository = {
findActiveFlashCompatible: sinon.stub(),
Expand Down Expand Up @@ -266,7 +257,6 @@ describe('Unit | UseCase | simulate-flash-assessment-scenario', function () {
pickChallenge,
pickAnswerStatus,
flashAlgorithmService,
limitToOneQuestionPerTube,
});

// then
Expand Down Expand Up @@ -336,6 +326,7 @@ function prepareStubs({
sharedFlashAlgorithmConfigurationRepository.getMostRecent.resolves({
enablePassageByAllCompetences: true,
maximumAssessmentLength: 3,
limitToOneQuestionPerTube: false,
});

flashAlgorithmService.getCapacityAndErrorRate
Expand Down

0 comments on commit 639fde0

Please sign in to comment.