Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Pix Junior - Utiliser les options de validation de challenge provenant de Pix Editor #11296

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const serialize = function (challenges) {
'focused',
'timer',
'shuffled',
'hasEmbedInternalValidation',
'noValidationNeeded',
],
transform: (challenge) => {
return {
Expand Down
4 changes: 4 additions & 0 deletions api/src/shared/domain/models/Challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Challenge {
alternativeVersion,
blindnessCompatibility,
colorBlindnessCompatibility,
hasEmbedInternalValidation,
noValidationNeeded,
} = {}) {
this.id = id;
this.answer = answer;
Expand Down Expand Up @@ -121,6 +123,8 @@ class Challenge {
this.alternativeVersion = alternativeVersion;
this.blindnessCompatibility = blindnessCompatibility;
this.colorBlindnessCompatibility = colorBlindnessCompatibility;
this.hasEmbedInternalValidation = hasEmbedInternalValidation;
this.noValidationNeeded = noValidationNeeded;
}

isTimed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ function toDomain({ challengeDto, webComponentTagName, webComponentProps, skill,
blindnessCompatibility: challengeDto.accessibility1,
colorBlindnessCompatibility: challengeDto.accessibility2,
successProbabilityThreshold,
hasEmbedInternalValidation: challengeDto.hasEmbedInternalValidation,
noValidationNeeded: challengeDto.noValidationNeeded,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ describe('Unit | Serializer | challenge-serializer', function () {
focused: false,
illustrationAlt: 'alt',
autoReply: false,
hasEmbedInternalValidation: true,
noValidationNeeded: true,
});

// when
Expand Down Expand Up @@ -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,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ describe('Integration | Repository | challenge-repository', function () {
locales: ['fr', 'nl'],
competenceId: 'competenceId00',
skillId: 'skillId00',
hasEmbedInternalValidation: true,
noValidationNeeded: true,
Comment on lines +47 to +48
Copy link
Contributor

@rouxxi rouxxi Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce cas n'existe pas ?
Il ne vaut pas mieux faire des true/false ou false/true ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L'idée était surtout de faire des tests techniques (passage de false à true ou pas...).
Les challenges ne sont pas "réalistes", ici, c'est un QCU avec autoReply à true par exemple.

};
const challengeData01_skill00_qcu_valide_flashCompatible_fren_withEmbedJson = {
id: 'challengeId01',
Expand Down Expand Up @@ -83,6 +85,8 @@ describe('Integration | Repository | challenge-repository', function () {
locales: ['fr', 'en'],
competenceId: 'competenceId00',
skillId: 'skillId00',
hasEmbedInternalValidation: true,
noValidationNeeded: true,
};
Comment on lines +88 to 90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

même question

const challengeData02_skill00_qcm_archive_flashCompatible_en_noEmbedJson = {
id: 'challengeId02',
Expand Down Expand Up @@ -531,6 +535,8 @@ describe('Integration | Repository | challenge-repository', function () {
}),
webComponentTagName: 'web-component',
webComponentProps: { prop1: 'value1', prop2: 'value2' },
hasEmbedInternalValidation: true,
noValidationNeeded: true,
Comment on lines +538 to +539
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Même question

}),
);
});
Expand Down Expand Up @@ -584,6 +590,8 @@ describe('Integration | Repository | challenge-repository', function () {
difficulty: skillData00_tube00competence00_actif.level,
hint: skillData00_tube00competence00_actif.hint_i18n.fr,
}),
hasEmbedInternalValidation: true,
noValidationNeeded: true,
Comment on lines +593 to +594
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Même question

}),
);
});
Expand Down
8 changes: 8 additions & 0 deletions api/tests/tooling/domain-builder/factory/build-challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const buildChallenge = function ({
competenceId = 'recCOMP1',
webComponentTagName,
webComponentProps,
hasEmbedInternalValidation = false,
noValidationNeeded = false,
} = {}) {
return new Challenge({
id,
Expand Down Expand Up @@ -73,6 +75,8 @@ const buildChallenge = function ({
skill,
// references
competenceId,
hasEmbedInternalValidation,
noValidationNeeded,
});
};

Expand Down Expand Up @@ -109,6 +113,8 @@ const buildChallengeWithWebComponent = function ({
skill = buildSkill(),
// references
competenceId = 'recCOMP1',
hasEmbedInternalValidation,
noValidationNeeded,
} = {}) {
return new Challenge({
id,
Expand Down Expand Up @@ -143,6 +149,8 @@ const buildChallengeWithWebComponent = function ({
skill,
// references
competenceId,
hasEmbedInternalValidation,
noValidationNeeded,
});
};

Expand Down
6 changes: 4 additions & 2 deletions junior/app/models/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default class Challenge extends Model {
@attr('boolean') shuffled;
@attr() webComponentProps;
@attr('string') webComponentTagName;
@attr('boolean') hasEmbedInternalValidation;
@attr('boolean') noValidationNeeded;

@hasMany('activity-answer', { async: true, inverse: 'challenge' }) activityAnswers;

Expand All @@ -52,7 +54,7 @@ export default class Challenge extends Model {
}

get isLesson() {
return !!this.focused;
return !!this.focused || !!this.noValidationNeeded;
}

get isQROC() {
Expand Down Expand Up @@ -80,7 +82,7 @@ export default class Challenge extends Model {
}

get isEmbedAutoValidated() {
return this.timer !== null && this.timer >= 0;
return (this.timer !== null && this.timer >= 0) || !!this.hasEmbedInternalValidation;
}

get hasMedia() {
Expand Down
50 changes: 50 additions & 0 deletions junior/tests/unit/models/challenge-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,56 @@ module('Unit | Model | Challenge', function (hooks) {
});
});

module('#isLesson', function () {
test('should be true if focused is true', function (assert) {
const challenge = store.createRecord('challenge', {
focused: true,
});
assert.true(challenge.isLesson);
});
test('should be true if noValidationNeeded is true', function (assert) {
const challenge = store.createRecord('challenge', {
noValidationNeeded: true,
});
assert.true(challenge.isLesson);
});
test('should be false if noValidationNeeded & focused are not set', function (assert) {
const challenge = store.createRecord('challenge');
assert.false(challenge.isLesson);
});
test('should be false if noValidationNeeded & focused are false', function (assert) {
const challenge = store.createRecord('challenge', {
focused: false,
noValidationNeeded: false,
});
assert.false(challenge.isLesson);
});
});
module('#isEmbedAutoValidated', function () {
test('should be true if timer is set', function (assert) {
const challenge = store.createRecord('challenge', {
timer: 1,
});
assert.true(challenge.isEmbedAutoValidated);
});
test('should be true if hasEmbedInternalValidation is true', function (assert) {
const challenge = store.createRecord('challenge', {
hasEmbedInternalValidation: true,
});
assert.true(challenge.isEmbedAutoValidated);
});
test('should be false if timer & hasEmbedInternalValidation are not set', function (assert) {
const challenge = store.createRecord('challenge');
assert.false(challenge.isEmbedAutoValidated);
});
test('should be false hasEmbedInternalValidation is false', function (assert) {
const challenge = store.createRecord('challenge', {
hasEmbedInternalValidation: false,
});
assert.false(challenge.isEmbedAutoValidated);
});
});

module('#hasWebComponent', function () {
test('should be true when web component name and web component props are fields', function (assert) {
const challenge = store.createRecord('challenge', {
Expand Down