-
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] Enregistrer comme correcte une réponse focused out si le ca…
- Loading branch information
1 parent
65acc35
commit f2fdb86
Showing
11 changed files
with
449 additions
and
104 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
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 @@ | ||
export class Candidate { | ||
/** | ||
* @param {Object} params | ||
* @param {boolean} [params.accessibilityAdjustmentNeeded] | ||
*/ | ||
constructor({ accessibilityAdjustmentNeeded } = {}) { | ||
this.accessibilityAdjustmentNeeded = !!accessibilityAdjustmentNeeded; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ertification/evaluation/infrastructure/repositories/certification-candidate-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
169 changes: 169 additions & 0 deletions
169
api/tests/certification/evaluation/acceptance/answer-route_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,169 @@ | ||
import { | ||
createServer, | ||
databaseBuilder, | ||
expect, | ||
generateValidRequestAuthorizationHeader, | ||
knex, | ||
mockLearningContent, | ||
} from '../../../test-helper.js'; | ||
|
||
describe('Certification | Evaluation | Acceptance | answer-route', function () { | ||
let server; | ||
|
||
beforeEach(async function () { | ||
server = await createServer(); | ||
}); | ||
|
||
describe('POST /api/answers', function () { | ||
context('when challenge is focused out and answer is correct', function () { | ||
context('when the candidate needs an accessibility adjustment', function () { | ||
it('should save the answer as correct', async function () { | ||
// given | ||
const { competenceId, challengeId } = _buildLearningContent(); | ||
const { assessmentId, userId } = await _setupTestData(databaseBuilder, { | ||
competenceId, | ||
doesCandidateNeedAccessibilityAdjustment: true, | ||
}); | ||
const options = _setupRequestOptions({ userId, challengeId, assessmentId }); | ||
|
||
// when | ||
await server.inject(options); | ||
|
||
// then | ||
const [answer] = await knex('answers'); | ||
expect(answer.result).to.equal('ok'); | ||
expect(answer.isFocusedOut).to.equal(true); | ||
}); | ||
}); | ||
|
||
context('when the candidate does not need an accessibility adjustment', function () { | ||
it('should save the answer as focused out', async function () { | ||
// given | ||
const { competenceId, challengeId } = _buildLearningContent(); | ||
const { assessmentId, userId } = await _setupTestData(databaseBuilder, { | ||
competenceId, | ||
doesCandidateNeedAccessibilityAdjustment: false, | ||
}); | ||
const options = _setupRequestOptions({ userId, challengeId, assessmentId }); | ||
|
||
// when | ||
await server.inject(options); | ||
|
||
// then | ||
const [answer] = await knex('answers'); | ||
expect(answer.result).to.equal('focusedOut'); | ||
expect(answer.isFocusedOut).to.equal(true); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
async function _setupTestData(databaseBuilder, { competenceId, doesCandidateNeedAccessibilityAdjustment }) { | ||
const userId = databaseBuilder.factory.buildUser().id; | ||
|
||
const session = databaseBuilder.factory.buildSession({}); | ||
|
||
databaseBuilder.factory.buildCertificationCandidate({ | ||
sessionId: session.id, | ||
userId, | ||
accessibilityAdjustmentNeeded: doesCandidateNeedAccessibilityAdjustment, | ||
}); | ||
|
||
const certificationCourse = databaseBuilder.factory.buildCertificationCourse({ | ||
userId, | ||
sessionId: session.id, | ||
}); | ||
|
||
const assessment = databaseBuilder.factory.buildAssessment({ | ||
type: 'CERTIFICATION', | ||
userId, | ||
competenceId, | ||
certificationCourseId: certificationCourse.id, | ||
}); | ||
|
||
await databaseBuilder.commit(); | ||
|
||
return { assessmentId: assessment.id, userId }; | ||
} | ||
|
||
function _setupRequestOptions({ userId, challengeId, assessmentId }) { | ||
return { | ||
method: 'POST', | ||
url: '/api/answers', | ||
headers: { authorization: generateValidRequestAuthorizationHeader(userId) }, | ||
payload: { | ||
data: { | ||
type: 'answers', | ||
attributes: { | ||
value: 'correct', | ||
'focused-out': true, | ||
}, | ||
relationships: { | ||
assessment: { | ||
data: { | ||
type: 'assessments', | ||
id: assessmentId, | ||
}, | ||
}, | ||
challenge: { | ||
data: { | ||
type: 'challenges', | ||
id: challengeId, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
function _buildLearningContent() { | ||
const challengeId = 'a_challenge_id'; | ||
const competenceId = 'recCompetence'; | ||
|
||
const learningContent = { | ||
areas: [{ id: 'recArea1', competenceIds: ['recCompetence'] }], | ||
competences: [ | ||
{ | ||
id: 'recCompetence', | ||
areaId: 'recArea1', | ||
skillIds: ['recSkill1'], | ||
origin: 'Pix', | ||
name_i18n: { | ||
fr: 'Nom de la competence FR', | ||
en: 'Nom de la competence EN', | ||
}, | ||
statue: 'active', | ||
}, | ||
], | ||
skills: [ | ||
{ | ||
id: 'recSkill1', | ||
name: '@recArea1_Competence1_Tube1_Skill1', | ||
status: 'actif', | ||
competenceId: competenceId, | ||
pixValue: '5', | ||
}, | ||
], | ||
challenges: [ | ||
{ | ||
id: challengeId, | ||
competenceId: competenceId, | ||
skillId: 'recSkill1', | ||
status: 'validé', | ||
solution: 'correct', | ||
proposals: '${a}', | ||
locales: ['fr-fr'], | ||
type: 'QROC', | ||
focusable: true, | ||
}, | ||
], | ||
}; | ||
mockLearningContent(learningContent); | ||
|
||
return { | ||
competenceId, | ||
challengeId, | ||
}; | ||
} |
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
Oops, something went wrong.