This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

ratings table empty (v2.5)
#1

Hi Steven,

I want to filter ratings calculation via a different method other than average. So I started to create a query to begin to select from the ratings table, but discovered it is empty. I have submitted some test rating data via the front end, and it displays fine, with average, but the table doesn't seem to get populated when a user creates a rating.

I can see in rate.php where the ratings table is written to and selected from, but it seems that for the average calculation it is only retrieving data using the first of the select statements, that is, from the rating field in the comments table.

Have I missed something? Can you shed any light on why the ratings table is not being populated?

Thanks

Lisa
Reply
#2

Hi Lisa,

A lot of this you probably know but I'll explain it for others too. Basically there are two types of ratings in Commentics. The first type is when you click on the average rating and those are stored in the 'ratings' table. The second is when you post a comment and those are stored in the 'comments' table. When the average rating is calculated, it calculates the ratings from both of these types. That's what the "UNION ALL" part of the SQL query is doing, joining the results together from the first SELECT statement and the second SELECT statement. I've just tested this by posting a comment with a rating of 5 and then clicking the average rating with a rating of 3 and the returned calculated result is 4 which is correct. (I had to change my IP address in the database in order to rate twice). Are these results different to what you were expecting?

Have you completed the interview?
Reply
#3

Hi Steven,

Thanks for the response.

I figured that both would write to the ratings table, thats why I was a tad confused.

I need to have a bayesian based rating and I think it will make sense to take it from a separate table, rather than two. So I've begun by bypassing (a chunk of) rate.php, and added a write to the ratings table after comment insert in processor.php (can also use most of your variables too!).

By using the existing code that writes the rating in comments table, I can use the 'already voted' functionality, and build up stats separately in ratings table. Minor duplication perhaps, but easier short term solution. I don't want to lose the rating if a comment is deleted. I

I'm also passing vars from existing site tables to commentics ratings table so I've added a few fields in there for subsequent logic.

Hopefully, I should end up with a method of rating, independent to the comments table and the ability to manipulate the data from ratings table any which way.

In another universe I'm also converting as much commentics as possible to bootstrap, and it's looking pretty good so far. I will post up my changes here eventually, in case anyone else wants to have a go.

I'm sure I'll be back to pick your brains again, but in the meantime thank you very much for a fine script, I'll try to help out in the forum if I can.

(14-Mar-2014, 07:34 PM)Steven Wrote:  Hi Lisa,

A lot of this you probably know but I'll explain it for others too....
Reply
#4

Further to my previous comment and on reflection.

In the interests of update compatibility, I have chosen to keep default settings wherever possible, and use minimum modification.

To satisfy my needs, I have disabled comments rating and used 'average' rating as the default rating selection.

I have added an additional statistics table which is populated from the ratings table via cron.

I moved the average rating block to above the 'if no comments' in includes/templates/comments.php to force it to display always. The 'Don't create the page until the user posts' in manage/pages also needs to be unchecked for this to happen consistently.

The function cmtx_average_rating() has been replaced with a Bayesian equation using a MYSQL View.

I also changed the number of stars from 5 to 10 and introduced some logic to jquery raty; filled stars only appear if the user is logged in and has rated, otherwise empty and ready to accept selection. Global rating is shown to the left of the stars.

So basically, it has similar look and feel to the IMDB rating system.

Comments I left just as comments.

The Bootsrap conversion is almost complete, though this will be difficult to reconcile with any updates. Looks nice though, the bootstrap pagination in particular! Some issues on mobile devices with the use of Code/Quote/PHP in tinymce that need sorting.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)