-
Notifications
You must be signed in to change notification settings - Fork 56
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] Créé des scripts pour générer des élements Modulix (PIX-11270) #8097
Merged
pix-service-auto-merge
merged 3 commits into
dev
from
PIX-11270-modulix-elements-generator
Feb 19, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { getImageSample } from '../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/image.sample.js'; | ||
|
||
console.log(''); | ||
console.log(JSON.stringify(getImageSample(), null, 2)); | ||
console.log(''); | ||
console.log('Voici un joli élément image. Pensez à remplir les alternatives !'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { getQcmSample } from '../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/qcm.sample.js'; | ||
|
||
console.log(''); | ||
console.log(JSON.stringify(getQcmSample(), null, 2)); | ||
console.log(''); | ||
console.log('Voici un petit QCM.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { getQcuSample } from '../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/qcu.sample.js'; | ||
|
||
console.log(''); | ||
console.log(JSON.stringify(getQcuSample(), null, 2)); | ||
console.log(''); | ||
console.log('Voici un QCU.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { getQrocmSample } from '../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/qrocm.sample.js'; | ||
|
||
console.log(''); | ||
console.log(JSON.stringify(getQrocmSample(), null, 2)); | ||
console.log(''); | ||
console.log('Voici un QROCM. Bon courage pour la contrib !'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { getTextSample } from '../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/text.sample.js'; | ||
|
||
console.log(''); | ||
console.log(JSON.stringify(getTextSample(), null, 2)); | ||
console.log(''); | ||
console.log('Voici un petit texte.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { getVideoSample } from '../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/video.sample.js'; | ||
|
||
console.log(''); | ||
console.log(JSON.stringify(getVideoSample(), null, 2)); | ||
console.log(''); | ||
console.log("Voici un joli élément vidéo. N'oubliez pas de compléter la transcription !"); |
11 changes: 11 additions & 0 deletions
11
api/src/devcomp/infrastructure/datasources/learning-content/samples/elements/image.sample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { randomUUID } from 'node:crypto'; | ||
|
||
export function getImageSample() { | ||
return { | ||
id: randomUUID(), | ||
type: 'image', | ||
url: 'https://images.pix.fr/modulix/placeholder-image.svg', | ||
alt: '', | ||
alternativeText: '', | ||
}; | ||
} |
18 changes: 18 additions & 0 deletions
18
api/src/devcomp/infrastructure/datasources/learning-content/samples/elements/qcm.sample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { randomUUID } from 'node:crypto'; | ||
|
||
export function getQcmSample(nbOfProposals = 3) { | ||
return { | ||
id: randomUUID(), | ||
type: 'qcm', | ||
instruction: '<p>Une question à choix multiples ?</p>', | ||
proposals: Array.from(Array(nbOfProposals)).map((_, i) => ({ | ||
id: `${i + 1}`, | ||
content: `Proposition ${i + 1}`, | ||
})), | ||
feedbacks: { | ||
valid: '<p>Correct !</p>', | ||
invalid: '<p>Incorrect !</p>', | ||
}, | ||
solutions: ['1', '2'], | ||
}; | ||
} |
18 changes: 18 additions & 0 deletions
18
api/src/devcomp/infrastructure/datasources/learning-content/samples/elements/qcu.sample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { randomUUID } from 'node:crypto'; | ||
|
||
export function getQcuSample(nbOfProposals = 3) { | ||
return { | ||
id: randomUUID(), | ||
type: 'qcu', | ||
instruction: '<p>Une question à choix unique ?</p>', | ||
proposals: Array.from(Array(nbOfProposals)).map((_, i) => ({ | ||
id: `${i + 1}`, | ||
content: `Proposition ${i + 1}`, | ||
})), | ||
feedbacks: { | ||
valid: '<p>Correct !</p>', | ||
invalid: '<p>Incorrect !</p>', | ||
}, | ||
solution: '1', | ||
}; | ||
} |
59 changes: 59 additions & 0 deletions
59
api/src/devcomp/infrastructure/datasources/learning-content/samples/elements/qrocm.sample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { randomUUID } from 'node:crypto'; | ||
|
||
export function getQrocmSample() { | ||
return { | ||
id: randomUUID(), | ||
type: 'qrocm', | ||
instruction: '<p>Complétez le texte ci-dessous.</p>', | ||
proposals: [ | ||
{ | ||
type: 'text', | ||
content: "<p>Il est possible d'utiliser des textes à champs libres :</p>", | ||
}, | ||
{ | ||
input: 'symbole-separateur-email', | ||
type: 'input', | ||
inputType: 'text', | ||
size: 1, | ||
display: 'inline', | ||
placeholder: '', | ||
ariaLabel: "Remplir avec le caractère qui permet de séparer les deux parties d'une adresse mail", | ||
defaultValue: '', | ||
tolerances: ['t1'], | ||
solutions: ['@'], | ||
}, | ||
{ | ||
type: 'text', | ||
content: '<p>On peut aussi utiliser des liste déroulantes :</p>', | ||
}, | ||
{ | ||
input: 'modulix', | ||
type: 'select', | ||
display: 'inline', | ||
placeholder: '', | ||
ariaLabel: "Choisir l'adjectif le plus adapté", | ||
defaultValue: '', | ||
tolerances: [], | ||
options: [ | ||
{ | ||
id: '1', | ||
content: 'Génial', | ||
}, | ||
{ | ||
id: '2', | ||
content: 'Incroyable', | ||
}, | ||
{ | ||
id: '2', | ||
content: 'Légendaire', | ||
}, | ||
], | ||
solutions: ['3'], | ||
}, | ||
], | ||
feedbacks: { | ||
valid: '<p>Correct !</p>', | ||
invalid: '<p>Incorrect !</p>', | ||
}, | ||
}; | ||
} |
9 changes: 9 additions & 0 deletions
9
api/src/devcomp/infrastructure/datasources/learning-content/samples/elements/text.sample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { randomUUID } from 'node:crypto'; | ||
|
||
export function getTextSample() { | ||
return { | ||
id: randomUUID(), | ||
type: 'text', | ||
content: "<p>Ceci est un texte qui accepte de l'HTML.</p>", | ||
}; | ||
} |
12 changes: 12 additions & 0 deletions
12
api/src/devcomp/infrastructure/datasources/learning-content/samples/elements/video.sample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { randomUUID } from 'node:crypto'; | ||
|
||
export function getVideoSample() { | ||
return { | ||
id: randomUUID(), | ||
type: 'video', | ||
title: 'Une vidéo', | ||
url: 'https://videos.pix.fr/modulix/placeholder-video.mp4', | ||
subtitles: 'https://videos.pix.fr/modulix/placeholder-video.vtt', | ||
transcription: '<p>Vidéo manquante</p>', | ||
}; | ||
} |
65 changes: 65 additions & 0 deletions
65
...omp/unit/infrastructure/datasources/learning-content/validation/module-validation_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { expect } from '../../../../../../test-helper.js'; | ||
import { | ||
imageElementSchema, | ||
qcmElementSchema, | ||
qcuElementSchema, | ||
qrocmElementSchema, | ||
textElementSchema, | ||
videoElementSchema, | ||
} from './element/index.js'; | ||
import { getImageSample } from '../../../../../../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/image.sample.js'; | ||
import { getQcmSample } from '../../../../../../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/qcm.sample.js'; | ||
import { getQcuSample } from '../../../../../../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/qcu.sample.js'; | ||
import { getQrocmSample } from '../../../../../../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/qrocm.sample.js'; | ||
import { getTextSample } from '../../../../../../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/text.sample.js'; | ||
import { getVideoSample } from '../../../../../../../src/devcomp/infrastructure/datasources/learning-content/samples/elements/video.sample.js'; | ||
|
||
describe('Unit | Infrastructure | Datasources | Learning Content | Module Datasource | format validation', function () { | ||
it('should validate sample image structure', function () { | ||
// When | ||
const result = imageElementSchema.validate(getImageSample()); | ||
|
||
// Then | ||
expect(result.error).to.equal(undefined, result.error?.details.map((error) => error.message).join('. ')); | ||
}); | ||
|
||
it('should validate sample qcm structure', function () { | ||
// When | ||
const result = qcmElementSchema.validate(getQcmSample()); | ||
|
||
// Then | ||
expect(result.error).to.equal(undefined, result.error?.details.map((error) => error.message).join('. ')); | ||
}); | ||
|
||
it('should validate sample qcu structure', function () { | ||
// When | ||
const result = qcuElementSchema.validate(getQcuSample()); | ||
|
||
// Then | ||
expect(result.error).to.equal(undefined, result.error?.details.map((error) => error.message).join('. ')); | ||
}); | ||
|
||
it('should validate sample qrocm structure', function () { | ||
// When | ||
const result = qrocmElementSchema.validate(getQrocmSample()); | ||
|
||
// Then | ||
expect(result.error).to.equal(undefined, result.error?.details.map((error) => error.message).join('. ')); | ||
}); | ||
|
||
it('should validate sample text structure', function () { | ||
// When | ||
const result = textElementSchema.validate(getTextSample()); | ||
|
||
// Then | ||
expect(result.error).to.equal(undefined, result.error?.details.map((error) => error.message).join('. ')); | ||
}); | ||
|
||
it('should validate sample video structure', function () { | ||
// When | ||
const result = videoElementSchema.validate(getVideoSample()); | ||
|
||
// Then | ||
expect(result.error).to.equal(undefined, result.error?.details.map((error) => error.message).join('. ')); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En regardant de plus près avec @mariannebost et @mirawlin, nous voyons pas vraiment l'intérêt de nommer l'erreur :
Voici les erreurs pour chaque expect :
Comme cela complexifie vachement la lecture des expects : il faut savoir que le deuxième paramètre est un override de l'erreur, et que
result.error?.details.map((error) => error.message).join('. ')
a pour but d'afficher toutes les erreurs du schéma. Nous proposons plutôt de rester simple avec :There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour info c'est un copié collé de ce qui est fait côté module-datasource_test.
Chaud pour voir ensemble comment faire mieux !