@pfaffman Thanks for the bug report!
Should be fixed now:
https://github.com/angusmcleod/discourse-ratings/commit/9d441c4965db3946973160ba17b888207d5c7804
@pfaffman Thanks for the bug report!
Should be fixed now:
https://github.com/angusmcleod/discourse-ratings/commit/9d441c4965db3946973160ba17b888207d5c7804
Fixed:
Buggy/Quirky:
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.
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.
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.
Thanks a lot for your continuing work. The plugin is improving by leaps and bounds!
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.
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.
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.
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.
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:
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.)
Yes this is a tricky one. I’ve been trying to pin it down this morning. This is what I’ve discovered so far:
It only occurs if you only change the rating on a reply by editing it. If you change the rating on the first post in a topic or change a rating in a reply and also change the content of the post, it does not occur.
The composer opening is triggered by this method in the topic-from-params route:
if (!Ember.isEmpty(topic.get('draft'))) {
composerController.open({
draft: Draft.getLocal(topic.get('draft_key'), topic.get('draft')),
draftKey: topic.get('draft_key'),
draftSequence: topic.get('draft_sequence'),
topic: topic,
ignoreIfChanged: true
});
}
```
So in other words, if only the rating is changed and the title and reply remain the same when an edit to a reply is saved, the ``draft`` attribute of the topic view is populated on the server.
However, it turns out that this is true generally of Discourse. If you edit a reply, do not change the title or reply content and then 'save' the edit, the composer will re-open if you refresh the page: http://quick.as/m1vrS6JxV
Is this a bug or is it intentional? @riking @zogstrip @sam
Not sure, I haven’t touched that part. Maybe @eviltrout knows better?
Just added exact topic averages next to topic star ratings, controlled by the Plugins setting Show exact average rating
https://github.com/angusmcleod/discourse-ratings/commit/e2a4fc5e189d445eea4dd6d2257719782dabe401
Added a note for admins if a topic has hidden ratings (if category or tags were changed).
https://github.com/angusmcleod/discourse-ratings/commit/25cdf0c3cd24c507c8d56811d9f82add63d6c92a
Probably not, but it’s a good feature to add! Will have a look at this soon.
This plugin is now at v0.2.
Apart from the composer re-opening issue, which may be a Discourse bug, the plugin is now reliably working as described. To do list in first post reflects ongoing agenda.
https://github.com/angusmcleod/discourse-ratings/releases/tag/0.2
Forgot to mention here, but the bug with the composer reopening should be fixed now if you update Discourse to include this commit.
https://github.com/discourse/discourse/commit/91a2750084a474a62fe2a61c43b91f6f9396b2d0
Feature request from github:
My team is building a site called Science Commons where academics can discuss research papers. Each topic is about a single paper; the first post is a “wiki” that contains a summary of the paper. I would like to use your rating plug-in for Science Commons. But my concern is that when I turn on the rating tag, I am forced to give a rating on the first post. Is there a way such that no rating is required for the first post? I want to be an impartial admin who posts the paper and don’t want to give my own opinion about the paper.
I’ve thought of adding this previously and will add this as a setting in a few days time, after finishing the current batch of work on Quick Messages.
I’ve added a feature which covers the use case previously mentioned (i.e. omission of a rating from the first post in a ratings topic), and also lets any user remove a rating entirely from a previous post in a ratings topic. Complete removal of a previous rating allows the user to rate in another post on that topic if they so wish.
https://github.com/angusmcleod/discourse-ratings/commit/c6ddc5a6546a594d7fa54bc5ce0238b02b0b7471
Is it possible to customize the “rating” tag to be any other existing tag of my selection?
Hey, that’s number ‘4’ on my list of to dos. As you’ve seen on the topics for my other plugins where you have posted I have a few ‘to dos’ on my plate at the moment, so it’ll be a little while before I add that. But I am happy to accept a PR in the meantime.