Skip to content

Commit

Permalink
Cyberleague: [premieroctet#113] Add is_drafted virtual fields to scor…
Browse files Browse the repository at this point in the history
…e schema
  • Loading branch information
Bastien-Wappizy committed Sep 6, 2024
1 parent 9f87916 commit 5fa2bfa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/web/server/plugins/cyberleague/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5fa2bfa

Please sign in to comment.