Question Answer Plugin

Ok the new sandbox is up.

The Q/A category has this plugin enabled.

4 Likes

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.

2 Likes

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

2 Likes

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.

1 Like

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:

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

cc @supernaturally

6 Likes

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!

https://gojavascript.com.br/

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:

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 ?

1 Like

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

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

26 AM

6 Likes

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.

1 Like

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” :disappointed:

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 ( :frowning: or :-1:) 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 :slight_smile:

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:

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

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

4 Likes

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

4 Likes

@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. 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.

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

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

Not sure I agree :slight_smile: 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.

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):

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:

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).

4 Likes

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

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

1 Like

Sure, why not :). Here you go:

https://github.com/angusmcleod/discourse-question-answer/commit/2e6304c9147d544e9f2ebe69ff559b944667d8e7

4 Likes

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 :heart: button).

3 Likes