Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+9 votes
737 views
in Q2A Core by
This would be a very good feature. Ability to import many questions at once via CSV or other type of file format. Huge time saver for admins creating a new site with desired questions. This should be a core feature. Yes? Thanks for your input.
Q2A version: latest
by
There's a paid plugin for this (see plugins page) and it is not very difficult to create one for self. We use one for our purpose following latex input as that's how our questions are. The core input part is hardly 30 lines of code. But adding to core will be troublesome as different users will have different requirements.

2 Answers

+2 votes
by


It is not really hard to do.

Basic steps:

  1. Parse your questions from CSV file, for example.
  2. Include these files in your script:
    • /qa-include/qa-base.php
    • qa-app-users.php
    • qa-app-posts.php
  3. Now you can use core function qa_post_create() to post questions.
Code example:
----------------
//Parse questions from your source and put data in array

//Include Q2A scripts:

require_once '/PATH/TO/qa-include/qa-base.php';
require_once QA_INCLUDE_DIR.'qa-app-users.php';
require_once QA_INCLUDE_DIR.'qa-app-posts.php';

//Publish questions:

qa_post_create($type, $parentid, $title, $content, $format, $categoryid, $tags, $userid);

----------------

You can find more info here - https://docs.question2answer.org/code/external/

by
What about answers? how to add them?
by
How I can get the id after post?
0 votes
by
There is no bulk import option yet in the core. You will have to do it manually. I have done a couple of complex database migrations and found if you have a database without any customization, then it might be easy, but you may have to import multiple times due to many FKs.

Other developers may have a better approach and be ready to share it with you.
...