Exporting Lessons

jlrobinson2171
Forums
I know you can import questions and answers with an Excel file. Is there a way to export the questions and answers easily? This is strictly for multiple choice questions.
Profile picture for user James Aparicio
James Aparicio

Hi jlrobinson2172,

Hi jlrobinson2172, Currently it is not possible to export a quiz. Is there a particular reason why you want to do it? Is it to reuse the quiz? Or what you want to export are the answers the users have given? Exporting results is on our todo list. Best regards
jlrobinson2171

I don't have a good reason.

I don't have a good reason. I'm kind of re-thinking how I want to do things and want to start with a fresh install of Opigno but don't want to redo all of the questions (3 lessons, 135 questions total), so it would be nice if I could export them to a CSV and then import them back in.
axel

Hi jlrobinson

Hi jlrobinson I understand your request. Of course an export tool would be useful, and this will for sure be developed in the future (still not assigned to a precise release in our development roadmap, but it will be done). In the meantime, I think you can do a simple database query to get the question list of each one of your 3 lessons (we can help you to build this query of course, don't hesitate to ask us on this forum), and then slightly rearrange it in Excel to reimport it. Best regards,
jlrobinson2171

I was thinking that a DB

I was thinking that a DB query could be done but that is expertise I am lacking so some help would be nice.
Profile picture for user James Aparicio
James Aparicio

Hi jlrobinson2171

Hi jlrobinson2171 You can start by getting the quiz nodes that you are interested in exporting. "Select * from node where type='quiz' and nid IN (X,Y)" where X and Y are the quiz ids of the nodes you want to export. This is the query you want to start with. You can check how to do it with Drupal in php here. https://api.drupal.org/api/drupal/includes!database!database.inc/function/db_select/7 Best regatds
jlrobinson2171

Ok, that works and gives me a

Ok, that works and gives me a list of the quizzes.
jlrobinson2171

So how would I go about

So how would I go about getting the questions and answers associated to the particular quiz?
Profile picture for user James Aparicio
James Aparicio

Hi jlrobinson,

Hi jlrobinson, With the quiz you can call the function quiz_get_questions that is inside quiz.module. Check this function. Best regards
jlrobinson2171

Thanks for the hint but it is

Thanks for the hint but it is best that you think of me as someone who knows absolutely nothing about programming and building scripts. Right now I know the node id's for the lessons created. Is it possible to build a script that will pull the questions with their associated answers based off the node ID of the lesson? I know it is possible but being the simple guy I am I have absolutely no idea on how to do it.
Profile picture for user James Aparicio
James Aparicio

Hi jlrobinson,

Hi jlrobinson, The first query that you ran gives you the node id (nid) but also the last revision id (vid). $quiznodeids= array(13 => 19, 14 => 20); // the list of your quiz id => quiz vid; foreach($quiznodeids as $quizid => $quizvid) { $questions[$quizid]=quiz_get_questions($quizid,$quizvid,TRUE,TRUE,TRUE,TRUE); } $questions will contain the list of questions for each quiz Best regards