Question Answer Plugin


(Pad Pors) #21

Hi Angus,

a suggestion regarding the composer plugin, that may be helpful:

Quora has a simple feature that is inspiring: “post to” in the same time that one is creating a topic:

hi Angus @angus , any update with the composer plugin?


(Pad Pors) #22

Hi Angus,

we used QA in our forum, but then the topics with more votes came down in the discussion! that’s if a topic has more vote its position is more near the bottom of the topic list.

does it have anything to do with the Persian language?

e.g. you can see in this image that a topic with one upvote is after a topic with zero votes!


(Pad Pors) #24

some minor issues with the QA plugin-test:

  • answers are not sorted based on their votes in our Persian forum. in fact they become randomly sorted after activation of QA tag. and won’t go back to the previous time-based sorting if I deactivate the tag from the topic :frowning:

  • people can vote to their own reply.


(Angus McLeod) #25

Hey dude, sorry for being unresponsive here. Will take a look soon.


(Tomek) #26

@angus did you manage to solve this?

On my forum this is also an issue, posts are not sorted based on their votes, this is an example:


(Angus McLeod) #27

Ok, previously I was trying to be clever and use the existing sort_order property on posts, however it seems that that breaks down when the topic gets longer than a handful of posts. I’ve just directly overridden the sort order of topics which are in a QA enabled category. So it’ll work for topics of any length.

cc @Pad_Pors @TomekB


(Alex Reguyal) #28

I tried to move a Q&A topic from the QA category to a different category, and all the votes and voting functionality disappeared. So I added a “question” tag to the topic, and all the votes came back on again. So the tag actually works.

The bug that I encountered is that, you can “like” any and all replies as long as you haven’t voted yet. However, if you vote first, then you can’t like anymore, you will get this error – “You are not permitted to view the requested resource”. So you should first undo your vote, then like some of the replies, then cast your precious one vote again.


(Lincoln President) #29

Thanks for sharing :slight_smile:


(Tomek) #30

@angus After installing your plugin I cannot read any private messages.

I get an error and this log message:

NoMethodError (undefined method custom_fields for nil:NilClass)
/var/www/discourse/plugins/discourse-qa/plugin.rb:66:in qa_enabled

(DiscourseMetrics.com) #31

I have the same issue. Strangely it persists when entering discourse’s safe mode.


(DiscourseMetrics.com) #32

Found the reason: “Safe mode currently only disable the JavaScript portions of plugins”


(Angus McLeod) #33

Yup, looks like my last update didn’t handle the case of uncategorized topics. Please give it another shot.

cc @DiscourseMetrics.com


(Angus McLeod) #34

This bug is now fixed as well.


(Stan Tyan) #35

Hi @angus, thank you for a great plugin.

However, I’m curious how this plugin works with built-in posts timeline. If “this plugin re-arranges the posts in the topic based on those that have been supported” then this timeline is messed up, isn’t it? Posts with the most votes will be on top no matter when they were posted.

Or this plugin turns off the timeline and default chronological posts order?

Your example topic https://dev.civll.com/t/testing-the-qa-plugin/187 does not work.


(Angus McLeod) #36

Sorry for the slow reply, I’ve been on holiday :sun_with_face: :bear:

Yes indeed. The timeline no longer ‘works’ if you use this plugin. I haven’t explicitly addressed that yet. But you’re right that this needs it. I’ll add something in the next few days to deal with it properly. You could always hide it with CSS if need be.

I haven’t needed to address this for my own purposes, as I’m using this in conjunction with my layouts plugin (and others).

Basically, how this plugin works is that it:

  1. Uses the latent vote post action in the core Discourse code and stores the votes in the latent vote_count property of posts. These properties both already exist in the core code, but are not used in the client at the moment (see e.g. here). There’s even core logic to re-arrange the sort_order of the topic based on the vote_count, but it doesn’t work anymore (or maybe I don’t understand it). Previously I had tried to use that, but that led to the issues discussed above, so I added 2…

  2. Overrides the default topic view ordering logic for topics in categories with the appropriate flag, to order posts by vote_count instead of by post_number (the normal way topic views are ordered) (see here). If you want to understand the post ordering logic for topics, most of it is in lib/topic_view.rb. Tantalizingly, there’s a reference in the code to allowing custom post orders in the future

Basically, this ordering logic boils down to this SQL statement:

case when post_number = 1 then 0 else 1 end, vote_count DESC

i.e. if the post is the first post in the topic, then put it at the top, otherwise order the topic by post vote count.

I’ve made another Q/A topic on my dev instance if you want to take a look. Or you could sign up an account and create your own.


(Stan Tyan) #37

Thank you so much for such a detailed answer!

  1. Do you think this plugin could possibly significantly slow down page load speed? if there are lot’s of posts in a topic.

  2. Also, is there any possibility that this plugin will conflict with future discourse developments and updates. For example, if t hey decided to roll out their own “posts up-voting” feature.

  3. And the last one, is there any was to turn your plugin active site-wide in all categories? I have about 100 categories, and going to each category settings to turn on the plugin is PITA :slight_smile:

  4. As far as I understood, vote counts of each post are saved in a database and remain there even if I remove this plugin, is this correct? And if yes, could it possibly cause some issues in future discourse updates?

Thank you so much again for this plugin.


(Angus McLeod) #38

No, it won’t affect page load speed.

Yes, this is a possibility with any plugin. If Discourse releases a core mechanism for up-voting posts then I will discontinue work on this and use that instead of this.

No, there isn’t yet. I could add this, but I strongly suggest you test this in a single category first, for at least a few weeks. This is a new plugin. I don’t use it in production myself yet.

[quote=“stantyan, post:37, topic:56032”]
As far as I understood, vote counts of each post are saved in a database and remain there even if I remove this plugin, is this correct?[/quote]

Correct.

The main question here is whether a future Discourse version will use the existing vote_count property of posts. If it does, then all votes made with this plugin will be picked up by the new core functionality.

Remember that vote_count is a property in the core Discourse code itself. It’s been there since the initial release of Discourse, i.e. 2013.

The alternative way of handling the storage of votes would have been to create a post custom field, i.e. post.custom_fields['vote_count']. The reason I chose not to do this was because it seemed redundant given there was an existing post property, and it would also make it harder to migrate the data created by this plugin if the core vote_count field were used in the future for a similar purpose. Also, I would have to re-create the front-end post-action UI and translations that already exist for voting.

I suppose there is a risk that vote_count could be used in the future in a such a way that does not conceptually relate to the way I am using it here, however I doubt it. Something called vote_count on a post object could only really be used for storing the count of how many people have voted for that post.

If you’re wondering whether this plugin conflicts with the poll plugin or the topic voting plugin, it doesn’t. Those plugins use different fields. All are about voting, but different kinds of voting…

image


(Cee Kay) #39

Do you have this template with you still?


(Daniela) #40

The site in the images I posted is the sandbox of @angus : https://dev.civll.com/


#41

@angus I can not rebuild Discourse when using your plugin. I get this error:

NoMethodError: undefined method attributes' for PostSerializer:Class /var/www/discourse/plugins/discourse-qa/plugin.rb:33:inclass:PostSerializer