-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TECH] Pix1D - Utiliser le modèle "Assessment" du contexte "School"
- Loading branch information
Showing
17 changed files
with
103 additions
and
64 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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import Model, { attr, belongsTo } from '@ember-data/model'; | ||
import Model, { attr } from '@ember-data/model'; | ||
|
||
export default class Activity extends Model { | ||
@attr('string') level; | ||
@belongsTo('assessment', { async: true, inverse: 'activities' }) assessment; | ||
} |
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 |
---|---|---|
@@ -1,17 +1,7 @@ | ||
import Model, { attr, hasMany } from '@ember-data/model'; | ||
import Model, { attr } from '@ember-data/model'; | ||
|
||
export default class Assessment extends Model { | ||
// attributes | ||
@attr('string') certificationNumber; | ||
@attr('string') codeCampaign; | ||
@attr('string') state; | ||
@attr('string') title; | ||
@attr('string') type; | ||
@attr('string') lastQuestionState; | ||
@attr('string') method; | ||
|
||
// references | ||
@attr('string') competenceId; | ||
@attr('string') missionId; | ||
@hasMany('activity', { async: true, inverse: 'assessment' }) activities; | ||
@attr('string') organizationLearnerId; | ||
} |
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
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
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,10 @@ | ||
import { Assessment as SharedAssessment } from '../../../shared/domain/models/Assessment.js'; | ||
class Assessment extends SharedAssessment { | ||
constructor({ id, missionId, organizationLearnerId, state } = {}) { | ||
super({ id, state }); | ||
this.missionId = missionId; | ||
this.organizationLearnerId = organizationLearnerId; | ||
} | ||
} | ||
|
||
export { Assessment }; |
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
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 { Assessment } from '../models/Assessment.js'; | ||
|
||
const getAssessmentById = async function ({ assessmentId, missionAssessmentRepository, assessmentRepository }) { | ||
const rawAssessment = await assessmentRepository.get(assessmentId); | ||
const rawMissionAssessment = await missionAssessmentRepository.getByAssessmentId(assessmentId); | ||
return new Assessment({ ...rawAssessment, ...rawMissionAssessment }); | ||
}; | ||
|
||
export { getAssessmentById }; |
5 changes: 0 additions & 5 deletions
5
api/src/school/domain/usecases/get-mission-assessment-by-assessment-id.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
api/src/school/infrastructure/repositories/mission-assessment-repository.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
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 |
---|---|---|
@@ -1,15 +1,9 @@ | ||
import { Serializer } from 'jsonapi-serializer'; | ||
|
||
const serialize = function (missionAssessment) { | ||
const serialize = function (assessment) { | ||
return new Serializer('assessment', { | ||
transform: (missionAssessment) => { | ||
return { | ||
...missionAssessment, | ||
id: missionAssessment.assessmentId, | ||
}; | ||
}, | ||
attributes: ['missionId', 'organizationLearnerId'], | ||
}).serialize(missionAssessment); | ||
attributes: ['missionId', 'organizationLearnerId', 'state'], | ||
}).serialize(assessment); | ||
}; | ||
|
||
export { serialize }; |
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
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
17 changes: 12 additions & 5 deletions
17
...ssion-assessment-by-assessment-id_test.js → ...ain/usecases/get-assessment-by-id_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 |
---|---|---|
@@ -1,22 +1,29 @@ | ||
import { databaseBuilder, expect } from '../../../../test-helper.js'; | ||
import { usecases } from '../../../../../src/school/shared/usecases/index.js'; | ||
import { MissionAssessment } from '../../../../../src/school/domain/models/MissionAssessment.js'; | ||
import { Assessment } from '../../../../../src/school/domain/models/Assessment.js'; | ||
import * as missionAssessmentRepository from '../../../../../src/school/infrastructure/repositories/mission-assessment-repository.js'; | ||
import * as assessmentRepository from '../../../../../src/shared/infrastructure/repositories/assessment-repository.js'; | ||
|
||
describe('Integration | UseCase | get-mission-assessment-by-assessment-id', function () { | ||
describe('Integration | UseCase | getAssessmentById', function () { | ||
it('should return the missionAssessment corresponding to the assessmentId', async function () { | ||
const assessmentId = databaseBuilder.factory.buildPix1dAssessment().id; | ||
const missionAssessment = databaseBuilder.factory.buildMissionAssessment({ assessmentId }); | ||
await databaseBuilder.commit(); | ||
|
||
const expectedMissionAssessment = new MissionAssessment({ | ||
const result = await usecases.getAssessmentById({ | ||
assessmentId, | ||
missionAssessmentRepository, | ||
assessmentRepository, | ||
}); | ||
|
||
const expectedMissionAssessment = new Assessment({ | ||
id: result.id, | ||
assessmentId, | ||
organizationLearnerId: missionAssessment.organizationLearnerId, | ||
missionId: missionAssessment.missionId, | ||
state: Assessment.states.STARTED, | ||
}); | ||
|
||
const result = await usecases.getMissionAssessmentByAssessmentId({ assessmentId, missionAssessmentRepository }); | ||
|
||
expect(result).to.deep.equal(expectedMissionAssessment); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...ests/school/integration/infrastructure/repositories/mission-assessment-repository_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
10 changes: 5 additions & 5 deletions
10
...re/repositories/school-repository_test.js → ...re/repositories/school-repository_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
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