Average in a rating between 1 and 5
Everybody is showing you how to compute the weighted average, but not why.
What you have is 28 votes. The average of 28 values is the sum of those values, divided by 28. In this case, that means:
$$\frac{1+1+1+1+1+2+2+2+3+4+\cdots+4+5+5}{28}$$
This, we see, is the same as:
$$\frac{1\cdot 5 + 2\cdot 3+ 3\cdot 1 + 4\cdot 17+5\cdot 2}{28}$$
I don't know where you pulled that $15$ denominator, but you're trying to do the weighted average. If you have a bunch of values $a_i$ to take the average from, all with a importance weight $w_i$, the weighted average is defined as follows : $$ \frac{ \sum_{i = 1}^n w_i \cdot a_i }{ \sum_{i = 1}^n w_i } $$
Note that the weights used in the numerator must be the same as the weights used in the denominator. In your problem the $a_i$ are the possible scores to give and the $w_i$ are the number of persons that gave that score. In your first case you get, $$ \frac{ 1\cdot5+2\cdot3+3\cdot1+4\cdot17+5\cdot2 }{ 5 + 3 + 1 + 17 + 2 } = \frac{92}{28} $$
In the second case, you get $$ \frac{ 1+2+3+4+5 }{ 1+1+1+1+1 } = \frac{15}{5} = 3 $$
You should divide by the total number of voters, not the total of the scores: $$\bar{x}=\frac{5\cdot1+3\cdot2+1\cdot3+17\cdot4+2\cdot5}{5+3+1+17+2}$$ $$=\frac{92}{28}\approx 3.29$$
To see why this is reasonable, suppose everyone voted for the same number (say $2$). Then you would certainly want the average to come out as $2$. It won't if you compute it your way.
Generally, if $v_i$ votes are cast for the score $s_i$, then the average score is $$\bar{s} = \frac{v_1s_1+v_2s_2+\cdots+v_ns_n}{v_1+v_2+\cdots+v_n}$$ This is called a weighted average; each score is weighted by the number of votes for it, then the weighted scores are added and the sum divided by the total of the weights. A bigger number of votes for a particular score gives the score more prominence in the average.
Addendum: Another way to look at the weighted average is to just rewrite it as $$\bar{s} = (\tfrac{v_1}{v_1+v_2+\cdots+v_n})s_1 + (\tfrac{v_2}{v_1+v_2+\cdots+v_n})s_2 + \cdots + (\tfrac{v_n}{v_1+v_2+\cdots+v_n})s_n$$ Here you can see that each score is weighted by the fraction of votes it got out of the total. Each of the weights is between 0% and 100% and they add up to 100%. So the weighted average will be somewhere between the smallest and the largest score.