A Simple WordPress Quiz Plugin

ver. 0.99, January 14, 2021

Because of recent changes to the WordPress CMS platform, I found it necessary to replace the quiz plugin I was using for my Food Bucket List. While the List itself may seem a bit lengthy to some, presenting it to readers only requires a simple Yes/No or True/False choice. Unfortunately many newer WordPress quiz plugins are either too unwieldly for this or, as I found out through numerous tests, don’t even include that kind of simple functionality.

It didn’t take long before I realized it would likely be simpler to take a couple hours and develop a simple one-file plugin to present the List. There wouldn’t need to be any database operations as I didn’t need to store anything. I could include the questions and their descriptions within the one PHP file as an array. I also didn’t intend to get any information from the user: All I needed to do was ask them to leave their final score in the comment section of the page.

Thinking it through, I mapped out a few ideas:

  • The questions only needed a checkbox, the name of the food, whether or not to “bold” the food name if it’s something I’ve had myself, and the food’s description.
  • Once the user was done and the Submit button was clicked, only count the checked checkboxes. There was no need to find out which ones were checked as I only cared about the count.
  • Any Introductory information needed to disappear when the Submit button was clicked so the user could see their result, meaning those paragraghs needed o be part of the plugin instead of being on the WordPress page.
  • It would be easier on me if the plugin could count the “bolded” items when I needed it to, instead of my having to verify my own count if I modified or added to the List.
  • The quiz should email me the answers when someone takes the quiz, maybe including their name and email address and cc’ing them too, but doesn’t need to save their name, email, or IP address.
  • November 2020 saw the addition of images, HTML image captions, and multiple-choice questions to the question array.

While these requirements seem complex, their implementation is rather simple. The code for the plugin’s main function is actually much smaller than the code for the question array.

You can download the current version of this plugin by clicking here. Unzip the folder, then modify the questions array in the get_available_questions() function in the cls/fbl.arrays.php file, as well as modifying the variables in the other two files before uploading the lpc-food-bucket-list folder to the wp-content/plugins/ directory in your WordPress installation. Then Activate the plugin in the Plugins page of the Admin area.

I certainly don’t claim to be any extreme kind of programmer. But that this only took about 4 hours to implement for initial functionality, with most of that time being spent on organizing the questions array, shows how simple a True/False quiz plugin with an emailer in WordPress can be.