PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Random Question Quiz

  1. I'm looking to create twenty question quizzes that are populated randomly from a larger repository of questions. This functionality would allow me to give each user a mostly unique quiz.

    So far, the questions are multiple choice and I plan to use conditionals to ensure that user answers are correct before submitting.

    Could anyone advise me as to the best way I might go about ordering my questions randomly?

    Thanks for your time.

    Posted 12 years ago on Monday May 14, 2012 | Permalink
  2. David Peralty

    There currently isn't any way to randomize fields in Gravity Forms. What you would have to do is make a form, and then using our hooks and a good amount of PHP, you would then be able to randomize the field labels and multiple choice field options.

    How much experience do you have with PHP?

    The first part would be hooking into the Pre-render hook we have available:
    http://www.gravityhelp.com/documentation/page/Gform_pre_render

    Posted 12 years ago on Monday May 14, 2012 | Permalink
  3. Hi David,

    I have enough experience to theme in Wordpress and do some basic to moderate things. The good amount of php might trip me up, but I'll check out the pre-render hook. If I can't get that work, I might have to look into a different method. Thanks.

    Posted 12 years ago on Tuesday May 15, 2012 | Permalink
  4. David Peralty

    The steps you would be looking for in the pre-render hook would be to grab from your database or text file of questions and answers, push those details to your labels and values in the fields you've already set up. Test against duplicates, so that you don't show the same question twice in one form. The data in the end result might be a little wonky though, as I'm not one hundred percent sure how much Gravity Forms is going to like it, but it should be something you can hack together. The good news is that once you set up the data feed to pull in questions, you should be able to easily expand the number of questions available in the pool without doing much to Gravity Forms.

    Posted 12 years ago on Tuesday May 15, 2012 | Permalink
  5. Cool. I'm making some headway, but I'm wondering if you could tell me how to modify the following:

    http://www.pastie.org/3916252

    I'm thinking that I could pull in random posts from a category and get their titles to show up in the labels. So, I've changed choices in the code you sent to label. As you mentioned, it could be clunky, but do you think I'm getting close?

    Posted 12 years ago on Tuesday May 15, 2012 | Permalink