MyBB Community Forums

Full Version: [F] Thread rating: Number of stars [R] [C-Michael83]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
A user reported the following issue.

The ratings of a thread are:
  • 4 x 4 stars
  • 1 x 3 stars
The average rating is 3.8 and because of that 4 stars should be shown. But there are only 3.

The reason is that the average rating gets intval'd.

forumdisplay.php:
$thread['averagerating'] = intval(round($thread['averagerating'], 2));
showthread.php:
$thread['averagerating'] = intval(round($thread['totalratings']/$thread['numratings'], 2));
Hm. I guess we could use is_float() to check if it's a proper decimal or not.
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group
Curious if you used the floatvar function?
Revision #4276

This fix is incomplete. There's another problem in the line to calculate the width of the list.

forumdisplay.php & showthread.php:
$thread['width'] = intval($thread['averagerating'])*20;
The problem is the same as mentioned before. Possible fix:
$thread['width'] = intval(round($thread['averagerating']))*20;
I used a different fix, so I'm not sure what you mean as to what exactly is still broken...
There are still 3 stars shown instead of 4. The reason is the line mentioned in my last post:
$thread['width'] = intval($thread['averagerating'])*20;
If the average rating is 3.8 $thread['width'] is 60 but it should be 80.
Shouldn't it show half stars aswell? I don't think it should be rounded. If the average is 4.5 it shouldn't show 5 stars IMHO.

Actually floatval seems like a fine fix for it.
(2008-11-25, 09:34 PM)CraKteR Wrote: [ -> ]Shouldn't it show half stars aswell? I don't think it should be rounded. If the average is 4.5 it shouldn't show 5 stars IMHO.

I don't think we have the ability to do half stars
Pages: 1 2