Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] Thread rating: Number of stars [R] [C-Michael83]
#1
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));
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
#2
Hm. I guess we could use is_float() to check if it's a proper decimal or not.
#3
How about this:

http://us2.php.net/manual/en/function.floatval.php
#4
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
#5
Curious if you used the floatvar function?
#6
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;
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
#7
I used a different fix, so I'm not sure what you mean as to what exactly is still broken...
#8
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.
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
#9
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.
#10
(11-25-2008, 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


Forum Jump:


Users browsing this thread: 1 Guest(s)