Topic Ratings Plugin

Yes, I see the issue, I’ll fix it tomorrow morning.

Klicking on the stars on the published post does not work (I think having to edit the post is fine, but since you advertised it, I am telling you about it).

Yes I should have mentioned, I removed that functionality (updated the description accordingly now). So you can only rate in the composer itself.

Just one more request: When you implement your restriction to one post per user in any rating thread, can you make that a setting? I think for my use case having a proper back and forth discussion might be better (of course with a limit of one rating per user :wink: ).

Yes, I think I’ll make it a setting.

Thanks!

Thanks a bunch for your fast response!
I did not have a lot of time this morning, so I just sent of a very quick response. I want to really thank you for this plugin, it matches perfectly with what I want to make possible for our community! (completely new site, so I am free to play around with a still maturing plugin. :wink: )

Another Bug Report from me:

  • Right now, every post can vote, even when that user has already replied and voted in the thread.

  • If you do not vote, it counts as 0 stars. I don’t think this is the correct way to handle it: A non-vote should not influence the average at all. And just posting into a thread which can rate should not lower the average opinion about the topic. Besides, once you have klicked onto 1-5 stars, you can never go back to 0 stars, so even if there just had to be a default vote, it would not be correct.

And a wishlist item: Some way to see the precise average, and how many people have rated the topic how highly. Kinda obvious if you look at amazon or wherever. Just making sure. :wink:

EDIT: Since it might not be obvious: Even though I report everything that looks wrong to me, and even write down whishlist items, the most important thing is that the plugin does not influence threads which it shouldn’t (no rating Tag, category not marked for rating). People are starting to use my discourse instance. Whether this plugin does or doesn’t work correctly is not a big deal as long as only the rating trial topic is influenced. When every single thread is modified, that is a much bigger problem. (All topics created today show stars…)

I have deinstalled the plugin again for now (rebuild the docker instance without it), to get rid of the visual clutter on threads that were not supposed to be rated.

I will happily retry it once that bug is fixed (though having to rebuild the instance for that, with the associated downtime, is unfortunate).

I have made sure the topic averages will not be applied to new topics in a non-ratings category or without the ratings tag. Unfortunately this won’t fix existing topics with empty ratings you’ve made in your instance. If that is a significant issue, I’ll see if I can figure out how to fix it.

https://github.com/angusmcleod/discourse-ratings/commit/22444911758280e519f5908cacf259da53df2a57

Right now, every post can vote, even when that user has already replied and voted in the thread.

I can’t reproduce this one. Could you check again if you re-install the plugin. Thanks.

If you do not vote, it counts as 0 stars. I don’t think this is the correct way to handle it: A non-vote should not influence the average at all. And just posting into a thread which can rate should not lower the average opinion about the topic. Besides, once you have klicked onto 1-5 stars, you can never go back to 0 stars, so even if there just had to be a default vote, it would not be correct.

Yes this is an issue. I think the way to handle it is if the user does not select a rating in a post, that post does not get a rating included. That user could still post on that topic with a rating in another post. Of course, once I add the setting to prevent a user posting in a ratings topic more than once, I will have to require that the user adds a rating to their single post. I will fix this one within the next two days.

And a wishlist item: Some way to see the precise average, and how many people have rated the topic how highly. Kinda obvious if you look at amazon or wherever. Just making sure. :wink:

Yes this is possible. I think I’ll add it next to the topic stars and add later a setting to show/hide it. I will do this one on the weekend.

1 Like

This is a significant issue, but not in the way you think. Having an SQL query to run against the DB (to remove the empty ratings) would not really help.
Think about this: How do you intend to handle the case where someone removes the “rating” tag from a topic? Or in any other way removes a topic from being a rated one?
I would argue that the only sane way for you to handle that case is to treat it as a vanilla topic: No stars, no possibility to rate, no restrictions in the amount of posts. So you don’t only look whether there are ratings when deciding on whether to draw stars or not, you always check whether the topic fulfills the criteria of being a rated one. (I have honestly no idea what you intend to do when someone tags an existing topic with “rating”, the setting to restrict it to one post per user is active, and users have already posted more than once…)

And if you have implement that, I won’t have any problems with stale ratings either. :wink:

I’ve got a discourse docker instance lying around on my desktop. Tell me when you have a version which you think should work, and I’ll test it there. :smiley:

Sure, I’ll play around with the ‘removal’ case tomorrow morning.

This morning I migrated this to the new plugin api.

https://github.com/angusmcleod/discourse-ratings/commit/31e49b955a0d9711d1275200d4e9d660a754ebef

1 Like

Ok! Finally had some time to work on this. Made various bugfixes and updates. Inter alia, I changed the category property that signified whether the category had ratings enabled, so existing categories with ratings enabled will have to be re-enabled to work.

The ratings tag and category toggle is now handled within the composer. If the creator of a topic removes/adds a ratings tag or changes from a ratings category in the first post of a topic the topic will refresh after they post and the ratings will show/hide depending on whether their action was to turn ratings on or off. If ratings are turned ‘off’ on a topic they are still there in the DB. If ratings are turned back on the same ratings will appear again.

Tomorrow or the next day, I’ll apply the same logic to the topic title edit (i.e. if the creator of the topic changes the category or tags by editing the topic title).

Then I’ll add the exact numeric rating to topics title sections and add a setting to toggle it. Then I’ll add an indication that a topic has ratings if those ratings are hidden (i.e. if the category or tags were changed) and a setting to toggle this too.

4 Likes

That sounds really good!
I’ll play around with your plugin this weekend, see whether I have any more bug reports for you. :smiley:

1 Like

Tomorrow or the next day, I’ll apply the same logic to the topic title edit (i.e. if the creator of the topic changes the category or tags by editing the topic title).

This is done.

1 Like

Thanks @DavidGNavas for the Spanish translation!

https://github.com/angusmcleod/discourse-ratings/pull/2

3 Likes

It seems that the ratings plugin makes messages unavailable. Here are some logs. It looks like somehow messages don’t know that they don’t have ratings.

Logs.txt (43.7 KB)

When I disabled the ratings plugins my messages worked again.

Version	v1.5.0.beta11 +267	1.5.0.beta11

@pfaffman Thanks for the bug report!

Should be fixed now:

https://github.com/angusmcleod/discourse-ratings/commit/9d441c4965db3946973160ba17b888207d5c7804

2 Likes

Fixed:

  • I can freely enable and disable the rating tag from a thread and the ratings appear and disappear accordingly. Fantastic!
  • If I have already answered in a thread and answer again, I can’t vote a second time. :thumbsup:

Buggy/Quirky:

  • If I add a “rating” tag while creating a thread, I have to give it a rating. If I modify the thread opening post and add the rating tag, I do not have to rate (and end up with 0 zero star rating…).
  • As a normal user, I am unable to reply without selecting a rating. I’d rather not force my users to have to vote to be able to reply, but it’s ok if other solutions are more work.
    However:
  • If a user ends up having voted multiple times for whatever reason (in this case, because the posts where made with an older plugin version), he is unable to correct that: He can not remove having voted from a post. Otherwise, I as an admin could fix up posts from other users as well as my own…
  • Deleted posts count towards votes. I’d strenuously argue that these votes should not count.
  • If a post has no vote (because the topic did not have the “rating” tag when the post was made), it’s not possible to add it in afterwards. The only way is to make a new reply.

Except for the deleted post voting, none of this is really a bug. But I get the feeling that giving the option to add and remove your vote from your post would make this voting system more intuitive, flexible and robust. :wink:

After seeing that I can reliably disable the plugin by removing the tag “rating”, I have added the plugin into the productive discourse instance again. So I’ll be able to report any other oddities I observer. :smiley:

Other than that, I am looking forward to the exact vote average, and maybe also to a listing of how many people have rated the topic how highly. :wink:

Thanks a lot for your continuing work. The plugin is improving by leaps and bounds! :tada:

2 Likes

As always, my thanks for your fantastic feedback.

If I add a “rating” tag while creating a thread, I have to give it a rating. If I modify the thread opening post and add the rating tag, I do not have to rate (and end up with 0 zero star rating…).

This is fixed.

https://github.com/angusmcleod/discourse-ratings/commit/2a7ab4a4c589fa0d5824ce18c1d09f0c908f38e1

2 Likes

Deleted posts count towards votes. I’d strenuously argue that these votes should not count.

This should be fixed. If a post is deleted its rating will automatically be removed from the average. If the post is restored, its rating will be added back to the average. This should also work with existing ratings topics.

There may be some remaining issues to iron out with this one, but it seems to be working in my local testing.

https://github.com/angusmcleod/discourse-ratings/commit/74fd87d41e42caf29790b6dba0532b8b66862a01

2 Likes

With these two, I see your point, however I think I might work on this kind of thing a little later. They are not functionality issues per se.

As a normal user, I am unable to reply without selecting a rating. I’d rather not force my users to have to vote to be able to reply, but it’s ok if other solutions are more work.

If a post has no vote (because the topic did not have the “rating” tag when the post was made), it’s not possible to add it in afterwards. The only way is to make a new reply.

For this one

If a user ends up having voted multiple times for whatever reason (in this case, because the posts where made with an older plugin version), he is unable to correct that: He can not remove having voted from a post. Otherwise, I as an admin could fix up posts from other users as well as my own…

This is a ‘legacy’ issue. I can fix it for you if it’s an issue on your live site, but if it’s just a dev issue, I might leave this one for now.

Cheers!

When I next have time in the next few days, I’m going to test the deletion discount from averages a bit more and add the exact averages and an indication of hidden ratings.

Thanks for your fast replies and changes!
No, I only have a single thread with votes atm, which is intended for testing. Having voted multiple times there makes playing around easier. :smiley:

Something is more weird after the plugin update than before:
I have currently the votes 0,4,2 which result in a one star rating. But I swear that before the update, changing that 2 into a 3 was enough to give me an average 2 star rating.
I have now changed the ratings to 0,4,5 and raised the rating of the deleted comment to 5. I still only get a 1 star average.
Is the rating maybe not getting updated at all anymore? There are two more comments in the thread without a rating (no stars shown).

Found another bug, and a pretty weird one:
Normally, when you refresh (F5) the browser window after having edited a post, it simply reloads the current thread. If you refresh a rated thread after having edited a post, the edit is shown again (I then cancel the edit, and everything is fine again.)
wtf?

Indeed. I had to add a ‘rating_weight’ property to accommodate deleted posts with ratings (and perhaps to use in the future for weighting ratings differently according to poster, or other metadata such as likes). This subsequently changed the calculation of the topic average from this:

@topic_posts = Post.where(topic_id: post.topic_id)
@all_ratings = PostCustomField.where(post_id: @topic_posts.map(&:id), name: "rating").pluck('value').map(&:to_i)
average = @all_ratings.inject(:+).to_f / @all_ratings.length

to this:

@topic_posts = Post.with_deleted.where(topic_id: post.topic_id)
@ratings = []
@topic_posts.each do |post|
  weight = post.custom_fields["rating_weight"]
  if weight.blank? || weight.to_i > 0
    rating = post.custom_fields["rating"].to_i
    @ratings.push(rating)
  end
end
average = @ratings.inject(:+).to_f / @ratings.length

The rating_weight of deleted posts is set to 0. This logic (I think) accommodates rating weight by only counting ratings if the weight is greater than 0 or is blank (to support posts with ratings posted prior to this change). However, the problem is that it also counts posts without a rating at all… So I’ve changed it to:

@topic_posts = Post.with_deleted.where(topic_id: post.topic_id)
@ratings = []
@topic_posts.each do |post|
  weight = post.custom_fields["rating_weight"]
  if post.custom_fields["rating"] && (weight.blank? || weight.to_i > 0)
   rating = post.custom_fields["rating"].to_i
   @ratings.push(rating)
  end
end
average = @ratings.inject(:+).to_f / @ratings.length 

This also checks if the post has a rating before counting it. A silly mistake on my part really. The problem is that I’m always working on this either early in the morning before work or late at night when the brain is softer…

I hope that fixes it.

https://github.com/angusmcleod/discourse-ratings/commit/615e2388e7475077e348241113fe335a631188b0

2 Likes

It does fix it. 5,4 and 0 now give me a rating of 3. Perfect!

At some point please take a look at the other weird bug I described as well.

Thanks a bunch for your work!

This looks great - would the rating of the topic be displayed in Google at all? i.e:

2 Likes