diff --git a/backend/web/server/plugins/cyberleague/functions.js b/backend/web/server/plugins/cyberleague/functions.js index 06b0b127c..f1fd9b26c 100644 --- a/backend/web/server/plugins/cyberleague/functions.js +++ b/backend/web/server/plugins/cyberleague/functions.js @@ -271,6 +271,7 @@ declareVirtualField({model: 'score', field: 'deviation', requires: 'answers.answ declareVirtualField({model: 'score', field: 'question_count', require: 'answers', instance: 'Number'}) declareEnumField( {model: 'score', field: 'level', enumValues: SCORE_LEVELS}) declareComputedField({model: 'score', field: 'questions_by_category', requires: 'answers.question.question_category._id', getterFn: getQuestionsByCategory}) +declareComputedField({model: 'score', field: 'bellwether_count', requires:'is_drafted', getterFn: getterCountFn('score', {'completed': true})}) //Answer declaration declareEnumField( {model: 'answer', field: 'answer', enumValues: ANSWERS}) @@ -478,7 +479,7 @@ const postPutData = async ({model, id, params, user}) => { const answer = await Answer.findById(id) const score = await Score.findById(answer.score) const completed = score.answers?.filter(a => !a.answer).length == 0 - + if (completed) { const computedScores = await computeScores(score.answers) diff --git a/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js b/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js index 5445f5650..59086ab6e 100644 --- a/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js +++ b/backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js @@ -71,6 +71,10 @@ const ScoreSchema = new Schema({ } }] }, + bellwether_count: { + type: Number, + default: 0 + }, completed: { type: Boolean, required: true,