Importing questions from external database

Importing questions from external database

by Maurizio Scibilia -
Number of replies: 9

Hi everyone,

I'm using the Moodle 2.6 version and I need to be able to import questions (and answers) from an external database (Microsoft Access would be perfect 'cause my client uses this, but of course I can convert it if needed), chosing (the number of questions in the database is higher than the number of questions in the database) and presenting them randomly to students. Is there any way to do it? Modifying some php or how? Any help would be appreciated. Thanks in advance.

 

PS: Sorry if a question like this was already posted but I didn't find it.

Average of ratings: -
In reply to Maurizio Scibilia

Re: Importing questions from external database

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Is this something you need to do just once to load stuff into the Moodle question bank, or is it something that needs to happen every time a student starts the quiz?

The former is easy. Make a script that takes the data from the database, and creates a Moodle XML format file that you can then import into the question bank. http://docs.moodle.org/26/en/Moodle_XML_format

If the latter, it is hard. In which case please clarify exactly how you see this working. Perhpas descripe what data you expect to flow from where to where as a student attempts a quiz.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Importing questions from external database

by Maurizio Scibilia -

Thank you Tim,

I need it once. I mean, they'll send me a list of multiple choice questions (and answers) that I have to put in the question bank (I presume) and then, for every test, pick a certain number of them and build the quiz. The number of questions will be enough to guarantee that every test is different. So it's the former case among yours. I hoped to find a solution without the need to produce a script, but your solution is the more natural, in its own way.

In reply to Maurizio Scibilia

Re: Importing questions from external database

by Mark Hardwick -

I've had two experiences with imports into Moodle.

1). Initially we loaded a ton of questions into Moodle when we first started a few years ago with a program we found (Respondus 4.0) that helped a great deal.  We were able to copy our questions from our previous system into Respondus and then import them into Moodle.  I believe this program has other uses where a instructor can write questions in 4.0 and then import them into Moodle.  In this event an instructor could get questions the way they wanted them and then move them to Moodle.  (Maybe an instructor does not have rights to the question bank System and develops questions on their own computer and then submits them to be imported).  However, we used the program as a one-time tool.  This program does not allow an instructor to manage the question once in Moodle.

2). I've found that Access cannot be imported directly into Moodle.  In my version of Access you cannot save a file as a CSV.  You have to run it into Excel and then save it into a CSV file, then import it into Moodle.  I've never tried to import a question but we export our student enrollments from Access-into-Excel, then save as a CSV file, then import into Moodle.

Not exactly what you asked for but maybe helpful.

Mark

 

 

In reply to Mark Hardwick

Re: Importing questions from external database

by Maurizio Scibilia -

Thank you Mark,

your experience is actually helpful. I don't think that for my client will be a problem to produce a CSV instead than an MDB. Actually I could ask them to put even the students data in an Excel File, if it did my job easier. I have just one question about the solution that you are proposing (please consider that I am a real newbie with this environment, so forgive me, cause I am starting to use it and I feel pretty ignorant about it): once I have my CSV file, is there a way to load its data to my question bank from the panel (without producing a script I mean)? And, if yes, how?

In reply to Maurizio Scibilia

Re: Importing questions from external database

by Mark Hardwick -

I've never imported quiz questions through a CSV file.  When we used Respondus 4.0 to import questions and it guided us through the process and just asked you where you wanted to put stuff.  It was fairy inexpensive as I recall and an easy download.

When importing student information for enrollment the hardest part was making the import table EXACTLY like the back-end programming in Moodle.  For enrollment there is an "import" button that you use.  Again, getting your Excel table exactly like Moodle is the only way it will work.  Things like: "Email Address" is "email" and "Sur Name" is "lastname" etc.  This took some digging to figure out what to call everything.  I don't know anything about PHP code but by viewing the registration code page and asking some questions here I finally got them to sync.

Mark 

In reply to Mark Hardwick

Re: Importing questions from external database

by Maurizio Scibilia -

Thank you again Mark.

Cause I can't see any CSV between the file formats.

 

In reply to Maurizio Scibilia

Re: Importing questions from external database

by Paula Clough -

Maurizio,

I think Mark was talking about the uploading of students into Moodle with CSV file.  The information is here.    

If the people you are working with can give you and Excel file of the user data, it's easy to manipulate in Excel and get the correct column titles etc, then save as a CSV file to do the upload process. 

cool

In reply to Paula Clough

Re: Importing questions from external database

by Paula Clough -

Maurizo,

I found a forum discussion here with an Excel file which has a built in button for making GIFT files.  It was only for multiple choice questions, but perhaps that will help, if you can separate the correct answers and put them first easily. I tried some sample questions and they imported very easily.

cool

 

In reply to Paula Clough

Re: Importing questions from external database

by Maurizio Scibilia -

Thank you twice Paula and sorry for the delay of this answer (for some weird reason the answers to my post were on my SPAM folder). Regarding the GIFT maker, I just have multiple choice questions, so that's good; but on the other side it's still not completely automatic as I've been dreaming of (I mean: Excel file in input, questions in your system in output). On the users side, I was able to import them, but just from a text file, not csv. I attach the import mask in my Moodle, but even if it talks about CSV, it makes impossible to import them.

Attachment import.JPG