Question Answer Plugin

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


1 Like

This bug is now fixed as well.


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 does not work.

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.

1 Like

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.

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]


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…



@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

1 Like

Thanks for the bug report. Fixed.


Works great! Thanks so much.


Trying to view your Q&A plugin in action but getting a “This site can’t be reached” message

Yeah, I just took that sandbox down. I’m making a new one.

1 Like

Ok the new sandbox is up.

The Q/A category has this plugin enabled.


I tried out the Q&A plugin in your sandbox. Think it’s a great idea. An observation - Finding the vote button was non-obvious:

I think instead, the like button should be repurposed (or hidden & a vote button added in its place). And for extra clarity, a “vote” label placed beside it (which could read “X votes” when X votes have been placed.

1 Like

Also it would be good if replies to a post were collapsed under each post, with a prominent button eg “2 replies” that you click to expand them into view.

Otherwise, replies will break the model

1 Like

I think this UI would be a minor but effective upgrade.

Also, is anyone testing the sandbox out on mobile, page responsiveness is not working.

I had some time yesterday, so I brought this plugin to a point where it makes a bit more sense.

  • Replies to replies always appear underneath the reply they are replying to in the order they were posted.

  • Replies to replies are indented and smaller (even ‘comment-like’ you might say).

  • You can’t reply to replies to replies.

I’ve attempted to make these changes feel ‘natural’, so:

  • Posts are staged in the order described above;

  • Neither the topic-timeline or its alternate the topic-progress box are added to the topic dom. Both represent the posts in the order they were posted, so they don’t make sense here.

  • 'The show-replies button and the reply-to-tab are prevented from being inserted into post. Both are either don’t make sense or are just visual clutter in this style of topic.
    12 AM57 AM

  • The experience is the same on mobile

Visual example:

Example topic:

cc @supernaturally


Excellent stuff @angus.

The new layout works well and removing the extraneous elements is a great idea.

I wonder if the vote button should be more button-like so people know to press it?

1 Like

I added the plugin in my forum, it’s great!

What is it that you are in a position to create a connection to the device is not enabled. But it’s very good, Congratulations!

I can’t find the setting to turn on the plugin for a category after installation. The plugin shows up in the Admin interface though. Is there anything else I have to turn on?

Fantastic work, this really takes things to a new level. The only issue I’m seeing is still the mobile responsiveness issue, here is a screenshot from an s8: