Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update score calculation #32

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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