E-Learning Learning Management Systems WordPress WordPress Basics WordPress Solutions

How to Create Personality Assessment Type Quizzes Using Gravity Forms Plugin

Personality and assessment quizzes are a great way to engage and learn about your audience. Here is how to create them using Gravity Forms, so you can build interactive quizzes without a dedicated quiz platform.

Namrata Namrata 6 min read

quiz-bannerHave you taken the ‘What kind of X are you’ quiz? I have.

Most of the times you can predict the result and manipulate it. Nevertheless, it is just as fun. It basically is a very crude personality assessment quiz. The answers are multiple-choice and are always displayed in a particular order. The results are based on the answers you choose.

So, say there are 4 choices for each result (a,b,c,d). Mostly a’s would mean you are type A, mostly b’s would mean you are type B, and so on. Optionally the answers have weights, and you evaluate based on your score. You get the idea.

If you have no clue on how to add such a quiz on your WordPress or LearnDash website, I’d suggest you search for a plugin. A suitable solution would really depend on your requirements. But, if you want total control on the functionality you’ll be better off building it yourself or having it custom-built by professionals.

I’ll warn you right away, that there will be some code involved. Don’t stress. But, code is not scary. Once you have the logic in place, coding is a breeze.

Here’s what we’ll need to do:

  1. Get the Gravity Forms plugin (if you do not already have it)
  2. Create an Assessment Type Quiz
  3. Evaluate and Display Results

[space]

Why Gravity Forms?

We’ll be using the Gravity Forms plugin as a base for the quiz. The reason we have selected the Gravity Forms plugin is that it reduces the effort by- a LOT!

You see, the functionality you need is readily available. You have an option to add radio buttons, and also to effortlessly split the questions across sections to create a multi-part form. (This will be clear when we actually create the form).

You have the option to store results in a hidden field, style the form as per your theme, allow notifications to be sent on form submission, as well as the option to process values using available hooks.

You basically have your job cut out.

[su_note note_color=”#EDEDED”]

NOTE:

If you’re trying to achieve something like this on your LearnDash website, there’s a workaround you should know about.

[space]

The default multiple-choice quiz question type in LearnDash will allow you to create the questionnaire. Once you have the questions ready, you can assign weights, points or a score to the options and have the suitable assessment displayed. 

If you choose to go ahead using this method, you need not use the Gravity Forms plugin at all.

[/su_note]

How to Create the Quiz?

Since we will be essentially creating a quiz, some of you might be wondering if we will be using the Quiz Add-on for Gravity Forms. We won’t be using this add-on, because it doesn’t help us. This add-on is focussed on creating examination type quizzes, and instead of tweaking it, we’d be better off creating our own solution.

Moving on.

For every quiz we create, we have to create a new form. As an example, let’s consider we want to create a ‘Which Superhero are you’ quiz.

Step 1: We’ll have to create a new form and name it ‘Which Superhero are you’.

Step 2: Each question will have to be added as a ‘Radio Buttons’ field. Add the question as the field name, and options as possible answers.

Step 3: To assign weights to each answer, check the ‘show values’ checkbox for the field, and add values.

gravity-forms-quiz-questions
Creating the Quiz

Step 4: If every question has to be answered, make each question a required field.

Step 5: To format the display of the form, you can choose to create a multipart form, and add a question on every section. For this, you would need to add a ‘Page Break’ field after every question.

Step 6: We’ll also be using a hidden field to store the result. This will be used once the form is filled but before notifications are sent. Add this field at the end of the form in the last section.

gravity-forms-hidden-field
Adding a Hidden Field

Once you have the fields in place, save the form. Pay attention to the form and field ids, we will be needing these in our code.

[space]

How to Evaluate and Display Results?

Now, we’ve come to the main point. We have to evaluate inputs and display the corresponding results. For this we need to use the gform_pre_submission’ hook. Using this hook, we can calculate the aggregate of the results and update the hidden field value, before the form entries are saved.

Lets consider you’ve added 5 questions, and the sixth field is the hidden field. Since we have assigned a value to each field, we would have to calculate the total of all selected fields and show the result based on the total. In the $_POST variable, the key for each field would be input_{field_id}. For example, for field id 4, the value would be $_POST[“input_4”];

add_filter("gform_pre_submission_3", "wdm_evaluate_results");

function wdm_evaluate_results($form)
{
    $total = 0;

    // add the values of selected results
    $total += $_POST["input_1"] ;
    $total += $_POST["input_2"] ;
    $total += $_POST["input_3"] ;
    $total += $_POST["input_4"] ;
    $total += $_POST["input_5"];

    // set the value of the hidden field
    $_POST["input_6"] = $total;
}

Now that we have the result, we can display a message using the confirmation notification settings for the form, and by using some conditional logic.

gravity-forms-confirmation-for-result
How to Display Results

In continuation with our example, say you are ‘Batman’ if your score is less than 30. In that case you have to add a confirmation, which will be displayed only if the value of the hidden field is less than 30.

And you’re set! You have your own personal assessment quiz.

Wrapping Up

A majority of our clients who’re always looking to upgrade the quizzing modules of their site are primarily LMS and LearnDash website owners. If you’re one of them, here’s something that might interest you.

[su_note note_color=”#EDEDED”]

[/su_note]

That’s all for today. Be sure to try it out and send me links of the assessment quizzes you create using the comment section below!

Cheers!

[space]
[freepik]

Get a FREE Consultation

Let's build something that lasts.

Share what's on your mind — a clear brief, a half-formed idea, or just a sense that something needs to change. We'll listen first, ask the right questions, and point you toward what's actually worth building.

We take on a handful of projects each quarter,ones where we can truly make a difference.

  • Receive a human response within 24 hours
  • Get a detailed scope and quote upfront
  • We're happy to sign an NDA upon request

    Free 30-Min Strategy Call

    Your Name *

    Your Phone No *

    Work Email *

    Your Budget*

    Project Details *