0
You need to know:
- maximum possible score
- number of votes
- voting quality
In variables it could be:
$quantidadeVotos = 15 + 3 + 2;
$qualidadeVotos = 5*15 + 4*3 + 1*2;
so the maximum score is 5, and thinking that the maximum score would be $quantidadeVotos * 5
, can do:
$quantidadeVotos * 5 5
____________________ = ___
$qualidadeVotos ?
Then you can settle with:
$resultado = $qualidadeVotos / $quantidadeVotos;
that is, in this example you gave:
$resultado = (5*15+4*3+1*2) / (15 + 3 + 2); // 4.45
I got it.. I divided the number of votes into 4 stars for example and divided by the total number of votes to get the % of each progress bar
– William Alvares