Skip to content

Commit

Permalink
✨ api: block scoring on complementary certification only on assessmen…
Browse files Browse the repository at this point in the history
…t completed
  • Loading branch information
P-Jeremy authored Nov 14, 2024
1 parent 36503c7 commit 8a36fbb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class CertificationCompletedJobController extends JobController {
const certificationAssessment = await certificationAssessmentRepository.get(assessmentId);
let certificationScoringCompletedEvent;

if (certificationAssessment.isScoringBlockedDueToComplementaryOnlyChallenges) {
return;
}

if (AlgorithmEngineVersion.isV3(certificationAssessment.version)) {
certificationScoringCompletedEvent = await _handleV3CertificationScoring({
certificationAssessment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CertificationCompletedJob } from '../../../../../../lib/domain/events/C
import { CertificationScoringCompleted } from '../../../../../../lib/domain/events/CertificationScoringCompleted.js';
import { CertificationCompletedJobController } from '../../../../../../src/certification/evaluation/application/jobs/certification-completed-job-controller.js';
import { AssessmentResultFactory } from '../../../../../../src/certification/scoring/domain/models/factories/AssessmentResultFactory.js';
import { AlgorithmEngineVersion } from '../../../../../../src/certification/shared/domain/models/AlgorithmEngineVersion.js';
import {
ABORT_REASONS,
CertificationCourse,
Expand Down Expand Up @@ -81,6 +82,7 @@ describe('Unit | Certification | Application | jobs | CertificationCompletedJobC
id: assessmentId,
certificationCourseId,
userId,
version: AlgorithmEngineVersion.V2,
});
certificationAssessmentRepository.get.withArgs(assessmentId).resolves(certificationAssessment);
});
Expand Down Expand Up @@ -265,6 +267,53 @@ describe('Unit | Certification | Application | jobs | CertificationCompletedJobC
});
});
});

context('when assessment only has only complementary certification challenges', function () {
it('should return', async function () {
// given
const certificationAssessmentWithOnlyComplementaryCertificationChallenges =
domainBuilder.buildCertificationAssessment({
id: assessmentId,
certificationCourseId,
userId,
version: AlgorithmEngineVersion.V2,
certificationChallenges: [
domainBuilder.buildCertificationChallengeWithType({
id: 1234,
certifiableBadgeKey: 'TOTO',
}),
domainBuilder.buildCertificationChallengeWithType({
id: 567,
certifiableBadgeKey: 'TOTO',
}),
domainBuilder.buildCertificationChallengeWithType({
id: 8910,
certifiableBadgeKey: 'TOTO',
}),
],
});
certificationAssessmentRepository.get
.withArgs(assessmentId)
.resolves(certificationAssessmentWithOnlyComplementaryCertificationChallenges);

const dependencies = {
assessmentResultRepository,
certificationAssessmentRepository,
certificationCourseRepository,
competenceMarkRepository,
scoringCertificationService,
services,
events,
};

// when
await certificationCompletedJobController.handle({ data, dependencies });

// then
expect(certificationCourseRepository.update).to.not.have.been.called;
expect(events.eventDispatcher.dispatch).to.not.have.been.called;
});
});
});

context('when certification is V3', function () {
Expand All @@ -285,7 +334,7 @@ describe('Unit | Certification | Application | jobs | CertificationCompletedJobC
certificationCourseId,
userId,
createdAt: Symbol('someCreationDate'),
version: 3,
version: AlgorithmEngineVersion.V3,
};
certificationAssessmentRepository.get.withArgs(assessmentId).resolves(certificationAssessment);
certificationCourse = domainBuilder.buildCertificationCourse({
Expand Down

0 comments on commit 8a36fbb

Please sign in to comment.