Skip to content

Commit

Permalink
count votes
Browse files Browse the repository at this point in the history
  • Loading branch information
judemont committed May 17, 2024
1 parent d2ae0fa commit ea30c04
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/getTeachers.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
$authorityTotal = 0;
$humorTotal = 0;

$votesCount = 0;
foreach ($votesData as $vote) {
$votesCount++;
$teachingQualityTotal += $vote["teaching_quality"];
$kindnessTotal += $vote["kindness"];
$authorityTotal += $vote["authority"];
$humorTotal += $vote["humor"];
}

$teacher["votes_count"] = $votesCount;
$teacher["teaching_quality"] = ($votesCount > 0) ? round($teachingQualityTotal / $votesCount) : 0;
$teacher["kindness"] = ($votesCount > 0) ? round($kindnessTotal / $votesCount) : 0;
$teacher["authority"] = ($votesCount > 0) ? round($authorityTotal / $votesCount) : 0;
Expand Down

0 comments on commit ea30c04

Please sign in to comment.