How I do the valuation account

Asked

Viewed 38 times

0

I’m going crazy here already trying to figure out how I do the account to get result for me to make a pub Progress this way.

inserir a descrição da imagem aqui

There in the 5 star bar has 100% in the 4 has 20% as I get these results.

Division ? I got the result of those 4.4 there, more for each bar I’m not getting..

1 answer

2


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.