Skip to content

Commit

Permalink
[FEATURE] Ajout de la colonne relative au besoin d'une certification …
Browse files Browse the repository at this point in the history
…aménagée dans la table certification-candidates (PIX-13293)

 #9815
  • Loading branch information
pix-service-auto-merge authored Aug 12, 2024
2 parents 88c3525 + b0aeea6 commit f252739
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,6 +55,7 @@ const buildCertificationCandidate = function ({
billingMode,
prepaymentCode,
hasSeenCertificationInstructions,
accessibilityAdjustmentNeeded,
};

databaseBuffer.pushInsertable({
Expand Down Expand Up @@ -84,6 +86,7 @@ const buildCertificationCandidate = function ({
billingMode,
prepaymentCode,
hasSeenCertificationInstructions,
accessibilityAdjustmentNeeded,
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -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 };
12 changes: 12 additions & 0 deletions api/db/seeds/data/common/tooling/session-tooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -57,6 +58,7 @@ async function createDraftScoSession({
createdAt,
configSession,
supervisorPassword,
version,
}) {
_buildSession({
databaseBuilder,
Expand All @@ -82,6 +84,7 @@ async function createDraftScoSession({
juryCommentAuthorId: null,
juryCommentedAt: null,
supervisorPassword,
version,
});

await _registerOrganizationLearnersToSession({
Expand All @@ -90,6 +93,7 @@ async function createDraftScoSession({
organizationId,
hasJoinSession: false,
configSession,
version,
});

await databaseBuilder.commit();
Expand Down Expand Up @@ -168,6 +172,7 @@ async function createDraftSession({
hasJoinSession: false,
configSession,
certificationCenterId,
version,
});

await databaseBuilder.commit();
Expand Down Expand Up @@ -519,6 +524,7 @@ async function createPublishedSession({
hasJoinSession: true,
configSession,
certificationCenterId,
version,
});

const { coreProfileData, complementaryCertificationsProfileData } = await _makeCandidatesCertifiable({
Expand Down Expand Up @@ -547,6 +553,7 @@ async function _registerOrganizationLearnersToSession({
organizationId,
hasJoinSession,
configSession,
version,
}) {
const certificationCandidates = [];
if (_hasLearnersToRegister(configSession)) {
Expand All @@ -560,6 +567,7 @@ async function _registerOrganizationLearnersToSession({
sessionId,
extraTimePercentages,
hasJoinSession,
version,
);
}
return certificationCandidates;
Expand All @@ -572,6 +580,7 @@ function _addCertificationCandidatesToScoSession(
sessionId,
extraTimePercentages,
hasJoinSession,
version,
) {
organizationLearners.forEach((organizationLearner, index) => {
const candidate = databaseBuilder.factory.buildCertificationCandidate({
Expand All @@ -593,6 +602,7 @@ function _addCertificationCandidatesToScoSession(
authorizedToStart: false,
billingMode: null,
prepaymentCode: null,
accessibilityAdjustmentNeeded: version === 3 && index === 0,
});
databaseBuilder.factory.buildCoreSubscription({ certificationCandidateId: candidate.id });
certificationCandidates.push(candidate);
Expand All @@ -616,6 +626,7 @@ async function _registerCandidatesToSession({
hasJoinSession,
configSession,
certificationCenterId,
version,
}) {
const certificationCandidates = [];
if (_hasCertificationCandidatesToRegister(configSession)) {
Expand Down Expand Up @@ -678,6 +689,7 @@ async function _registerCandidatesToSession({
authorizedToStart: false,
billingMode: randomBillingMode,
prepaymentCode: randomPrepaymentCode,
accessibilityAdjustmentNeeded: version === 3 && i === 0,
});

databaseBuilder.factory.buildCoreSubscription({ certificationCandidateId: certificationCandidate.id });
Expand Down
4 changes: 3 additions & 1 deletion api/db/seeds/data/team-certification/data-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ async function _createScoCertificationCenter({ databaseBuilder }) {
updatedAt: new Date(),
members: [{ id: SCO_CERTIFICATION_MANAGING_STUDENTS_CERTIFICATION_CENTER_USER_ID }],
complementaryCertificationIds: [],
isV3Pilot: true,
});
}

Expand Down Expand Up @@ -306,6 +307,7 @@ async function _createScoSession({ databaseBuilder }) {
room: '42',
time: '12:00',
createdAt: new Date(),
version: 3,
configSession: {
learnersToRegisterCount: 8,
},
Expand Down Expand Up @@ -427,7 +429,7 @@ async function _createSuccessCertifiableUser({ databaseBuilder }) {
async function _createV3Session({
databaseBuilder,
configSession = {
candidatesToRegisterCount: 1,
candidatesToRegisterCount: 2,
hasComplementaryCertificationsToRegister: false,
},
}) {
Expand Down
3 changes: 3 additions & 0 deletions api/src/shared/domain/models/CertificationCandidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -78,6 +79,7 @@ class CertificationCandidate {
prepaymentCode = null,
subscriptions = [],
hasSeenCertificationInstructions = false,
accessibilityAdjustmentNeeded = false,
} = {}) {
this.id = id;
this.firstName = firstName;
Expand All @@ -102,6 +104,7 @@ class CertificationCandidate {
this.billingMode = billingMode;
this.prepaymentCode = prepaymentCode;
this.hasSeenCertificationInstructions = hasSeenCertificationInstructions;
this.accessibilityAdjustmentNeeded = accessibilityAdjustmentNeeded;

Object.defineProperty(this, 'complementaryCertification', {
enumerable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe('Integration | Certification | Session | Repository | Candidate', funct
billingMode: null,
prepaymentCode: null,
hasSeenCertificationInstructions: false,
accessibilityAdjustmentNeeded: false,
subscriptions: [
{
type: SUBSCRIPTION_TYPES.CORE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const buildCertificationCandidate = function ({
billingMode = null,
prepaymentCode = null,
subscriptions = [domainBuilder.buildCoreSubscription({ certificationCandidateId: 123 })],
accessibilityAdjustmentNeeded = false,
} = {}) {
return new CertificationCandidate({
id,
Expand All @@ -50,6 +51,7 @@ const buildCertificationCandidate = function ({
billingMode,
prepaymentCode,
subscriptions,
accessibilityAdjustmentNeeded,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('Unit | Domain | Models | Certification Candidate', function () {
complementaryCertification: null,
subscriptions: [coreSubscription],
hasSeenCertificationInstructions: false,
accessibilityAdjustmentNeeded: false,
};
});

Expand Down

0 comments on commit f252739

Please sign in to comment.