Skip to content

Commit fbad3be

Browse files
authored
Merge pull request #32 from gitcoinco/score-update
update score calculation
2 parents 8c074ab + ff1da93 commit fbad3be

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/service/EvaluationService.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,22 @@ class EvaluationService {
9191
throw new NotFoundError('Application not found');
9292
}
9393

94-
// Calculate the evaluator score
9594
let totalScore = 0;
9695
for (const question of questions) {
97-
totalScore += question.answerEnum;
96+
if (question.answerEnum === 0) {
97+
// approved
98+
totalScore += 1;
99+
} else if (question.answerEnum === 2) {
100+
// uncertain
101+
totalScore += 0.5;
102+
}
98103
}
99104

100-
// Normalize the score to be between 0 and 100
101-
const maxPossibleScore = questions.length * 2; // Each question can contribute a maximum of 2 points (uncertain)
102-
const evaluatorScore = Math.round(
103-
(1 - totalScore / maxPossibleScore) * 100
104-
);
105+
// Calculate the maximum possible score
106+
const maxPossibleScore = questions.length;
107+
108+
// Calculate the evaluator score as a percentage
109+
const evaluatorScore = Math.round((totalScore / maxPossibleScore) * 100);
105110

106111
// Set the evaluation status if the evaluator is not human
107112
if (evaluatorType !== EVALUATOR_TYPE.HUMAN) {

0 commit comments

Comments
 (0)