Skip to content

Commit

Permalink
Cyberleague: [premieroctet#111] update score.js to match new score sc…
Browse files Browse the repository at this point in the history
…hema
  • Loading branch information
Bastien-Wappizy committed Sep 9, 2024
1 parent d0c788f commit 6c0bf2a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions backend/web/server/plugins/cyberleague/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ const lodash = require('lodash')
const { ANSWER_NOT_APPLICABLE, ANSWER_YES } = require("./consts")

// questionArray: [{question, answer}]
const computeScores = async (questionArray) => {
const computeScores = async (answerArray) => {

let questions= await Promise.all(questionArray.map((q) =>
loadFromDb({model: 'question', fields: ['weight', 'question_category', 'is_bellwether'], id: q.question._id})))
let answers= await Promise.all(answerArray.map((a) =>
loadFromDb({model: 'question', fields: ['weight', 'question_category', 'is_bellwether'], id: a.question._id})))

questions=questions.map((elem, idx) => {
return {question: elem[0], answer: questionArray[idx].answer}
answers=answers.map((elem, idx) => {
return {question: elem[0], answer: answerArray[idx].answer}
})

let total_weight =0
Expand Down Expand Up @@ -45,7 +45,7 @@ const computeScores = async (questionArray) => {
let category_weightsAndRates={}
let bellwether_weightsAndRates = {}

lodash.forEach(questions, ({question, answer}) => {
lodash.forEach(answers, ({question, answer}) => {

// If not applicable => question is not considered
if (answer != ANSWER_NOT_APPLICABLE) {
Expand Down

0 comments on commit 6c0bf2a

Please sign in to comment.