• Skip to content
  • Skip to footer
A Bright Clear Web

A Bright Clear Web

A Bright Clear Web - Simple, effective, accessible websites

  • Home
  • About
  • Websites
  • Writing
  • Learn
  • Blog
  • Contact
You are here: Home / WordPress / How To Create a Gravity Forms Quiz With Multiple Outcomes

How To Create a Gravity Forms Quiz With Multiple Outcomes

Posted: July 23, 2016 Updated: January 4, 2018 by Claire Brotherton
15 Comments

The word quiz and school doodles against student's desk with tablet pc

The word quiz and school doodles against student's desk with tablet pcFor a project I’m working on I needed a WordPress quiz solution.

There were some specific requirements:

  1. The quiz should have Yes/No answers.
  2. The quiz should be split into several pages, with one question per page.
  3. The quiz should keep overall score, but not offer instant feedback to users i.e. users should not be told straight away if they got the answer to a particular question “wrong”.
  4. An overall score should be displayed on quiz completion.
  5. There should be different feedback given for various scores, with 3 possible overall outcomes.

I had a look at some different quiz plugins for WordPress, including Riddle, which I reviewed in an earlier post.

Unfortunately, I couldn’t find one that met my exact needs.

Then I stumbled upon the knowledge that Gravity Forms, a powerful form creation plugin, also had a quiz add-on.

I happened to be using Gravity Forms on the site anyway, so I took a look to see if it met the needs of the project.

Gravity Forms Quiz Add-On

The Gravity Forms Quiz add-on is available to Gravity Forms Developer license holders.

At the time of writing, this costs $199/year, though there is a 50% renewal discount.

Installation

The Gravity Forms plugin comes in a zip file to upload at Plugins > Add New > Upload Plugin.

After adding your license key and configuring settings, the Quiz add-on can be installed from Forms > Add-Ons.

Creating the Gravity Forms Quiz

I created a quiz with 5 questions. The questions and answers came from this list of UK farming facts.

Questions were added using the Quiz field, which is an Advanced type of form field.

Here’s what a single question looked like:

Gravity Forms Quiz question

The options I chose for each question were:

Quiz Field Type – Radio Buttons (Dropdown selectors and checkboxes for multiple selections are also available.)

Quiz Answers – Yes or No. (Yes marked as the correct answer.)

Rules – Required checked. Each question must be answered before proceeding to the next.

Note: In the Appearance section, you can set a Custom Validation Message. See the section on form validation below.

I then duplicated the quiz field and just changed the question.

The questions were separated by page breaks using the Page field.

I chose to have some introductory text at the start and an image, inserted into an HTML Block.

A Gravity Forms HTML Block

Here’s what the opening section of my quiz looked like:

Farming Quiz with image of a barley field

Quiz Settings

The grading for the quiz was set in the form’s Settings > Quiz.

I chose a Pass/Fail grading and set a grading of 80%.

The pass/fail confirmations were set after this.

The defaults are:

Quiz Pass Confirmation

<strong>Quiz Results:</strong> You Passed!
<strong>Score:</strong> {quiz_score}
<strong>Percentage:</strong> {quiz_percent}%/code>

Quiz Fail Confirmation

<strong>Quiz Results:</strong> You Failed!
<strong>Score:</strong> {quiz_score}
<strong>Percentage:</strong> {quiz_percent}%

I changed these by removing the Passed/Failed message and percentage, and adding my own text.

Confirmations

I wanted 3 outcomes, however, not the two that the Quiz Settings offered.

The way around this was to use Gravity Forms built-in Confirmations instead.

This is a really powerful feature that shows the user a different result when the form is completed, depending on their answers.

All forms have a default confirmation – “Thanks for contacting us! We will get in touch with you shortly.”

You should amend this to something like “Thank you for completing the quiz.”

You can then set any number of others. Each new confirmation should have conditional logic which indicates who gets to see it.

You could set logic for getting a particular question right or wrong, or based on the quiz percentage or quiz score total. I used the total.

Confirmations can either be Text (complete the textarea), Page (redirect the user to a page on your site) or Redirect (redirect to an external URL.

I set 3 different score bands with 3 different results:

  1. A score of 0 or 1
  2. A score of 2-4
  3. A score of 5

Here’s an example of a confirmation and its conditional logic:

Gravity Forms confirmation

The confirmation is set to show if the quiz score total is less than 2.

After testing, this seemed to work nicely.

Notifications

One other thing you might want to do is to turn off admin notifications if you don’t want an email every time someone completes the quiz.

All entries are saved in the database, in any case, and can be viewed under Quiz Results for your form.

Inserting the Quiz on a Page

This is done like any other form by using the Add Form button on a page to insert a shortcode. You’ll probably want to hide the title and possibly the description as well.

I put my quiz in a 50% width column, just in case you’re wondering! Otherwise, it will occupy the page width.

Handling Form Validation Errors

Because I required each question to be completed, failing to select an answer before moving to the next question threw an error.

Gravity Forms validation error for an incomplete answer

The error messages were not very elegant, and I wanted to change them to something a bit more user-friendly for a quiz.

To change the overall ‘There was a problem with your submission’ message, I used this code:

add_filter( 'gform_validation_message_2', 'quiz_validation', 10, 2 );

function quiz_validation( $message, $form ) {
return "<div class='validation_error'>Oops! You forgot something!</div>";
}

The number 2 following gform_validation_message limits the altered validation message to just the form with ID 2. This means the code won’t affect your other forms.

To change the ‘This field is required’ message, I set the Custom Validation Message for each field on the form to ‘Please select an answer’.

Set a Custom Validation Message in Gravity Forms

If you’re building the quiz, this is best done before duplicating the quiz fields!

I also added a little custom CSS to add a little padding to the error section:


.gfield_error {
padding: 10px;
}

Modified error messages for my quiz

Much better.

Gravity Forms for Non-Admins

If your quiz was being built for a client, and they wanted to add or edit their quizzes, one issue is that only administrators can make new forms – and by extension, quizzes.

You can, however, get round this by a few methods outlined in Ryan Benhase’s excellent post on giving Editors access to Gravity Forms.

If you do this using the User Role Editor plugin, you’ll need to set some permissions. I suggest the following settings.

User Role Editor settings for Gravity Forms Editors

The main issue with non-admins creating their own forms is with users entering rich media content or formatted text.

Why? There’s no visual editor in the form builder available to do this easily. The only way to do it is to add an HTML block to the form and enter the relevant code.

I’m not too sure why this is so, because there is a visual editor for the Confirmations.

Until I find a better solution, the best workaround is to:

  • Create a new post or a page
  • Enter the content you want into the Visual editor
  • Switch to Text mode
  • Copy and paste the HTML code into a new HTML block

Unfortunately, it’s a bit hacky.

Pros and Cons of Gravity Forms Quiz

Pros

  • Display results by score, percentage, letter grading (A-E) or no score at all
  • Instant answer feedback (optional)
  • Create any number of results pages
  • Error messages are customizable
  • Control over the quiz look with CSS – most online quiz solutions give you limited control unless you pay
  • Results are saved or can be emailed to you

Cons

  • Cost – $199/year, $99.50/year thereafter
  • Less usable for lay people
  • No inbuilt social sharing of the quiz – you would need to add your own social sharing buttons, and likely limit them to the quiz page only.

Have you used Gravity Forms Quiz add-on? Would you? Let me know in the comments.

Related

Category: WordPress Tags: Gravity Forms, quiz

About Claire Brotherton

Freelance web designer and front end developer based in Edinburgh, Scotland. I love WordPress, code, learning and blogging.

Reader Interactions

Comments

  1. Valerie Adler says

    July 23, 2016 at 10:23 am

    What a great post, Claire, and a very empowering tutorial! Gravity Forms is incredibly powerful, well-supported and definitely worth the investment. Thanks for sharing your hands-on experience.

    Reply
    • Claire Brotherton says

      July 23, 2016 at 8:01 pm

      Thanks Valerie. I think I’ve only just realised how powerful Gravity Forms can be. 🙂 Glad you found the post helpful.

      Reply
  2. Martin says

    August 23, 2016 at 2:47 pm

    Excellent post! Can you please share the link to the quiz so I can see the example… thanks

    Reply
    • Claire Brotherton says

      August 26, 2016 at 9:46 pm

      Thanks Martin. The quiz is no longer online.

      Reply
  3. terry says

    August 23, 2017 at 12:06 am

    hi there,

    I am using gravity quiz on our website and if you try to complete the quiz while logged on, it shows the result % without any issues.
    But when I am not a logged in visitor of the website, it doesn’t show me the result of my quiz. Can you please help me how to fix this.

    you can try it here: http://www.safetynaction.co.nz/consultancy/

    Scroll down a little bit and the quiz is on the right hand side column.

    Thanks

    Reply
    • Claire Brotherton says

      August 27, 2017 at 11:05 am

      Hi Terry

      I see the problem. Not sure what’s going on there. I think you’d be best contacting Gravity Forms support so that they can troubleshoot the issue.

      Reply
  4. Nahuai Badiola says

    November 30, 2017 at 9:49 am

    ¡Great tutorial!

    I’m thinking on doing some quiz on me website so it was really heplful.
    Thanks for sharing Claire.

    Reply
    • Claire Brotherton says

      December 1, 2017 at 9:57 pm

      Cheers Nahuai!

      Reply
  5. Pablo says

    April 4, 2019 at 8:32 am

    Hi,

    I would like to add the average score, is that possible?

    Thank you!

    Reply
    • Claire Brotherton says

      April 5, 2019 at 12:26 pm

      Hi Pablo

      You can find out the average score for any quiz in the back end under Forms > Entries > Quiz Results tab.

      You could then hard code in that value to your form confirmation.

      If you need to keep the average score dynamically updated, then that looks harder. I suspect you’d need some custom code to do it.

      Reply
  6. aria says

    July 1, 2019 at 9:40 am

    Hi, thanks for this useful post.

    Is there any way to use multiple questions in each page section and scores calculated on each separate page and show to viewer?
    for example i need 5 page and 5 different score for each section (page) and also total score (sum of all 5 page scores)

    Thank you.

    Reply
    • Claire Brotherton says

      July 1, 2019 at 2:25 pm

      Hi Aria, glad you found the post useful.

      I’m honestly not sure if it’s possible to calculate the score per page. Gravity Forms Support may know, if you ask them.

      Reply
  7. Ben says

    November 27, 2019 at 10:22 pm

    How do I make it show one question at a time and have the next button?

    Reply
    • Claire Brotherton says

      November 27, 2019 at 10:33 pm

      Hi Ben,

      I think you just add page breaks to your form, as shown here: Creating Multi-Page Forms

      Reply
  8. David Bentley says

    January 21, 2021 at 7:22 pm

    I know this is a bit of an old post, but I have a recommendation for making the experience better – https://wordpress.org/plugins/auto-advance-for-gravity-forms/. It’s a free plugin that makes it easy for people to go page to page in a multi-form gravity form without having to click a next button. So you can put a question per page and when the user answers the question, it goes to the next automatically.

    There is a demo of it here – https://gformsdemo.com/gravity-forms-auto-advance-demo/

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email. Read my privacy policy.

potted cactus and laptop with code

Footer

Categories

  • Accessibility
  • Blogging & Content Marketing
  • Business
  • Personal
  • Software & Tech
  • Websites
  • WordPress

Top Posts

  • How To Create WordPress Excerpts And Include Links In Them
  • How To Solve WordPress Image Alignment And Text-Wrap Problems
  • Improve Your Divi Website's Reach With Divi Accessibility
  • How To Set Up And Customize Twenty Nineteen Theme
  • Registering a Domain Name with GoDaddy - Step by Step

Let’s Be Social

  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
Copyright © 2014 -2025 A Bright Clear Web
  • Privacy and cookies policy
  • Site map