• Resolved Henry

    (@henrychea)


    Hi Harmonic, is there a way to import questions directly in a quiz with csv or xml files? I see that I can export just the questions to xml but what about the quizzes?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    This is actually a complicated subject.

    Basically, WordPress did not have “custom taxonomy meta”, so quiz settings/options are saved to the wp_options table.

    This means that if you export questions using the default WordPress export tool, then the export will contain a list off all of those questions and all question meta, but only a reference to the quiz. So you’ll be able to import that file again without issue, and it will restore the quiz – even on a new site, but you’ll need to reset any custom quiz settings you may have had, such as custom pass/fail text.

    There is no CSV import/export tool for HD Quiz. The main reason is that everyone’s needs are completely different on how they want or need the file to be formatted. If I ever built a tool for that, I’d spend more time supporting the tool than I would supporting the main actual HD Quiz haha. CSV files need to be PERFECTLY formatted, or it will cause an absolute ton of mess.

    What is your use case? Do you already have a CSV that you’d like to import?

    Thread Starter Henry

    (@henrychea)

    I do have a few thousand questions in CSV. If it’s possible I could convert it to xml or and format that wordpress can accept. It doesn’t have to be CSV

    Plugin Author Harmonic Design

    (@harmonic_design)

    You sure like to keep things hard for me!

    My largest concern is with the formatting. CSV is the best format to do the import, but it’ll need to be formatted in a certain way to ensure that nothing breaks during the format. The largest issue is with “special characters”, and especially, quotes and commas.

    CSV stands for Comma Separated Values. This means that if your question title or any of the answers have a comma in them, then it would completely break the import.

    So step one is to clean your data to remove any commas from titles or answers.

    Here is an example row for a good CSV file.

    questionTitle, quizID, answer1, answer2, answer3, ... , answer10, correct

    The above fields would be mandatory, and the correct field would be an integer (number) that corresponds to the correct answer. So if answer3 is the correct answer, then correct should have a value of 3.

    If you want, we could also extend this with option fields such as if pagination should be enabled, set the featured image, etc.

    If you could create a CSV export formatted like above, and ensure that there are no errant commas, then I think I can help you create an automatic import tool.

    Thread Starter Henry

    (@henrychea)

    Hi I’ve found a way to do it with automated Selenium instead on my local server and then export and import it onto the live server

    Plugin Author Harmonic Design

    (@harmonic_design)

    Selenium is a great idea! Glad you got a working solution.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Add questions with xml or csv’ is closed to new replies.