Skip to content

Commit 1a0c09b

Browse files
author
Guillaume
committed
wip
1 parent 832298d commit 1a0c09b

File tree

3 files changed

+128
-6
lines changed

3 files changed

+128
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export class ParticipationStoreLevelPerTubeJob {
2-
constructor({ campaignParticipationId }) {
2+
constructor({ campaignId, campaignParticipationId, locale }) {
33
this.campaignParticipationId = campaignParticipationId;
4+
this.campaignId = campaignId;
5+
this.locale = locale;
46
}
57
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
export const startCampaignParticipation = async ({ campaignParticipationId, knowledgeElementSnapshotRepository }) => {
1+
export const startCampaignParticipation = async ({
2+
campaignId,
3+
campaignParticipationId,
4+
locale,
5+
knowledgeElementSnapshotRepository,
6+
learningContentRepository,
7+
}) => {
28
// get ke snapshot for user participation
3-
const keSnapshot =
4-
knowledgeElementSnapshotRepository.findCampaignParticipationKnowledgeElementSnapshots(campaignParticipationId);
9+
const knowledgeElementsByParticipation = await knowledgeElementSnapshotRepository.findByCampaignParticipationIds([
10+
campaignParticipationId,
11+
]);
12+
13+
const learningContent = await learningContentRepository.findByCampaignId(campaignId, locale);
514

6-
// get tubes and skills for the campaign
715
// sort user ke by tube
816
// find the highest skill level for each tube
917
// store each tube with the highest level in a row in the table
10-
return 42;
1118
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { KnowledgeElementCollection } from '../../../../../../src/prescription/shared/domain/models/KnowledgeElementCollection.js';
2+
import { KnowledgeElement } from '../../../../../../src/shared/domain/models/index.js';
3+
import { databaseBuilder, domainBuilder } from '../../../../../test-helper.js';
4+
5+
describe('Integration | UseCases | storeCampaignParticipationLevelPerTube', function () {
6+
describe('compute', function () {
7+
let campaignParticipationId;
8+
9+
beforeEach(function () {
10+
const learningContentData = {
11+
frameworks: [
12+
{
13+
id: 'frameworkId',
14+
name: 'frameworkName',
15+
areas: [
16+
{
17+
id: 'recArea1',
18+
frameworkId: 'frameworkId',
19+
competenceIds: ['recCompetence1'],
20+
competences: [
21+
{
22+
id: 'recCompetence1',
23+
index: '1.1',
24+
name: 'nom de la competence',
25+
description: 'description de la competence',
26+
areaId: 'recArea1',
27+
origin: 'Pix',
28+
tubes: [
29+
{
30+
id: 'recTube1',
31+
practicalTitle: 'tube1',
32+
practicalDescription: 'tube1 description',
33+
competenceId: 'recCompetence1',
34+
skills: [
35+
{
36+
id: 'recSkillWeb1',
37+
name: '@web1',
38+
status: 'actif',
39+
difficulty: 1,
40+
},
41+
{
42+
id: 'recSkillWeb2',
43+
name: '@web2',
44+
status: 'actif',
45+
difficulty: 2,
46+
},
47+
],
48+
},
49+
{
50+
id: 'recTube2',
51+
practicalTitle: 'tube2',
52+
practicalDescription: 'tube2 description',
53+
competenceId: 'recCompetence1',
54+
skills: [
55+
{
56+
id: 'recSkillUrl1',
57+
name: '@url1',
58+
status: 'actif',
59+
difficulty: 3,
60+
},
61+
{
62+
id: 'recSkillUrl2',
63+
name: '@url2',
64+
status: 'actif',
65+
difficulty: 4,
66+
},
67+
],
68+
},
69+
],
70+
},
71+
],
72+
},
73+
],
74+
},
75+
],
76+
};
77+
78+
const userId = databaseBuilder.factory.buildUser({}).id;
79+
const campaignId = databaseBuilder.factory.buildCampaign().id;
80+
campaignParticipationId = databaseBuilder.factory.buildCampaignParticipation({
81+
campaignId,
82+
userId,
83+
}).id;
84+
85+
domainBuilder.buildLearningContent(learningContentData.frameworks);
86+
87+
const ke1 = domainBuilder.buildKnowledgeElement({
88+
status: KnowledgeElement.StatusType.INVALIDATED,
89+
skillId: 'skill1',
90+
userId: 1,
91+
});
92+
93+
const ke2 = domainBuilder.buildKnowledgeElement({
94+
status: KnowledgeElement.StatusType.VALIDATED,
95+
skillId: 'skill2',
96+
userId: 1,
97+
});
98+
99+
databaseBuilder.factory.buildCampaignSkill({ campaignId, skillId: 'skill1' });
100+
databaseBuilder.factory.buildCampaignSkill({ campaignId, skillId: 'skill2' });
101+
102+
const snapshot = new KnowledgeElementCollection([ke1, ke2]).toSnapshot();
103+
104+
databaseBuilder.factory.buildKnowledgeElementSnapshot({ campaignParticipationId: 1, snapshot });
105+
106+
databaseBuilder.commit();
107+
});
108+
109+
it('should store the reached level per tube', function () {
110+
expect(true).equal(true);
111+
});
112+
});
113+
});

0 commit comments

Comments
 (0)