Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
2.6k views
in Q2A Core by
edited by
I am building a site oriented to math problems. We usually study by solving problems; and even when someone has posted a valid answer to a problem, the other users may want to try to solve the problem independently before seeing the answer.

I would want to be able to provide a system that would allow the users to read the contents of the questions and try to solve them by themselves; without forcing them to read the other answers on the same page.

Any ideas on how to achieve that? Is there any plugin which could help me?
Q2A version: 1.7.3
by
I use a "hide answer by default" option. Unfortunately it is done by a core hack. Users can then select this from their profile.
by
I have done a simple plugin for you. I will deploye repository and let you know.
by
I am also very interested in the hide "answer by default" option by arjunsuresh. How did you create it?
by
I have done it using core hack- that is changing the Q2A code at multiple places which is not good for updates (so I still use Q2A 1.7.0). But I plan to make it as independent of the core as possible or even make this a proper plugin. The fact that I used a core hack is because I wanted a filter module (filter questions based on tag) and answer hidden by default went quite nicely with it. I'll try releasing this plugin soon. If I remember only things to do are
1. Create user option
2. Override answer list display function and hide answers by default
3. Requires a javascript to toggle the answer display.

2 Answers

+2 votes
by
selected by
 
Best answer
This is my logic. But I haven't tried anything yet practically. However, I believe it should solves your problem.

1st and easy way is to use jQuery. What you need to do is add a checkbox or a text link or element and than by default hide entire Answers container (parent container is .qa-a-list)

Now if the use want to see other answer, s/he will click on the checkbox or text link to unhide all answers otherwise he will write own and submit.

The only problem with this solution is it wil always keep hidden everyone's answers including the user.

 

2nd logic

You can modify answers list method in theme or by plugin layer. And conditionally display other answers if users has already given an answer for that question. This is more rock solid but required little bit php works.

So the user will only see the question if s/he hasn't given any answer yet. Once post an answer on that question, s/he will be able to see all other' answers including his/her.

This is not so difficult to do just need to do some R&D and query. You also may like to use AJAX to display answers as soon as user post his/her.
by
I think the first logic is enough for me, but I will try the plugin too. Thank you!
by
Okay cool...! BTW, the plugin I made it does the same but more robust than jQuery. As once the user has given an answer, he will be able to see all other answers without clicking on anything. But it's your choice.
by
Oh, I see! I have to try it yet, but it sounds perfect for me. Thank you very much.
+5 votes
by

Here is the plugin for it

Download from Q2A Market Store

Download from Github

Git clone command

git clone https://github.com/q2amarket/Answer-Visibility.git
by
Nicely done...
Release the plugin as a fresh question as well...
by
Oh.. good idea
by
Thanks for the plugin, it is exactly what I have been looking for.
by
You are most welcome...!
...