Skip to content

Commit

Permalink
wip pour qu'Alex puisse regarder sur son WebStorm, il est perdu avec …
Browse files Browse the repository at this point in the history
…Vi :p
  • Loading branch information
yaf committed Jan 16, 2025
1 parent 76e6984 commit 1d6ca25
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ export const handleV3CertificationScoring = async ({
configuration,
});

console.log('yaf là 14', locale);
const v3CertificationScoring = await scoringConfigurationRepository.getLatestByDateAndLocale({
locale,
date: certificationCourse.getStartDate(),
});

console.log('yaf là 15');
console.log(abortReason);
const certificationAssessmentScore = CertificationAssessmentScoreV3.fromChallengesAndAnswers({
abortReason,
algorithm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import CertificationCancelled from '../../../../../lib/domain/events/CertificationCancelled.js';
import { SessionAlreadyFinalizedError } from '../errors.js';
import { NotFinalizedSessionError } from '../../../../shared/domain/errors.js';

/**
* @param {Object} params
Expand All @@ -20,10 +20,9 @@ export const cancelCertificationCourse = async function ({
sessionRepository,
}) {
const certificationCourse = await certificationCourseRepository.get({ id: certificationCourseId });
const session = await sessionRepository.get({ id: certificationCourse.id });

if (session.isFinalized) {
throw new SessionAlreadyFinalizedError();
const session = await sessionRepository.get({ id: certificationCourse.getSessionId() });
if (!session.isFinalized) {
throw new NotFinalizedSessionError();
}

certificationCourse.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import { V3CertificationScoring } from '../../domain/models/V3CertificationScori
export const getLatestByDateAndLocale = async ({ locale, date }) => {
const allAreas = await areaRepository.list();
const competenceList = await competenceRepository.list({ locale });

console.log(competenceList);
const competenceScoringConfiguration = await knex('competence-scoring-configurations')
.select('configuration')
.where('createdAt', '<=', date)
.orderBy('createdAt', 'desc')
.first();

console.log('YAF 16', competenceScoringConfiguration);
if (!competenceScoringConfiguration) {
throw new NotFoundError(`No competence scoring configuration found for date ${date.toISOString()}`);
}

console.log('YAF 17');
const certificationScoringConfiguration = await knex('certification-scoring-configurations')
.select('configuration')
.where('createdAt', '<=', date)
Expand Down
6 changes: 3 additions & 3 deletions api/src/shared/domain/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,8 @@ class AuditLoggerApiError extends DomainError {
}
}

class NotFinalizedCertificationError extends DomainError {
constructor(message) {
class NotFinalizedSessionError extends DomainError {
constructor(message = 'A certification course cannot be cancelled while session has not been finalized.') {
super(message);
}
}
Expand Down Expand Up @@ -1128,7 +1128,7 @@ export {
NoSkillsInCampaignError,
NoStagesForCampaign,
NotEnoughDaysPassedBeforeResetCampaignParticipationError,
NotFinalizedCertificationError,
NotFinalizedSessionError,
NotFoundError,
NotImplementedError,
ObjectValidationError,
Expand Down
4 changes: 2 additions & 2 deletions api/src/shared/domain/models/AssessmentResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @typedef {import('../../../certification/shared/domain/models/CompetenceMark.js').CompetenceMark} CompetenceMark
* @typedef {import('../../../certification/shared/domain/models/JuryComment.js').JuryComment} JuryComment
*/
import { NotFinalizedCertificationError } from '../errors.js';
import { NotFinalizedSessionError } from '../errors.js';
import { Assessment } from './Assessment.js';

/**
Expand Down Expand Up @@ -105,7 +105,7 @@ class AssessmentResult {

cancel() {
if (!Object.values(AssessmentResult.status).includes(this.status)) {
throw new NotFinalizedCertificationError('A certification cannot be cancelled if it has not been finalized.');
throw new NotFinalizedSessionError();
}
this.status = AssessmentResult.status.CANCELLED;
}
Expand Down
Loading

0 comments on commit 1d6ca25

Please sign in to comment.