Skip to content

Commit

Permalink
[TECH] Ajout de nouvelles colonnes pour les challenges pix-junior
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Jan 31, 2025
2 parents 13f012d + 83c0788 commit 49ab8b8
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export function buildChallenge({
locales = ['fr'],
competenceId = null,
skillId = null,
hasEmbedInternalValidation = false,
noValidationNeeded = false,
} = {}) {
return buildChallengeInDB({
id,
Expand Down Expand Up @@ -77,6 +79,8 @@ export function buildChallenge({
locales,
competenceId,
skillId,
hasEmbedInternalValidation,
noValidationNeeded,
});
}

Expand Down Expand Up @@ -118,6 +122,8 @@ export function buildChallengeWithNoDefaultValues({
locales,
competenceId,
skillId,
hasEmbedInternalValidation,
noValidationNeeded,
}) {
return buildChallengeInDB({
id,
Expand Down Expand Up @@ -157,6 +163,8 @@ export function buildChallengeWithNoDefaultValues({
locales,
competenceId,
skillId,
hasEmbedInternalValidation,
noValidationNeeded,
});
}

Expand Down Expand Up @@ -198,6 +206,8 @@ function buildChallengeInDB({
locales,
competenceId,
skillId,
hasEmbedInternalValidation,
noValidationNeeded,
}) {
const values = {
id,
Expand Down Expand Up @@ -237,6 +247,8 @@ function buildChallengeInDB({
locales,
competenceId,
skillId,
hasEmbedInternalValidation,
noValidationNeeded,
};
return databaseBuffer.pushInsertable({
tableName: 'learningcontent.challenges',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const SCHEMA_NAME = 'learningcontent';
const TABLE_NAME = 'challenges';
const COLUMN_NAME = 'hasEmbedInternalValidation';

const up = async function (knex) {
await knex.schema.withSchema(SCHEMA_NAME).table(TABLE_NAME, function (table) {
table
.boolean(COLUMN_NAME)
.defaultTo(false)
.comment('Indicates that the embed has internal rules to handle the challenge validation');
});
};

const down = async function (knex) {
await knex.schema.withSchema(SCHEMA_NAME).table(TABLE_NAME, function (table) {
table.dropColumn(COLUMN_NAME);
});
};

export { down, up };
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const SCHEMA_NAME = 'learningcontent';
const TABLE_NAME = 'challenges';
const COLUMN_NAME = 'noValidationNeeded';

const up = async function (knex) {
await knex.schema.withSchema(SCHEMA_NAME).table(TABLE_NAME, function (table) {
table
.boolean(COLUMN_NAME)
.defaultTo(false)
.comment(
'Indicates that the challenge does not need any validation, i.e. contains only a video to watch or a text to read',
);
});
};

const down = async function (knex) {
await knex.schema.withSchema(SCHEMA_NAME).table(TABLE_NAME, function (table) {
table.dropColumn(COLUMN_NAME);
});
};

export { down, up };
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ChallengeRepository extends LearningContentRepository {
locales,
competenceId,
skillId,
hasEmbedInternalValidation,
noValidationNeeded,
}) {
return {
id,
Expand Down Expand Up @@ -86,6 +88,8 @@ class ChallengeRepository extends LearningContentRepository {
locales,
competenceId,
skillId,
hasEmbedInternalValidation,
noValidationNeeded,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr'],
competenceId: 'competenceId About to be refreshed Epreuve - new',
skillId: 'skillId About to be refreshed Epreuve - new',
hasEmbedInternalValidation: false,
noValidationNeeded: false,
},
{
id: 'untouchedChallengeId',
Expand Down Expand Up @@ -333,6 +335,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr', 'en'],
competenceId: 'competenceId Untouched Epreuve',
skillId: 'skillId Untouched Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: true,
},
{
id: 'newChallengeId',
Expand Down Expand Up @@ -372,6 +376,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr', 'nl'],
competenceId: 'competenceId New Epreuve',
skillId: 'skillId New Epreuve',
hasEmbedInternalValidation: true,
noValidationNeeded: false,
},
],
courses: [
Expand Down Expand Up @@ -786,6 +792,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr', 'nl'],
competenceId: 'competenceId About to be refreshed Epreuve - old',
skillId: 'skillId About to be refreshed Epreuve - old',
hasEmbedInternalValidation: true,
noValidationNeeded: true,
});
databaseBuilder.factory.learningContent.buildChallenge({
id: 'untouchedChallengeId',
Expand Down Expand Up @@ -825,6 +833,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr', 'en'],
competenceId: 'competenceId Untouched Epreuve',
skillId: 'skillId Untouched Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: true,
});
databaseBuilder.factory.learningContent.buildChallenge({
id: 'missingChallengeId',
Expand Down Expand Up @@ -864,6 +874,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['en', 'nl'],
competenceId: 'competenceId Missing Epreuve',
skillId: 'skillId Missing Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: false,
});
databaseBuilder.factory.learningContent.buildCourse({
id: 'aboutToBeRefreshedCourseId',
Expand Down Expand Up @@ -1394,6 +1406,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr'],
competenceId: 'competenceId About to be refreshed Epreuve - new',
skillId: 'skillId About to be refreshed Epreuve - new',
hasEmbedInternalValidation: false,
noValidationNeeded: false,
},
{
id: 'missingChallengeId',
Expand Down Expand Up @@ -1433,6 +1447,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['en', 'nl'],
competenceId: 'competenceId Missing Epreuve',
skillId: 'skillId Missing Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: false,
},
{
id: 'newChallengeId',
Expand Down Expand Up @@ -1472,6 +1488,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr', 'nl'],
competenceId: 'competenceId New Epreuve',
skillId: 'skillId New Epreuve',
hasEmbedInternalValidation: true,
noValidationNeeded: false,
},
{
id: 'untouchedChallengeId',
Expand Down Expand Up @@ -1511,6 +1529,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr', 'en'],
competenceId: 'competenceId Untouched Epreuve',
skillId: 'skillId Untouched Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: true,
},
]);
const updatedCourses = await knex.select('*').from('learningcontent.courses').orderBy('id');
Expand Down Expand Up @@ -2004,6 +2024,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr', 'nl'],
competenceId: 'competenceId About to be refreshed Epreuve - old',
skillId: 'skillId About to be refreshed Epreuve - old',
hasEmbedInternalValidation: true,
noValidationNeeded: true,
},
{
id: 'missingChallengeId',
Expand Down Expand Up @@ -2043,6 +2065,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['en', 'nl'],
competenceId: 'competenceId Missing Epreuve',
skillId: 'skillId Missing Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: false,
},
{
id: 'untouchedChallengeId',
Expand Down Expand Up @@ -2082,6 +2106,8 @@ describe('Learning Content | Integration | Application | Jobs | Create release',
locales: ['fr', 'en'],
competenceId: 'competenceId Untouched Epreuve',
skillId: 'skillId Untouched Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: true,
},
]);
const updatedCourses = await knex.select('*').from('learningcontent.courses').orderBy('id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr'],
competenceId: 'competenceId About to be refreshed Epreuve - new',
skillId: 'skillId About to be refreshed Epreuve - new',
hasEmbedInternalValidation: false,
noValidationNeeded: false,
},
{
id: 'untouchedChallengeId',
Expand Down Expand Up @@ -333,6 +335,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr', 'en'],
competenceId: 'competenceId Untouched Epreuve',
skillId: 'skillId Untouched Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: true,
},
{
id: 'newChallengeId',
Expand Down Expand Up @@ -372,6 +376,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr', 'nl'],
competenceId: 'competenceId New Epreuve',
skillId: 'skillId New Epreuve',
hasEmbedInternalValidation: true,
noValidationNeeded: true,
},
],
courses: [
Expand Down Expand Up @@ -786,6 +792,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr', 'nl'],
competenceId: 'competenceId About to be refreshed Epreuve - old',
skillId: 'skillId About to be refreshed Epreuve - old',
hasEmbedInternalValidation: true,
noValidationNeeded: true,
});
databaseBuilder.factory.learningContent.buildChallenge({
id: 'untouchedChallengeId',
Expand Down Expand Up @@ -825,6 +833,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr', 'en'],
competenceId: 'competenceId Untouched Epreuve',
skillId: 'skillId Untouched Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: true,
});
databaseBuilder.factory.learningContent.buildChallenge({
id: 'missingChallengeId',
Expand Down Expand Up @@ -864,6 +874,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['en', 'nl'],
competenceId: 'competenceId Missing Epreuve',
skillId: 'skillId Missing Epreuve',
hasEmbedInternalValidation: true,
noValidationNeeded: false,
});
databaseBuilder.factory.learningContent.buildCourse({
id: 'aboutToBeRefreshedCourseId',
Expand Down Expand Up @@ -1394,6 +1406,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr'],
competenceId: 'competenceId About to be refreshed Epreuve - new',
skillId: 'skillId About to be refreshed Epreuve - new',
hasEmbedInternalValidation: false,
noValidationNeeded: false,
},
{
id: 'missingChallengeId',
Expand Down Expand Up @@ -1433,6 +1447,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['en', 'nl'],
competenceId: 'competenceId Missing Epreuve',
skillId: 'skillId Missing Epreuve',
hasEmbedInternalValidation: true,
noValidationNeeded: false,
},
{
id: 'newChallengeId',
Expand Down Expand Up @@ -1472,6 +1488,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr', 'nl'],
competenceId: 'competenceId New Epreuve',
skillId: 'skillId New Epreuve',
hasEmbedInternalValidation: true,
noValidationNeeded: true,
},
{
id: 'untouchedChallengeId',
Expand Down Expand Up @@ -1511,6 +1529,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr', 'en'],
competenceId: 'competenceId Untouched Epreuve',
skillId: 'skillId Untouched Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: true,
},
]);
const refreshedCourses = await knex.select('*').from('learningcontent.courses').orderBy('id');
Expand Down Expand Up @@ -2004,6 +2024,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr', 'nl'],
competenceId: 'competenceId About to be refreshed Epreuve - old',
skillId: 'skillId About to be refreshed Epreuve - old',
hasEmbedInternalValidation: true,
noValidationNeeded: true,
},
{
id: 'missingChallengeId',
Expand Down Expand Up @@ -2043,6 +2065,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['en', 'nl'],
competenceId: 'competenceId Missing Epreuve',
skillId: 'skillId Missing Epreuve',
hasEmbedInternalValidation: true,
noValidationNeeded: false,
},
{
id: 'untouchedChallengeId',
Expand Down Expand Up @@ -2082,6 +2106,8 @@ describe('Learning Content | Integration | Application | Jobs | Refresh cache',
locales: ['fr', 'en'],
competenceId: 'competenceId Untouched Epreuve',
skillId: 'skillId Untouched Epreuve',
hasEmbedInternalValidation: false,
noValidationNeeded: true,
},
]);
const refreshedCourses = await knex.select('*').from('learningcontent.courses').orderBy('id');
Expand Down
Loading

0 comments on commit 49ab8b8

Please sign in to comment.