HD Quiz

Need to send invoices?
Check out my new WordPress plugin HDInvoice
Limited time launch sale

Is there a way we could give a different result based on the selected answer?

Published: March 2, 2024
Support status: comment

For use as an assessment quiz, like a personality test, is there a way to give either a different result on the results page or at least different incorrect answer for each selected answer?

For example:
Q: Which do you prefer, french fries or poutine?
A. French fries
B. Poutine

Conditional Incorrect Answer message:
If you select A: God Bless America!
If you select B: God Bless Canada!

thread author: Laban Johnson

Hi Laban,
is it possible? yes!
is it easy? no!

I would not recommend the following unless you are comfortable adding code to your site, but it IS possible. I can provide code template if you want to go down this rout, but first, an explanation.

Why is this not built in?

The short answer is UI clutter. I personally think that the best thing about HD Quiz is that it is very feature rich, while still being a simple and intuitive user interface.

If I were to extend the “extra” text functionality, then we would need a whole new editor to load for each possible answers. By default, this would be 9 extra editors, but since you can override the maximum answers per question, this number could become as high as thousands.

Now let’s factor in that the WordPress editor (TinyMCE/classic editor) is the “heaviest” element on the page, and having too many of them could slow your browser down to a crawl, or even crash it.

The Solution

I would not recommend this if using more than, say, 4 answers per question due to the performance issues outlined above.

I built a LOT of hooks and filters into HD Quiz that allows anyone to extend the functionality and capabilities of HD Quiz as needed.

In our case, we could do the following. NOTE: This would not work if using random answer order in quiz settings.

  1. Add custom meta to questions. Example, three more editors to the Extra tab that maps to the answers.
  2. Use the hdq_after hook to add custom JavaScript to quizzes. Our custom function will need to change depending on if you have “Immediately mark answer as correct or incorrect” enabled or not. This function would update the “extra text” section based on the selected answer.
04 March 2024 — 13:51 support admin - Dylan

Respond to thread

You can also upload images to imgur and paste the links here. Just make sure that your images don't include any sensitive information.

Submit