TinyPortal

Development => Support => Installation => Topic started by: clothahump on February 20, 2011, 12:50:59 PM

Title: Article Ratings Error
Post by: clothahump on February 20, 2011, 12:50:59 PM
Link to my site: http://www.tropicalfishforums.co.uk
SMF version: SMF ver. RC5
TP version: TP ver. TinyPortal10RC1
Default Forum Language: English
Theme name and version: Default
Browser Name and Version: Firefox?
Mods installed: Not Applicable
Related Error messages: None

Ratings appear to be working but the totals are screwed up, first vote shows as 5 stars, after that any other ratings seem to deduct stars, for example, one article has 10 votes of 5 but it only shows one star.
Title: Re: Article Ratings Error
Post by: lurkalot on February 20, 2011, 01:52:29 PM
As far as I'm aware, and I could be wrong.

The rating system takes a average from all the votes, and then rounds it down to the nearest whole number.

So instead of showing 1.5 or 4.5 it will show 1 or 4.

This might have changed though, and as I said I could be wrong.  Hopefully one of the other team members will put us straight on this. ;)
Title: Re: Article Ratings Error
Post by: clothahump on February 20, 2011, 01:58:28 PM
I know what you mean Mick but the average of 10 votes at 5 starts = 5 stars surely.
Title: Re: Article Ratings Error
Post by: lurkalot on February 20, 2011, 02:16:32 PM
Numbers give me a headache. lol..  :-[

Well I have just tried this on my site, I had two articles with one five star vote on each. 

I gave one another five star vote, and it went down to three stars.

I gave the other a one star vote, and it also went down to three stars.   ???

We'll have to wait for the experts on this one. ;)
Title: Re: Article Ratings Error
Post by: WillyP on February 21, 2011, 02:20:27 AM
I think he is saying each of ten people voted five stars... so yes, should be an average of five stars.

If everyone votes five stars, should be an average of five stars. No?

Edit:
Egads, you are right!  I logged into my test site and voted five, which gave a correct rating of five.  I logged out and logged in as someone else, voted five again and now the article has a rating of three!

I wrote a bug report: TinyPortal Bug tracker - Issue #65: Article ratings error (http://www.tinyportal.net/index.php?issue=65.0)
Title: Re: Article Ratings Error
Post by: clothahump on February 21, 2011, 08:06:16 AM
Get this one sorted and then we can move on to the next problem.
Title: Re: Article Ratings Error
Post by: lurkalot on February 21, 2011, 09:15:39 AM
Quote from: WillyP on February 21, 2011, 02:20:27 AM
I think he is saying each of ten people voted five stars... so yes, should be an average of five stars.

If everyone votes five stars, should be an average of five stars. No?

Edit:
Egads, you are right!  I logged into my test site and voted five, which gave a correct rating of five.  I logged out and logged in as someone else, voted five again and now the article has a rating of three!

I wrote a bug report: TinyPortal Bug tracker - Issue #65: Article ratings error (http://www.tinyportal.net/index.php?issue=65.0)

Cheers for doing the bug report.   O0   Something clearly wrong with the voting system.
Title: Re: Article Ratings Error
Post by: IchBin on February 22, 2011, 05:45:27 AM
Find in TPortal.php about line#677

                    // allowed and all is well, go on with it.
                    $context['TPortal']['article'] = $article;


Add after the code above, this code:
                    $context['TPortal']['article']['rating'] = array_sum(explode(',', $context['TPortal']['article']['rating']));

Just to note, TP rounds the votes up. If the number of votes divided by the number of voters is something like 4.3 it rounds the average votes up to 5.
Title: Re: Article Ratings Error
Post by: lurkalot on February 22, 2011, 08:42:03 AM
Quote from: IchBin on February 22, 2011, 05:45:27 AM

Just to note, TP rounds the votes up. If the number of votes divided by the number of voters is something like 4.3 it rounds the average votes up to 5.

Thanks for that info Brad.  Now I knew I'd read it somewhere, and took me a while to find it, but the reason I said rounded down was because I had this in my head for some reason, http://www.tinyportal.net/index.php?topic=30746.msg245459#msg245459
Title: Re: Article Ratings Error
Post by: clothahump on February 22, 2011, 08:58:49 AM
Are all these fixes being implemented in the download of TP?
Title: Re: Article Ratings Error
Post by: lurkalot on February 22, 2011, 09:16:55 AM
TBH, they'll probably be in the next release.  But IchBin has provided the fix for you to try above.  Hopefully it'll sort your problem for now.  ;)
Title: Re: Article Ratings Error
Post by: clothahump on February 22, 2011, 09:31:37 AM
I was just thinking of people downloading the current version and then having to trawl through the forum to find the fixes, surely the current version could be updated every time an error is fixed?
Title: Re: Article Ratings Error
Post by: WillyP on February 22, 2011, 11:47:30 AM
No, the reason for knowing version numbers is so we know whats in the code.  If you start releasing updates without any way to track them, you end up with chaos.  We have trouble enough getting people to state the version when asking for help, imagine having to ask for them to dig in the code to see if random changes had been made.  When a number of small patches have been made, Ich will release a new version.  If it was a critical security patch, I am sure he would release a new version right away.  But this is a minor feature that does not affect the overall operation of the forum.
Title: Re: Article Ratings Error
Post by: IchBin on February 22, 2011, 02:54:11 PM
Generally if I post the fix in the topic, I post it in the bugtracker too. If I don't post the fix, it's because there are too many changes, or it's a change I wouldn't want someone to try just yet. 

Lurk, my guess is that these things have changed over the last while with Bloc moving things, and updating them. I haven't looked, but I'd say that ratings may have been broken longer than just TP1RC1. Either way, we are getting closer. The biggest issues to solve are the front page problems with articles/pagination, and Agridocs language issues.
Title: Re: Article Ratings Error
Post by: clothahump on February 22, 2011, 05:09:57 PM
The problem still exists in category view.
http://www.tropicalfishforums.co.uk/index.php?cat=16
Title: Re: Article Ratings Error
Post by: IchBin on February 22, 2011, 05:40:27 PM
Thanks for reporting that clothahump. I forgot about that section. I'll dig into this when I can get access back on my server. :)
Title: Re: Article Ratings Error
Post by: IchBin on February 22, 2011, 05:59:56 PM
If you'd like to try a fix for this one too you can try this. I don't know if it works, so make sure you backup your file before making these changes.
Sources/TPortal.php about line #1056
// expand the vislaoptions
$row['visual_options'] = explode(",", $row['options']);


Add this right before the lines found above:
// Add the rating together
$row['rating'] = array_sum(explode(',', $row['rating']));
Title: Re: Article Ratings Error
Post by: clothahump on February 22, 2011, 06:19:14 PM
Fine, that one worked as well, by the time we are finished it will be a new release. :)