Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
481 views
in Plugins by
Hello,

I was wondering if there is a plugin which can be used to create a new question, by "forking" an existing one? As an example, there might be a question in a forum which asks for a method to remove stains from wool. I would like to be able to fork that question, into a new "branch" which asks about stain removal on polyester. Really bad example... but you get the point.

I assume that such a plugin does not exist, so I thought Id might make it my first q2a plugin assignment :-).

As a starter, I would try to add a button on the question page, similar to the "flag as inappropriate", but which simply creates a new question. This should be straight forward I hope. As a next step I would try to associate the new question with the old one. Would it make sense to use the "parentid" in the qa_posts table for that? Or is this not a good idea?

Any other pointers before I start (except http://docs.question2answer.org/plugins/ of course)? I'm a novice on q2a but with a basic grasp of php/css.

Thanks in advance!
Q2A version: 1.7.4
by
So did you make any progress on this?
by
Not progress really... reading and building an understanding. I hope to have more time next weekend, for some actual work.

1 Answer

+2 votes
by
edited by

Well, I didn't quite get what the plugin does. What I got is that it sounds like a "Make similar question". This would be a button that once clicked would take the user to the ask page and will prepopulate all fields with the same values as the original question.

Now, it is not clear to me why you think it is necessary to keep a link to the original question. I mean, does it really matter what question was the "removal from polyester" question based on? I will assume it does, based on your comment.

These are the high-level steps to create that plugin:

  1. Create a table to store a given question and the question it was based on. E.G.: ^similar_questions(question_id, based_on_id). Both foreign keys to the ^posts table and are themselves a compound primary key
  2. Add the "Make similar question" button to a question (use a layer)
  3. Prepopulate all fields in the ask.php page (I think you will have no other choice than using a layer again). You can base your changes on how the question edition is done
  4. Add the "This question is based on ..." to the question being created (layer, again)
  5. When saving make sure to update your ^similar_questions table. (maybe a layer for this will be a good choice... you could use an event module and check the POSTed variables there but seems to be inappropriate as you're actually accessing data that is not strictly part of the event)
  6. Add the "This question is based on ..." to questions being viewed (layer, again)
  7. Commit and push to GitHub

You could get some hints on how the "Ask a related question" feature works.

...