diff --git a/backend/web/server/plugins/cyberleague/consts.js b/backend/web/server/plugins/cyberleague/consts.js index 54820033ee..bca3a34dd9 100644 --- a/backend/web/server/plugins/cyberleague/consts.js +++ b/backend/web/server/plugins/cyberleague/consts.js @@ -225,6 +225,15 @@ const QUESTION_CATEGORIES = { [QUESTION_CATEGORY_DEVICE_AND_FACTORY_NETWORK_SECURITY] : `SECURITE DES EQUIPEMENTS ET RESEAUX INDUSTRIELS (OT)` } +const SCORE_LEVEL_1 = `SCORE_LEVEL_1` +const SCORE_LEVEL_2 = `SCORE_LEVEL_2` +const SCORE_LEVEL_3 = `SCORE_LEVEL_3` + +const SCORE_LEVELS = { + [SCORE_LEVEL_1] : `Niveau 1`, + [SCORE_LEVEL_2] : `Niveau 2`, + [SCORE_LEVEL_3] : `Niveau 3` +} module.exports = { DISC_ADMIN, DISC_MEMBER, DISC_PARTNER, DISCRIMINATOR_KEY, @@ -241,5 +250,5 @@ module.exports = { QUESTION_CATEGORY_OWN_AND_THIRD_PARTY_ASSET_MANAGEMENT, QUESTION_CATEGORY_IDENTITY_AND_CLEARANCE_MANAGEMENT, QUESTION_CATEGORY_LOG_AND_SUPERVISION, QUESTION_CATEGORY_SAVE_AND_RECOVERY, QUESTION_CATEGORY_DATA_PRIVACY, QUESTION_CATEGORY_PERSONAL_DATA_PROCESSING, QUESTION_CATEGORY_PHYSICAL_SECURITY, QUESTION_CATEGORY_NETWORK_SECURITY_AND_ADMINISTRATIVE_ENVIRONMENT, QUESTION_CATEGORY_ANTIVIRUS_PROTECTION, QUESTION_CATEGORY_ENDPOINT_SECURITY, QUESTION_CATEGORY_MONITORING_AND_UPDATE_MANAGEMENT, QUESTION_CATEGORY_DEVELOPMENT_AND_APP_SECURITY, QUESTION_CATEGORY_BANK_TRANSACTION_SECURITY, QUESTION_CATEGORY_DEVICE_AND_FACTORY_NETWORK_SECURITY, - + SCORE_LEVELS,SCORE_LEVEL_1, SCORE_LEVEL_2, SCORE_LEVEL_3 } \ No newline at end of file diff --git a/backend/web/server/plugins/cyberleague/functions.js b/backend/web/server/plugins/cyberleague/functions.js index 589dc68948..e77611382a 100644 --- a/backend/web/server/plugins/cyberleague/functions.js +++ b/backend/web/server/plugins/cyberleague/functions.js @@ -11,7 +11,7 @@ const { setPostPutData, idEqual, } = require('../../utils/database') -const { ROLES, SECTOR, EXPERTISE_CATEGORIES, CONTENT_TYPE, JOBS, COMPANY_SIZE, ROLE_PARTNER, ROLE_ADMIN, ROLE_MEMBER, ESTIMATED_DURATION_UNITS, LOOKING_FOR_MISSION, CONTENT_VISIBILITY, EVENT_VISIBILITY, ANSWERS, QUESTION_CATEGORIES } = require('./consts') +const { ROLES, SECTOR, EXPERTISE_CATEGORIES, CONTENT_TYPE, JOBS, COMPANY_SIZE, ROLE_PARTNER, ROLE_ADMIN, ROLE_MEMBER, ESTIMATED_DURATION_UNITS, LOOKING_FOR_MISSION, CONTENT_VISIBILITY, EVENT_VISIBILITY, ANSWERS, QUESTION_CATEGORIES, SCORE_LEVELS } = require('./consts') const { PURCHASE_STATUS } = require('../../../utils/consts') const Company = require('../../models/Company') const { BadRequestError } = require('../../utils/errors') @@ -27,6 +27,8 @@ const ExpertiseCategory = require('../../models/ExpertiseCategory') const { computeScores } = require('./score') const Conversation = require('../../models/Conversation') const User = require('../../models/User') +const Question = require('../../models/Question') +const Answer = require('../../models/Answer') const { isMineForPost } = require('./post') //User declarations @@ -240,8 +242,11 @@ declareEnumField({model: 'mission', field: 'estimation_duration_unit', enumValue declareVirtualField({model: 'expertiseSet', field: 'display_categories', requires: 'expertises,categories', instance: 'Array', multiple: true}) //Score declarations -declareVirtualField({model: 'score', field: 'deviation', requires: 'questions.answer', instance: 'Number'}) -declareEnumField( {model: 'score', field: 'questions.answer', enumValues: ANSWERS}) +declareVirtualField({model: 'score', field: 'deviation', requires: 'answers.answer', instance: 'Number'}) +declareEnumField( {model: 'score', field: 'level', enumValues: SCORE_LEVELS}) + +//Answer declaration +declareEnumField( {model: 'answer', field: 'answer', enumValues: ANSWERS}) //questionCategory declarations declareVirtualField({model: 'questionCategory', field: 'questions', instance: 'Array', multiple: true, diff --git a/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js b/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js index d7def9289c..2e2c3164fd 100644 --- a/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js +++ b/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js @@ -1,6 +1,6 @@ const mongoose = require('mongoose') const {schemaOptions} = require('../../../utils/schemas') -const { ANSWER_NO, ANSWERS } = require('../consts') +const { ANSWER_NO, SCORE_LEVELS } = require('../consts') const { DUMMY_REF } = require('../../../utils/database') const Schema = mongoose.Schema @@ -50,6 +50,11 @@ const ScoreSchema = new Schema({ } }], default: [] + }, + level: { + type: String, + enum: Object.keys(SCORE_LEVELS), + required: [true, `Le niveau du score est obligatoire`] } }, {...schemaOptions})