Skip to content

Commit

Permalink
refactor(api): remove variationPercentUntil parameter from flash algo…
Browse files Browse the repository at this point in the history
…rithm
  • Loading branch information
alexandrecoin committed Nov 28, 2024
1 parent dd10148 commit d01154d
Show file tree
Hide file tree
Showing 24 changed files with 77 additions and 281 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ import { t } from 'ember-intl';
<:label>{{t "pages.administration.certification.flash-algorithm-configuration.form.variationPercent"}}</:label>
</PixInput>

<PixInput
{{on "input" @updateNumberValues}}
@id="variationPercentUntil"
@value={{@form.variationPercentUntil}}
type="number"
min="0"
>
<:label>{{t
"pages.administration.certification.flash-algorithm-configuration.form.variationPercentUntil"
}}</:label>
</PixInput>

<PixCheckbox
{{on "input" @updateCheckboxValues}}
@id="limitToOneQuestionPerTube"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default class FlashAlgorithmConfiguration extends Component {
maximumAssessmentLength: this.args.model.maximumAssessmentLength,
challengesBetweenSameCompetence: this.args.model.challengesBetweenSameCompetence,
variationPercent: this.args.model.variationPercent,
variationPercentUntil: this.args.model.variationPercentUntil,
limitToOneQuestionPerTube: this.args.model.limitToOneQuestionPerTube,
enablePassageByAllCompetences: this.args.model.enablePassageByAllCompetences,
};
Expand Down
1 change: 0 additions & 1 deletion admin/app/models/flash-algorithm-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default class FlashAlgorithmConfiguration extends Model {
@attr('number') maximumAssessmentLength;
@attr('number') challengesBetweenSameCompetence;
@attr('number') variationPercent;
@attr('number') variationPercentUntil;
@attr('boolean') limitToOneQuestionPerTube;
@attr('boolean') enablePassageByAllCompetences;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module('Integration | Component | administration/certification/flash-algorithm-
maximumAssessmentLength: 1,
challengesBetweenSameCompetence: 3,
variationPercent: 4,
variationPercentUntil: 5,
limitToOneQuestionPerTube: true,
enablePassageByAllCompetences: false,
};
Expand All @@ -33,9 +32,6 @@ module('Integration | Component | administration/certification/flash-algorithm-
const variationPercent = await screen.getByRole('spinbutton', {
name: t('pages.administration.certification.flash-algorithm-configuration.form.variationPercent'),
}).value;
const variationPercentUntil = await screen.getByRole('spinbutton', {
name: t('pages.administration.certification.flash-algorithm-configuration.form.variationPercentUntil'),
}).value;
const limitToOneQuestionPerTube = await screen.getByRole('checkbox', {
name: t('pages.administration.certification.flash-algorithm-configuration.form.limitToOneQuestionPerTube'),
}).checked;
Expand All @@ -46,7 +42,6 @@ module('Integration | Component | administration/certification/flash-algorithm-
assert.strictEqual(maximumAssessmentLength, '1');
assert.strictEqual(challengesBetweenSameCompetence, '3');
assert.strictEqual(variationPercent, '4');
assert.strictEqual(variationPercentUntil, '5');
assert.true(limitToOneQuestionPerTube);
assert.false(enablePassageByAllCompetences);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module('Unit | Component | authenticated/certifications/flash-algorithm-configur
maximumAssessmentLength: 0,
challengesBetweenSameCompetence: 2,
variationPercent: 3,
variationPercentUntil: 4,
limitToOneQuestionPerTube: true,
enablePassageByAllCompetences: true,
};
Expand Down Expand Up @@ -72,7 +71,6 @@ module('Unit | Component | authenticated/certifications/flash-algorithm-configur
maximumAssessmentLength: 0,
challengesBetweenSameCompetence: 2,
variationPercent: 3,
variationPercentUntil: 4,
limitToOneQuestionPerTube: true,
enablePassageByAllCompetences: true,
};
Expand Down
3 changes: 1 addition & 2 deletions admin/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@
"enablePassageByAllCompetences": "Forcer le passage par les 16 compétences",
"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é"
"variationPercent": "Capage de la capacité (en % )"
}
},
"sco-whitelist": {
Expand Down
3 changes: 1 addition & 2 deletions admin/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@
"enablePassageByAllCompetences": "Forcer le passage par les 16 compétences",
"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é"
"variationPercent": "Capage de la capacité (en % )"
}
},
"sco-whitelist": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const buildFlashAlgorithmConfiguration = function ({
limitToOneQuestionPerTube = null,
enablePassageByAllCompetences = false,
variationPercent = null,
variationPercentUntil = null,
createdAt = new Date(),
} = {}) {
const values = {
Expand All @@ -16,7 +15,6 @@ const buildFlashAlgorithmConfiguration = function ({
limitToOneQuestionPerTube,
enablePassageByAllCompetences,
variationPercent,
variationPercentUntil,
createdAt,
};

Expand Down
1 change: 0 additions & 1 deletion api/db/seeds/data/team-certification/data-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function _createV3CertificationConfiguration({ databaseBuilder }) {
limitToOneQuestionPerTube: true,
enablePassageByAllCompetences: true,
variationPercent: 0.5,
variationPercentUntil: null,
createdAt: new Date('1977-10-19'),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const register = async (server) => {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class FlashAssessmentAlgorithm {
challenges,
capacity: initialCapacity,
variationPercent: this._configuration.variationPercent,
variationPercentUntil: this._configuration.variationPercentUntil,
});
}

Expand All @@ -103,7 +102,6 @@ class FlashAssessmentAlgorithm {
challenges,
capacity: initialCapacity,
variationPercent: this._configuration.variationPercent,
variationPercentUntil: this._configuration.variationPercentUntil,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand All @@ -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);
Expand All @@ -83,19 +70,14 @@ function getCapacityAndErrorRateHistory({

while (answerIndex < allAnswers.length) {
answer = allAnswers[answerIndex];
const variationPercentForCurrentAnswer = _defineVariationPercentForCurrentAnswer(
variationPercent,
variationPercentUntil,
answerIndex,
);

({ latestCapacity, likelihood, normalizedPosteriori } = _singleMeasure({
challenges,
answer,
latestCapacity,
likelihood,
normalizedPosteriori,
variationPercent: variationPercentForCurrentAnswer,
variationPercent,
}));

answerIndex++;
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const serialize = function ({ flashAlgorithmConfiguration }) {
'limitToOneQuestionPerTube',
'enablePassageByAllCompetences',
'variationPercent',
'variationPercentUntil',
];
return new Serializer('flash-algorithm-configurations', {
transform(config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -16,15 +15,13 @@ export class FlashAssessmentAlgorithmConfiguration {
limitToOneQuestionPerTube = false,
enablePassageByAllCompetences = false,
variationPercent,
variationPercentUntil,
createdAt,
} = {}) {
this.maximumAssessmentLength = maximumAssessmentLength;
this.challengesBetweenSameCompetence = challengesBetweenSameCompetence;
this.limitToOneQuestionPerTube = limitToOneQuestionPerTube;
this.enablePassageByAllCompetences = enablePassageByAllCompetences;
this.variationPercent = variationPercent;
this.variationPercentUntil = variationPercentUntil;
this.createdAt = createdAt;
}

Expand All @@ -35,7 +32,6 @@ export class FlashAssessmentAlgorithmConfiguration {
limitToOneQuestionPerTube: this.limitToOneQuestionPerTube,
enablePassageByAllCompetences: this.enablePassageByAllCompetences,
variationPercent: this.variationPercent,
variationPercentUntil: this.variationPercentUntil,
createdAt: this.createdAt,
};
}
Expand All @@ -46,7 +42,6 @@ export class FlashAssessmentAlgorithmConfiguration {
limitToOneQuestionPerTube,
enablePassageByAllCompetences,
variationPercent,
variationPercentUntil,
createdAt,
}) {
return new FlashAssessmentAlgorithmConfiguration({
Expand All @@ -55,7 +50,6 @@ export class FlashAssessmentAlgorithmConfiguration {
limitToOneQuestionPerTube,
enablePassageByAllCompetences,
variationPercent,
variationPercentUntil,
createdAt,
});
}
Expand Down
Loading

0 comments on commit d01154d

Please sign in to comment.