diff --git a/backend/web/server/plugins/cyberleague/functions.js b/backend/web/server/plugins/cyberleague/functions.js index e77611382a..07f6e6be18 100644 --- a/backend/web/server/plugins/cyberleague/functions.js +++ b/backend/web/server/plugins/cyberleague/functions.js @@ -243,6 +243,7 @@ declareVirtualField({model: 'expertiseSet', field: 'display_categories', require //Score declarations declareVirtualField({model: 'score', field: 'deviation', requires: 'answers.answer', instance: 'Number'}) +declareVirtualField({model: 'score', field: 'is_drafted', requires: 'answers.answer', instance: 'Boolean'}) declareEnumField( {model: 'score', field: 'level', enumValues: SCORE_LEVELS}) //Answer declaration diff --git a/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js b/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js index 2e2c3164fd..b26e6c3b5f 100644 --- a/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js +++ b/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js @@ -64,6 +64,10 @@ ScoreSchema.virtual('deviation', DUMMY_REF).get(function() { return this?.answers?.filter(a => a.answer==ANSWER_NO).length || 0 }) +ScoreSchema.virtual('is_drafted', DUMMY_REF).get(function() { + return this?.answers?.filter(a => !a.answer).length == 0 +}) + /* eslint-enable prefer-arrow-callback */ module.exports = ScoreSchema \ No newline at end of file