-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Créé des scripts pour générer des élements Modulix (PIX-11270)
- Loading branch information
Showing
13 changed files
with
228 additions
and
0 deletions.
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('. ')); | ||
}); | ||
}); |