From 080f4a78fcbcf4187805bf83f34a37824760473c Mon Sep 17 00:00:00 2001 From: Aurelie Crouillebois Date: Fri, 31 Jan 2025 14:39:29 +0100 Subject: [PATCH] feat(api): add validation indicators on pix junior challenges --- .../infrastructure/serializers/challenge-serializer.js | 2 ++ api/src/shared/domain/models/Challenge.js | 4 ++++ .../infrastructure/repositories/challenge-repository.js | 2 ++ .../serializers/challenge-serializer_test.js | 4 ++++ .../repositories/challenge-repository_test.js | 8 ++++++++ .../tooling/domain-builder/factory/build-challenge.js | 8 ++++++++ 6 files changed, 28 insertions(+) diff --git a/api/src/school/infrastructure/serializers/challenge-serializer.js b/api/src/school/infrastructure/serializers/challenge-serializer.js index 3ed19733693..5444229571a 100644 --- a/api/src/school/infrastructure/serializers/challenge-serializer.js +++ b/api/src/school/infrastructure/serializers/challenge-serializer.js @@ -20,6 +20,8 @@ const serialize = function (challenges) { 'focused', 'timer', 'shuffled', + 'hasEmbedInternalValidation', + 'noValidationNeeded', ], transform: (challenge) => { return { diff --git a/api/src/shared/domain/models/Challenge.js b/api/src/shared/domain/models/Challenge.js index ee1d23b7420..c0f7de432ff 100644 --- a/api/src/shared/domain/models/Challenge.js +++ b/api/src/shared/domain/models/Challenge.js @@ -89,6 +89,8 @@ class Challenge { alternativeVersion, blindnessCompatibility, colorBlindnessCompatibility, + hasEmbedInternalValidation, + noValidationNeeded, } = {}) { this.id = id; this.answer = answer; @@ -121,6 +123,8 @@ class Challenge { this.alternativeVersion = alternativeVersion; this.blindnessCompatibility = blindnessCompatibility; this.colorBlindnessCompatibility = colorBlindnessCompatibility; + this.hasEmbedInternalValidation = hasEmbedInternalValidation; + this.noValidationNeeded = noValidationNeeded; } isTimed() { diff --git a/api/src/shared/infrastructure/repositories/challenge-repository.js b/api/src/shared/infrastructure/repositories/challenge-repository.js index a9eee3bb37c..1e59134a22d 100644 --- a/api/src/shared/infrastructure/repositories/challenge-repository.js +++ b/api/src/shared/infrastructure/repositories/challenge-repository.js @@ -253,6 +253,8 @@ function toDomain({ challengeDto, webComponentTagName, webComponentProps, skill, blindnessCompatibility: challengeDto.accessibility1, colorBlindnessCompatibility: challengeDto.accessibility2, successProbabilityThreshold, + hasEmbedInternalValidation: challengeDto.hasEmbedInternalValidation, + noValidationNeeded: challengeDto.noValidationNeeded, }); } diff --git a/api/tests/school/unit/infrastructure/serializers/challenge-serializer_test.js b/api/tests/school/unit/infrastructure/serializers/challenge-serializer_test.js index 99a5b19f2ac..ad9b208b86c 100644 --- a/api/tests/school/unit/infrastructure/serializers/challenge-serializer_test.js +++ b/api/tests/school/unit/infrastructure/serializers/challenge-serializer_test.js @@ -29,6 +29,8 @@ describe('Unit | Serializer | challenge-serializer', function () { focused: false, illustrationAlt: 'alt', autoReply: false, + hasEmbedInternalValidation: true, + noValidationNeeded: true, }); // when @@ -58,6 +60,8 @@ describe('Unit | Serializer | challenge-serializer', function () { timer: 300, 'illustration-alt': 'alt', 'auto-reply': false, + 'has-embed-internal-validation': true, + 'no-validation-needed': true, }, }, }); diff --git a/api/tests/shared/integration/infrastructure/repositories/challenge-repository_test.js b/api/tests/shared/integration/infrastructure/repositories/challenge-repository_test.js index 22c1f7df118..df2a36d4ae0 100644 --- a/api/tests/shared/integration/infrastructure/repositories/challenge-repository_test.js +++ b/api/tests/shared/integration/infrastructure/repositories/challenge-repository_test.js @@ -44,6 +44,8 @@ describe('Integration | Repository | challenge-repository', function () { locales: ['fr', 'nl'], competenceId: 'competenceId00', skillId: 'skillId00', + hasEmbedInternalValidation: true, + noValidationNeeded: true, }; const challengeData01_skill00_qcu_valide_flashCompatible_fren_withEmbedJson = { id: 'challengeId01', @@ -83,6 +85,8 @@ describe('Integration | Repository | challenge-repository', function () { locales: ['fr', 'en'], competenceId: 'competenceId00', skillId: 'skillId00', + hasEmbedInternalValidation: true, + noValidationNeeded: true, }; const challengeData02_skill00_qcm_archive_flashCompatible_en_noEmbedJson = { id: 'challengeId02', @@ -530,6 +534,8 @@ describe('Integration | Repository | challenge-repository', function () { }), webComponentTagName: 'web-component', webComponentProps: { prop1: 'value1', prop2: 'value2' }, + hasEmbedInternalValidation: true, + noValidationNeeded: true, }), ); }); @@ -583,6 +589,8 @@ describe('Integration | Repository | challenge-repository', function () { difficulty: skillData00_tube00competence00_actif.level, hint: skillData00_tube00competence00_actif.hint_i18n.fr, }), + hasEmbedInternalValidation: true, + noValidationNeeded: true, }), ); }); diff --git a/api/tests/tooling/domain-builder/factory/build-challenge.js b/api/tests/tooling/domain-builder/factory/build-challenge.js index fc82a4cebf8..66f70b997d8 100644 --- a/api/tests/tooling/domain-builder/factory/build-challenge.js +++ b/api/tests/tooling/domain-builder/factory/build-challenge.js @@ -37,6 +37,8 @@ const buildChallenge = function ({ competenceId = 'recCOMP1', webComponentTagName, webComponentProps, + hasEmbedInternalValidation = false, + noValidationNeeded = false, } = {}) { return new Challenge({ id, @@ -73,6 +75,8 @@ const buildChallenge = function ({ skill, // references competenceId, + hasEmbedInternalValidation, + noValidationNeeded, }); }; @@ -109,6 +113,8 @@ const buildChallengeWithWebComponent = function ({ skill = buildSkill(), // references competenceId = 'recCOMP1', + hasEmbedInternalValidation, + noValidationNeeded, } = {}) { return new Challenge({ id, @@ -143,6 +149,8 @@ const buildChallengeWithWebComponent = function ({ skill, // references competenceId, + hasEmbedInternalValidation, + noValidationNeeded, }); };