Skip to content

Commit

Permalink
Merge pull request #32 from gitcoinco/score-update
Browse files Browse the repository at this point in the history
update score calculation
  • Loading branch information
0xKurt authored Dec 2, 2024
2 parents 8c074ab + ff1da93 commit fbad3be
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/service/EvaluationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,22 @@ class EvaluationService {
throw new NotFoundError('Application not found');
}

// Calculate the evaluator score
let totalScore = 0;
for (const question of questions) {
totalScore += question.answerEnum;
if (question.answerEnum === 0) {
// approved
totalScore += 1;
} else if (question.answerEnum === 2) {
// uncertain
totalScore += 0.5;
}
}

// Normalize the score to be between 0 and 100
const maxPossibleScore = questions.length * 2; // Each question can contribute a maximum of 2 points (uncertain)
const evaluatorScore = Math.round(
(1 - totalScore / maxPossibleScore) * 100
);
// Calculate the maximum possible score
const maxPossibleScore = questions.length;

// Calculate the evaluator score as a percentage
const evaluatorScore = Math.round((totalScore / maxPossibleScore) * 100);

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

0 comments on commit fbad3be

Please sign in to comment.