# Question Answer Plugin

**URL:** https://meta.discourse.org/t/question-answer-plugin/56032
**Category:** Plugin
**Tags:** deprecated
**Created:** [January 19, 2017, 4:43pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032 "2017-01-19T16:43:47Z")
**Posts on this page:** 20
**Page:** 3

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [August 25, 2017, 1:51am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/46 "2017-08-25T01:51:25Z")

</div>

Ok the new [sandbox](https://discourse.angusmcleod.com.au) is up.

The [Q/A category](https://discourse.angusmcleod.com.au/c/qa) has this plugin enabled.

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [September 25, 2017, 7:09am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/49 "2017-09-25T07:09:45Z")

</div>

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:

 ![359632F7-9B7D-48D7-96DB-F3CD873AD7F0](https://global.discourse-cdn.com/meta/original/3X/a/c/aceaefd91445ebf85179b124f4766225678160cd.jpg)

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.

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [September 25, 2017, 7:11am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/50 "2017-09-25T07:11:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![supernaturally](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@supernaturally](https://meta.discourse.org/u/supernaturally)
#### Post date: [September 27, 2017, 4:53am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/51 "2017-09-27T04:53:47Z")

</div>

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

 ![Screenshot_20170926-215119](https://global.discourse-cdn.com/meta/original/3X/f/8/f8328939aa6cafeb1990789792508f1f6e3ca37b.png)

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

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [September 28, 2017, 1:19am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/52 "2017-09-28T01:19:09Z")

</div>

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 AM](https://global.discourse-cdn.com/meta/original/3X/c/b/cbfd0d58ad31dff5415ce540a3cc1a6170bbbbb8.png) ![57 AM](https://global.discourse-cdn.com/meta/original/3X/d/3/d33182051010dcbd732354513de83954e4c63c7e.png)

- The experience is the same on mobile

Visual example:

 ![Screenshot at Sep 28 09-20-36](https://global.discourse-cdn.com/meta/original/3X/0/3/0327d7a359bcf2fc3a4b2c177a21efb9bfb0bae1.png)

Example topic:

[https://discourse.angusmcleod.com.au/t/can-you-solve-aldhelms-lorica/59](https://discourse.angusmcleod.com.au/t/can-you-solve-aldhelms-lorica/59)

cc @supernaturally

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [September 28, 2017, 6:47am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/53 "2017-09-28T06:47:58Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![wiliamjoaquim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wiliamjoaquim/32/71571_2.png) [@wiliamjoaquim](https://meta.discourse.org/u/wiliamjoaquim)
#### Post date: [September 28, 2017, 11:53am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/54 "2017-09-28T11:53:25Z")

</div>

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!

[https://gojavascript.com.br/](https://gojavascript.com.br/)

---

<div class="post-metadata">

### Author: ![Raphael\_Haase\_NL](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Raphael\_Haase\_NL](https://meta.discourse.org/u/Raphael_Haase_NL)
#### Post date: [September 28, 2017, 2:37pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/55 "2017-09-28T14:37:22Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![supernaturally](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@supernaturally](https://meta.discourse.org/u/supernaturally)
#### Post date: [September 28, 2017, 8:11pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/56 "2017-09-28T20:11:38Z")

</div>

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:

 ![Screenshot_20170928-130851](https://global.discourse-cdn.com/meta/original/3X/3/f/3f6559e28d6b3120784e4b30ac429e65d12d8ced.png)

---

<div class="post-metadata">

### Author: ![wiliamjoaquim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wiliamjoaquim/32/71571_2.png) [@wiliamjoaquim](https://meta.discourse.org/u/wiliamjoaquim)
#### Post date: [September 29, 2017, 5:56pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/57 "2017-09-29T17:56:26Z")

</div>

I noticed a bug, at least for me. After installing, all topics could not be accessed, a connection error occurred, after going in the settings of each category and activate the QnA returned to function normally. But if you do not activate, the error happens.

Now I noticed another, the welcome message from the discobot, is giving error, when creating a new user, and the notification arrives, the user clicks and receives the error of the image, of “_ **we can not load the topic** _”, how can I solve ?

 ![cats](https://global.discourse-cdn.com/meta/original/3X/d/5/d56ad07d429117aaacf297b277ef29613e9d91d0.jpg)

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [September 30, 2017, 2:10am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/58 "2017-09-30T02:10:28Z")

</div>

Strange. I’m not seeing that. That looks like an older version. Try again?

 ![40 AM](https://global.discourse-cdn.com/meta/original/3X/2/a/2a207d293be9aecf878d6b3b79b336bc0f6d17fe.jpg) ![IMG_3298](https://global.discourse-cdn.com/meta/original/3X/3/c/3c8be4b940ae04111e2554ff20f25ca875c3ab2b.jpg) ![19 AM](https://global.discourse-cdn.com/meta/original/3X/8/9/894b7bb8eff1150bda11e1b2d4dbf97243648511.jpg) ![59 AM](https://global.discourse-cdn.com/meta/original/3X/6/7/67024369c62a172cf4bc096acea6c21ff4b6f6bd.png)

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [September 30, 2017, 2:37am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/59 "2017-09-30T02:37:45Z")

</div>

Ok I’ve fixed both issues and also wrapped all the plugin logic in an enabled setting. You’ll need to turn it on for the plugin to work.

[https://github.com/angusmcleod/discourse-question-answer/commit/944496be03df0c8d60ae65a7ff78ba2ad962392e](https://github.com/angusmcleod/discourse-question-answer/commit/944496be03df0c8d60ae65a7ff78ba2ad962392e)

 ![26 AM](https://global.discourse-cdn.com/meta/original/3X/5/7/571bf1b637546aea4d736a294116aa87a65fef31.png)

---

<div class="post-metadata">

### Author: ![supernaturally](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@supernaturally](https://meta.discourse.org/u/supernaturally)
#### Post date: [September 30, 2017, 9:33am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/60 "2017-09-30T09:33:19Z")

</div>

It seems like the error I reported earlier is only occurring in Samsung internet browser (basically a modified chromium build for Samsung galaxy phones), but your sandbox works very well when viewing in either stock Chrome or Firefox.

---

<div class="post-metadata">

### Author: ![dalerka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dalerka/32/120265_2.png) [@dalerka](https://meta.discourse.org/u/dalerka)
#### Post date: [January 27, 2018, 8:19am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/61 "2018-01-27T08:19:37Z")

</div>

Hey! From the UX point (especially for non-tech users) having both the _“Like”_ button and the _“Vote”_ button on a _Question_ is a bit confusing. How about adding settings like:

1. `qa tie votes to likes` - i.e. updating the vote/like count simultaneously for _Questions_ (not answers) and re-positioning based on “Likes”

2. `qa voting button & count` - let’s you select which button+count to show and use for voting on _Questions_ (“vote”, “like” or both) and hide the non-selected from HTML.

Also, if only _“Likes”_ were used to do voting, we get the benefit of not duplicating the existing functionality e.g. the _Count_, the _List of likers (voters)_, and the _“Undo vote”_. Just augment the _“Likes”_ with a setting like:

1. `qa replace like icon` - replaces the “heart” with the “vote” icon (only for _Questions_, not answers).

Later you could add a _“Dislike”_ action to keep a separate count of _downvotes_ (not interfering with “Likes”), and the post’s position score could be calculated based on Likes, Dislikes, and then other factors like (voting time, voter’s reputation etc.).

Yet again, perhaps the existing “Flagging” action could be augmented with an option like _“I dislike this”_ 😞

> [@angus](#):
>
> “Like” button. …The main difference between that button and this plugin is that this plugin re-arranges the posts in the topic based on those that have been supported. This plugin may also add the ability to ‘down vote’ posts.

UPDATE: Just another idea do consider:

1. a setting like: `qa reverse to downvote` - can turn the _voting button and counter_ into a _Dislike_ button, keeping the list of _Dislikers_ ( ☹ or 👎) separate from _Likers_.  
Of course the positioning formula will then account for: _Likes - Dislikes_ and we can style things with CSS.

Just a pic to illustrate current state of the art 🙂

 ![QA%20plugin%20-%20Voters-Likers%20List](https://global.discourse-cdn.com/meta/original/3X/3/2/3245e820b09da6c00ded529461d06e493b187f2b.png)

UPDATE-2: In case the _Downvoting_ be implemented we should consider some protection against troll-voting (too many voters suppress or surface a post).

I’m not sure about a good (yet simple) formula to calculate the position score but it could be like:

```plaintext
PositionScore = (Likes - Dislikes)/TotalVotes 
 + LikeByOwner + LikesByStaff + LikesByMods
 - DislikeByOwner - DislikesByStaff - DislikesByMods

```

Plus a setting to enable such formula instead of simple +/- vote count.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [January 30, 2018, 8:04am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/62 "2018-01-30T08:04:50Z")

</div>

Thanks for the detailed feedback. I’ll try and address your points in a few days when I have the time.

---

<div class="post-metadata">

### Author: ![supernaturally](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@supernaturally](https://meta.discourse.org/u/supernaturally)
#### Post date: [February 1, 2018, 6:36am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/63 "2018-02-01T06:36:27Z")

</div>

@angus Great plugin! I really like the UI of embedding replies - it would be good fun to see if we could work out some UI changes to mimic the [discussion format at Kaggle](https://www.kaggle.com/c/sp-society-camera-model-identification/discussion/47475). In regards to the concept of threaded replies - are there any scalability limitations or issues that your plugin introduces to our discourse instance? I’ve been following the threaded replies discussion, and there are a number of posts that express concerns in modifying the post stream.

> [@Plugin: Ask me anything or Q&A format (threaded replies)](https://meta.discourse.org/t/plugin-ask-me-anything-or-q-a-format-threaded-replies/44950/4):
>
> Not sure you are hearing me – any change to post stream is 10/10 in engineering difficulty due to the massive numbers of assumptions we’ve made about it being in perfect chronological order since 2013. Another reason I don’t like this proposal, on top of the extreme difficulty, is that there is a very simple workaround – simply force a full quote on every reply. So Halo 4 for the gameplay itself. Becomes guy asked What’s your favorite halo game? Halo 4 for the gameplay itself. Pret…

Just curious if this plugin will introduce any potential conflicts to the ‘massive assumptions’ mentioned above (scalability, compatibility with future core updates, etc.)

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [February 2, 2018, 3:55am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/64 "2018-02-02T03:55:45Z")

</div>

> [@dalerka](#):
>
> From the UX point (especially for non-tech users) having both the “Like” button and the “Vote” button on a Question is a bit confusing.

Not sure what you mean here. If by question you mean the first post in a topic, the vote button doesn’t appear on the first post. See e.g.: [https://discourse.angusmcleod.com.au/t/what-has-cities-but-no-houses-forests-but-no-trees-and-water-but-no-fish/55](https://discourse.angusmcleod.com.au/t/what-has-cities-but-no-houses-forests-but-no-trees-and-water-but-no-fish/55)

> [@dalerka](#):
>
> Also, if only “Likes” were used to do voting, we get the benefit of not duplicating the existing functionality e.g. the Count, the List of likers (voters), and the “Undo vote”. Just augment the “Likes” with a setting like

Not sure I agree 🙂 I think there’s a difference between liking an answer and thinking it’s the correct answer. For example you could like an answer because it’s funny, but not think it’s the best answer to the question.

> [@supernaturally](#):
>
> Just curious if this plugin will introduce any potential conflicts to the ‘massive assumptions’ mentioned above (scalability, compatibility with future core updates, etc.)

No doubt, there will be further issues this plugin needs to overcome. As Jeff says in that topic you linked, there are indeed a number of parts of the app that assume the posts are in chronological order. I’ve dealt with some of the key ones in this plugin. But there will probably be more.

Personally, I still consider this plugin to be speculative. I’m planning to use Discourse Solved for questions on my own site, at least for now.

That said, it does actually work. Try it out on your own test instance and it will work as described. If you’re sure you need this style of QnA to work in Discourse, you could hire a dev (or do it yourself) to test all the edge cases and related functionality that the changes to the topic order might affect. Things like: topic entry (i.e. where does the topic scroll to), topic tracking time (i.e. reading time), or how it handles long threads. If after extensive testing you’re satisfied, then use it by all means.

In terms of future compatibility, core Discourse may well introduce new logic that assumes a topic’s posts are in chronological order, in which case this plugin will have to be updated to handle that as well.

That said, there is actually a `sort_order` property for Posts in core Discourse which is seperate from `post_number`. Currently there are two sort orders in Core Discourse (see `models/post.rb` - I don’t think `reverse_order` is actually used though):

```plaintext
def self.regular_order
 order(:sort_order, :post_number)
end

def self.reverse_order
  order('sort_order desc, post_number desc')
end

```

The way this plugin works is to introduce a new (slightly more complex) sort order:

```plaintext
answers = posts.where(reply_to_post_number: [nil, ''])
          .where.not(post_number: 1)
          .order("vote_count DESC, post_number ASC")

count = 1
answers.each do |a|
   a.update(sort_order: count)
   comments = posts.where(reply_to_post_number: a.post_number)
      .order("post_number ASC")
   if comments.any?
      comments.each do |c|
        count += 1
        c.update(sort_order: count)
      end
   else
      count += 1
   end
end

```

The `sort_order` column is not going away any time soon. It’s existence anticipates that there can be other orders apart from the chronological order (i.e. post number).

---

<div class="post-metadata">

### Author: ![dalerka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dalerka/32/120265_2.png) [@dalerka](https://meta.discourse.org/u/dalerka)
#### Post date: [February 2, 2018, 12:42pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/65 "2018-02-02T12:42:49Z")

</div>

> [@angus](#):
>
> Not sure what you mean here. If by question you mean the first post in a topic, the vote button doesn’t appear on the first post.

Sorry I misstated, in this case I meant an _answer_ (not Question) for which people can _vote_, but also _“Like”_.

> [@angus](#):
>
> you could like an answer because it’s funny, but not think it’s the best answer to the question.

Valid point. For my use case I believe it is better to “disable” likes for posts which have a voting button. Sure, we could hide the _“Like”_ button and the list of _Likers_ with CSS, but that would not prevent abuse with the browser console.

So, perhaps it would it be possible to add an optional global setting to e.g.:  
`qa disable likes on answers` - prevents rendering of _“Like”_ button and the list of _Likers_

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [February 3, 2018, 5:42am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/66 "2018-02-03T05:42:13Z")

</div>

Sure, why not :). Here you go:

[https://github.com/angusmcleod/discourse-question-answer/commit/2e6304c9147d544e9f2ebe69ff559b944667d8e7](https://github.com/angusmcleod/discourse-question-answer/commit/2e6304c9147d544e9f2ebe69ff559b944667d8e7)

---

<div class="post-metadata">

### Author: ![dalerka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dalerka/32/120265_2.png) [@dalerka](https://meta.discourse.org/u/dalerka)
#### Post date: [February 4, 2018, 8:39am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/67 "2018-02-04T08:39:25Z")

</div>

Thank you once again!  
To make UX & styling customizations easier, would it be possible to do the following:

1. Wrap the text nodes in a `span` tag? (e.g. _“voted for this”_, _“N persons voted for this post”_ etc.)

2. Change _“N persons voted for this…”_ to a simpler: “Show/Hide voters” button?

Even better, let the _Vote count_ become a _button_ in charge of showing/hiding the list of voters?  
(similar to how _“Likes”_ counter works)

1. Not duplicate the _voters count_ (as the _vote count_ already reflects this)?

UPDATE:  
4. Toggle “.active” class on “.qa-post button” (if user voted/unvoted), so we can give a better visual feedback (again, similar to the _Like_❤ button).

[Previous page](https://meta.discourse.org/t/question-answer-plugin/56032.md?page=2)

[Next page](https://meta.discourse.org/t/question-answer-plugin/56032.md?page=4)
