From 0940df4e860271c381c095b9871b210870c634cd Mon Sep 17 00:00:00 2001 From: "matthieu.gros" Date: Wed, 7 Aug 2024 12:37:50 +0200 Subject: [PATCH 1/4] :sparkles: api: create migration to add accessibilityAdjustedCertificationNeeded column in certification-candidates table --- ..._needed_column_to_certification_candidates.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 api/db/migrations/20240807091800_add_accessibility_adjusted_certification_needed_column_to_certification_candidates.js diff --git a/api/db/migrations/20240807091800_add_accessibility_adjusted_certification_needed_column_to_certification_candidates.js b/api/db/migrations/20240807091800_add_accessibility_adjusted_certification_needed_column_to_certification_candidates.js new file mode 100644 index 00000000000..4b6a1373882 --- /dev/null +++ b/api/db/migrations/20240807091800_add_accessibility_adjusted_certification_needed_column_to_certification_candidates.js @@ -0,0 +1,16 @@ +const TABLE_NAME = 'certification-candidates'; +const COLUMN_NAME = 'accessibilityAdjustmentNeeded'; + +const up = async function (knex) { + await knex.schema.table(TABLE_NAME, function (table) { + table.boolean(COLUMN_NAME).defaultTo(false); + }); +}; + +const down = async function (knex) { + await knex.schema.table(TABLE_NAME, function (table) { + table.dropColumn(COLUMN_NAME); + }); +}; + +export { down, up }; From 8b6908ec5a13b9ae46cdb9646f59c2f947f35d07 Mon Sep 17 00:00:00 2001 From: "matthieu.gros" Date: Wed, 7 Aug 2024 14:42:09 +0200 Subject: [PATCH 2/4] :sparkles: api: add accessibilityAdjustedCertificationNeeded field in CertificationCandidate class --- api/src/shared/domain/models/CertificationCandidate.js | 3 +++ .../infrastructure/repositories/candidate-repository_test.js | 1 + .../domain-builder/factory/build-certification-candidate.js | 2 ++ api/tests/unit/domain/models/CertificationCandidate_test.js | 1 + 4 files changed, 7 insertions(+) diff --git a/api/src/shared/domain/models/CertificationCandidate.js b/api/src/shared/domain/models/CertificationCandidate.js index ece0c9771fa..79082f0b9d7 100644 --- a/api/src/shared/domain/models/CertificationCandidate.js +++ b/api/src/shared/domain/models/CertificationCandidate.js @@ -44,6 +44,7 @@ const certificationCandidateParticipationJoiSchema = Joi.object({ prepaymentCode: Joi.string().allow(null).optional(), subscriptions: Joi.array().items(subscriptionSchema).unique('type').required(), hasSeenCertificationInstructions: Joi.boolean().optional(), + accessibilityAdjustmentNeeded: Joi.boolean().optional(), }); class CertificationCandidate { @@ -78,6 +79,7 @@ class CertificationCandidate { prepaymentCode = null, subscriptions = [], hasSeenCertificationInstructions = false, + accessibilityAdjustmentNeeded = false, } = {}) { this.id = id; this.firstName = firstName; @@ -102,6 +104,7 @@ class CertificationCandidate { this.billingMode = billingMode; this.prepaymentCode = prepaymentCode; this.hasSeenCertificationInstructions = hasSeenCertificationInstructions; + this.accessibilityAdjustmentNeeded = accessibilityAdjustmentNeeded; Object.defineProperty(this, 'complementaryCertification', { enumerable: true, diff --git a/api/tests/certification/enrolment/integration/infrastructure/repositories/candidate-repository_test.js b/api/tests/certification/enrolment/integration/infrastructure/repositories/candidate-repository_test.js index 434864d615a..aeea84d7e79 100644 --- a/api/tests/certification/enrolment/integration/infrastructure/repositories/candidate-repository_test.js +++ b/api/tests/certification/enrolment/integration/infrastructure/repositories/candidate-repository_test.js @@ -151,6 +151,7 @@ describe('Integration | Certification | Session | Repository | Candidate', funct billingMode: null, prepaymentCode: null, hasSeenCertificationInstructions: false, + accessibilityAdjustmentNeeded: false, subscriptions: [ { type: SUBSCRIPTION_TYPES.CORE, diff --git a/api/tests/tooling/domain-builder/factory/build-certification-candidate.js b/api/tests/tooling/domain-builder/factory/build-certification-candidate.js index e9bf35802c9..1f9f604fd49 100644 --- a/api/tests/tooling/domain-builder/factory/build-certification-candidate.js +++ b/api/tests/tooling/domain-builder/factory/build-certification-candidate.js @@ -25,6 +25,7 @@ const buildCertificationCandidate = function ({ billingMode = null, prepaymentCode = null, subscriptions = [domainBuilder.buildCoreSubscription({ certificationCandidateId: 123 })], + accessibilityAdjustmentNeeded = false, } = {}) { return new CertificationCandidate({ id, @@ -50,6 +51,7 @@ const buildCertificationCandidate = function ({ billingMode, prepaymentCode, subscriptions, + accessibilityAdjustmentNeeded, }); }; diff --git a/api/tests/unit/domain/models/CertificationCandidate_test.js b/api/tests/unit/domain/models/CertificationCandidate_test.js index ff441f9338a..2b9fa8c7f47 100644 --- a/api/tests/unit/domain/models/CertificationCandidate_test.js +++ b/api/tests/unit/domain/models/CertificationCandidate_test.js @@ -48,6 +48,7 @@ describe('Unit | Domain | Models | Certification Candidate', function () { complementaryCertification: null, subscriptions: [coreSubscription], hasSeenCertificationInstructions: false, + accessibilityAdjustmentNeeded: false, }; }); From 28a8b5eab0a89f4c6dc6a558deeea9a482f2882a Mon Sep 17 00:00:00 2001 From: "matthieu.gros" Date: Wed, 7 Aug 2024 14:43:09 +0200 Subject: [PATCH 3/4] :sparkles: api: add at least one candidate that needs adjusted certification in a certification session v3 --- .../factory/build-certification-candidate.js | 3 +++ api/db/seeds/data/common/tooling/session-tooling.js | 8 ++++++++ api/db/seeds/data/team-certification/data-builder.js | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/db/database-builder/factory/build-certification-candidate.js b/api/db/database-builder/factory/build-certification-candidate.js index 6ed96478b28..062c2ed0423 100644 --- a/api/db/database-builder/factory/build-certification-candidate.js +++ b/api/db/database-builder/factory/build-certification-candidate.js @@ -27,6 +27,7 @@ const buildCertificationCandidate = function ({ billingMode = null, prepaymentCode = null, hasSeenCertificationInstructions = false, + accessibilityAdjustmentNeeded = false, } = {}) { sessionId = _.isUndefined(sessionId) ? buildSession().id : sessionId; userId = _.isUndefined(userId) ? buildUser().id : userId; @@ -54,6 +55,7 @@ const buildCertificationCandidate = function ({ billingMode, prepaymentCode, hasSeenCertificationInstructions, + accessibilityAdjustmentNeeded, }; databaseBuffer.pushInsertable({ @@ -84,6 +86,7 @@ const buildCertificationCandidate = function ({ billingMode, prepaymentCode, hasSeenCertificationInstructions, + accessibilityAdjustmentNeeded, }; }; diff --git a/api/db/seeds/data/common/tooling/session-tooling.js b/api/db/seeds/data/common/tooling/session-tooling.js index 4cb41c02b18..603166b5838 100644 --- a/api/db/seeds/data/common/tooling/session-tooling.js +++ b/api/db/seeds/data/common/tooling/session-tooling.js @@ -168,6 +168,7 @@ async function createDraftSession({ hasJoinSession: false, configSession, certificationCenterId, + version, }); await databaseBuilder.commit(); @@ -519,6 +520,7 @@ async function createPublishedSession({ hasJoinSession: true, configSession, certificationCenterId, + version, }); const { coreProfileData, complementaryCertificationsProfileData } = await _makeCandidatesCertifiable({ @@ -593,6 +595,7 @@ function _addCertificationCandidatesToScoSession( authorizedToStart: false, billingMode: null, prepaymentCode: null, + accessibilityAdjustmentNeeded: (version === 3 && accessibilityAdjustedCertificationNeeds[index]) ?? false, }); databaseBuilder.factory.buildCoreSubscription({ certificationCandidateId: candidate.id }); certificationCandidates.push(candidate); @@ -616,6 +619,7 @@ async function _registerCandidatesToSession({ hasJoinSession, configSession, certificationCenterId, + version, }) { const certificationCandidates = []; if (_hasCertificationCandidatesToRegister(configSession)) { @@ -634,6 +638,7 @@ async function _registerCandidatesToSession({ prepaymentCode: null, }, ]; + const accessibilityAdjustedCertificationNeeds = [true, false]; const complementaryCertificationIds = [null]; if (configSession.hasComplementaryCertificationsToRegister) { @@ -658,6 +663,8 @@ async function _registerCandidatesToSession({ billingModes[i % billingModes.length]; const randomExtraTimePercentage = extraTimePercentages[i % extraTimePercentages.length]; + const randomAccessibilityAdjustedCertificationNeeded = + (version === 3 && accessibilityAdjustedCertificationNeeds[i]) ?? false; const certificationCandidate = databaseBuilder.factory.buildCertificationCandidate({ firstName: `firstname${i}-${sessionId}`, @@ -678,6 +685,7 @@ async function _registerCandidatesToSession({ authorizedToStart: false, billingMode: randomBillingMode, prepaymentCode: randomPrepaymentCode, + accessibilityAdjustmentNeeded: randomAccessibilityAdjustedCertificationNeeded, }); databaseBuilder.factory.buildCoreSubscription({ certificationCandidateId: certificationCandidate.id }); diff --git a/api/db/seeds/data/team-certification/data-builder.js b/api/db/seeds/data/team-certification/data-builder.js index 36d8eac7765..8aacf82e5db 100644 --- a/api/db/seeds/data/team-certification/data-builder.js +++ b/api/db/seeds/data/team-certification/data-builder.js @@ -427,7 +427,7 @@ async function _createSuccessCertifiableUser({ databaseBuilder }) { async function _createV3Session({ databaseBuilder, configSession = { - candidatesToRegisterCount: 1, + candidatesToRegisterCount: 2, hasComplementaryCertificationsToRegister: false, }, }) { From b0aeea61aad9037dab91324688ee60ba9757c7f6 Mon Sep 17 00:00:00 2001 From: "matthieu.gros" Date: Thu, 8 Aug 2024 14:20:04 +0200 Subject: [PATCH 4/4] :sparkles: api: add SCO candidate requiring adjusted certification --- .../seeds/data/common/tooling/session-tooling.js | 14 +++++++++----- .../seeds/data/team-certification/data-builder.js | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/api/db/seeds/data/common/tooling/session-tooling.js b/api/db/seeds/data/common/tooling/session-tooling.js index 603166b5838..38f7075daeb 100644 --- a/api/db/seeds/data/common/tooling/session-tooling.js +++ b/api/db/seeds/data/common/tooling/session-tooling.js @@ -38,6 +38,7 @@ export { * @param {Date} createdAt * @param {string} supervisorPassword * @param {learnersToRegisterCount: number, maxLevel: number } configSession + * @param {number} version * @returns {Promise<{sessionId: number}>} sessionId */ @@ -57,6 +58,7 @@ async function createDraftScoSession({ createdAt, configSession, supervisorPassword, + version, }) { _buildSession({ databaseBuilder, @@ -82,6 +84,7 @@ async function createDraftScoSession({ juryCommentAuthorId: null, juryCommentedAt: null, supervisorPassword, + version, }); await _registerOrganizationLearnersToSession({ @@ -90,6 +93,7 @@ async function createDraftScoSession({ organizationId, hasJoinSession: false, configSession, + version, }); await databaseBuilder.commit(); @@ -549,6 +553,7 @@ async function _registerOrganizationLearnersToSession({ organizationId, hasJoinSession, configSession, + version, }) { const certificationCandidates = []; if (_hasLearnersToRegister(configSession)) { @@ -562,6 +567,7 @@ async function _registerOrganizationLearnersToSession({ sessionId, extraTimePercentages, hasJoinSession, + version, ); } return certificationCandidates; @@ -574,6 +580,7 @@ function _addCertificationCandidatesToScoSession( sessionId, extraTimePercentages, hasJoinSession, + version, ) { organizationLearners.forEach((organizationLearner, index) => { const candidate = databaseBuilder.factory.buildCertificationCandidate({ @@ -595,7 +602,7 @@ function _addCertificationCandidatesToScoSession( authorizedToStart: false, billingMode: null, prepaymentCode: null, - accessibilityAdjustmentNeeded: (version === 3 && accessibilityAdjustedCertificationNeeds[index]) ?? false, + accessibilityAdjustmentNeeded: version === 3 && index === 0, }); databaseBuilder.factory.buildCoreSubscription({ certificationCandidateId: candidate.id }); certificationCandidates.push(candidate); @@ -638,7 +645,6 @@ async function _registerCandidatesToSession({ prepaymentCode: null, }, ]; - const accessibilityAdjustedCertificationNeeds = [true, false]; const complementaryCertificationIds = [null]; if (configSession.hasComplementaryCertificationsToRegister) { @@ -663,8 +669,6 @@ async function _registerCandidatesToSession({ billingModes[i % billingModes.length]; const randomExtraTimePercentage = extraTimePercentages[i % extraTimePercentages.length]; - const randomAccessibilityAdjustedCertificationNeeded = - (version === 3 && accessibilityAdjustedCertificationNeeds[i]) ?? false; const certificationCandidate = databaseBuilder.factory.buildCertificationCandidate({ firstName: `firstname${i}-${sessionId}`, @@ -685,7 +689,7 @@ async function _registerCandidatesToSession({ authorizedToStart: false, billingMode: randomBillingMode, prepaymentCode: randomPrepaymentCode, - accessibilityAdjustmentNeeded: randomAccessibilityAdjustedCertificationNeeded, + accessibilityAdjustmentNeeded: version === 3 && i === 0, }); databaseBuilder.factory.buildCoreSubscription({ certificationCandidateId: certificationCandidate.id }); diff --git a/api/db/seeds/data/team-certification/data-builder.js b/api/db/seeds/data/team-certification/data-builder.js index 8aacf82e5db..b210be935fb 100644 --- a/api/db/seeds/data/team-certification/data-builder.js +++ b/api/db/seeds/data/team-certification/data-builder.js @@ -112,6 +112,7 @@ async function _createScoCertificationCenter({ databaseBuilder }) { updatedAt: new Date(), members: [{ id: SCO_CERTIFICATION_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID }], complementaryCertificationIds: [], + isV3Pilot: true, }); } @@ -306,6 +307,7 @@ async function _createScoSession({ databaseBuilder }) { room: '42', time: '12:00', createdAt: new Date(), + version: 3, configSession: { learnersToRegisterCount: 8, },