Search my Blog

Tags

Browse Past Posts

Browse by Topic

♥ Special ♥

Blogroll

Frequently Visited Sites

News, Geek & Security

www.flickr.com
This is a Flickr badge showing public photos and videos from Bruce Westbrook. Make your own badge here.

My Hosting Provider

My most excellent hosting provider since 2002...9 years and counting!

This is not the image you are looking for.

wbQuiz Setup

Updated on April 23rd, 2008

Well, as you can see from the original post below, I obviously figured out how make wbQuiz work with my K2 install and graphite styling. It took some time and effort, but I did it. The thing is, after moving on and making some other, unrelated changes to the site, I found a MUCH EASIER and BETTER way.

After getting my first quiz up and running, I moved on to some other enhancements to the site. One of those included adding a datestamp to some of my Pages (like on this Page). Because I wanted the flexibility to decide which Pages to show the datestamp on, rather then changing “theloop” code I wanted the ability to simply add the pertinent PHP code to my Page to show the date I wanted, in the format I wanted, etc.

To do so, I installed Soren’s excellent Exec-PHP. All was good in my Geek Blog world.

A few days after this I decided that I wanted clean up the quiz page I had created earlier. The fonts didn’t match and it was missing my side navigation, because I had set up the page template very simplistically to get it up and running. So I started messing around with the page template. As I was doing so, a thought occurred to me. “Hey!” I thought, “I don’t have to use a template to run PHP code any longer! With Exec-PHP I can just insert the function call in the Page content.”

And whaddya know…it not only works but for some reason the problem I was having with the Custom Field variable not being passed was also now working! Well, almost. The wbquiz function was running, but their was an error in the code. And literally, it was the HTML code tag. I opened up the wb_quiz.php file, found the code tags and removed them, and tada! It worked perfectly!

So here’s the much simpler way to get Wander’s wbQuiz to work:

  1. Download wbQuiz
  2. Unzip the archive
  3. Copy the ./plugins/wb_quiz_questions.php file that you unzipped to a new file for your own questions
  4. Edit your new file following the examples provided to customize your questions, rankings, your “Submit” button text, your introduction including the page title, and your question string. If you’d like to see my customized Identity Theft example, download it here.
  5. Create a new file named error.php with the following one liner of code:
    [quickcode:noclick] < ?php $intro_string = "ERROR - I'm sorry. An error has occurred loading the questions. Please try again at a later time."; ?> [/quickcode]
  6. Edit the ./plugins/wb_quiz.php file that you unzipped. Find the $question_file section and change the code as follows:
    [quickcode:noclick]
    FROM THIS:

    if (!isset($question_file)) {
    $question_file[0] = ‘wb_quiz_questions.php’;

    TO THIS:

    if (!isset($question_file)) {
    $question_file[0] = ‘error.php’;

    [/quickcode]

  7. Also while you have the wb_quiz.php file open, locate the function wb_quiz_ask_questions() and simply remove the HTML open and close code tags. There are just two, one open and one close – simply do a search for the word code.
  8. Upload both your new edited version of wb_quiz.php and your error.php files to your WordPress plugins directory. I created a directory in plugins specifically for the quiz at this location: ./wp-content/plugins/wb_quiz
  9. Now upload your custom question file to your site. This can go anywhere that is readable by your web server. If you want to you can put it directly into the wb_quiz plugins directory as well.
  10. Activate wbQuiz in your Adminstration => Plugins panel
  11. Now create a new page (Write => Write Page) in WordPress. Enter a title for the page – I used the name of the quiz – and for the Page Content simply type the following line (be sure to remove the space between the < and the ? characters):
    [quickcode:noclick]
    < ?php wb_quiz(); ?>
    [/quickcode]
  12. Now add a new Custom Field with the Key name of question_file and a Value that is the filename of your question file (the copy of wb_quiz_questions.php that you made and edited with your questions). Be sure to include the entire SERVER-SIDE path to the file, not the HTTP path. For instance, it might be: /var/www/myblog/wp-content/plugins/wpquiz/my_questions.php
  13. Your quiz should be up and working now!

Unlike my earlier procedures, you won’t need to create separate plugins for different quizzes. Simply pass the Custom Field variable with your question file and life is good!


As Originally Published November 9th, 2006

I searched high and low and it’s the *only* WordPress specific quiz plugin that I could find. It lacks any interface or administration panel, so you have to create your quizzes in pure PHP code – which basically sucks since it takes some time to do. And I couldn’t get the Custom Field to pass the question file variable properly no matter what I did, so I ended up hard-coding it. Not sure if it’s a bug in wbQuiz or WordPress. But the quiz has some great features, such as three types of questions (radios, single multi-choice, multi multi-choice), highly customizable (well of course, since you are editing the code directly), multiple rankings, and most importantly for my Identity Theft quiz it allows weighting of questions. That is, some questions can be worth more or less points, as well as negative or positive points. If you’re looking for a quiz that works with your WordPress templates, I recommend wbQuiz – even though it was a pain in the arse getting it to work for me using K2.

This is what it took for me to get Wander’s wbQuiz working with K2 and my many customized tweaks in my WordPress:

  1. Download wbQuiz
  2. Unzip the archive
  3. Copy the ./plugins/wb_quiz_questions.php file that you unzipped to a new file for your own questions
  4. Edit your new file following the examples provided to customize your questions, rankings, your “Submit” button text, your introduction including the page title, and your question string. If you’d like to see my customized Identity Theft example, download it here.
  5. Create a new file named error.php with the following one liner of code:
    [quickcode:noclick] < ?php $intro_string = "ERROR - I'm sorry. An error has occurred loading the questions. Please try again at a later time."; ?> [/quickcode]
  6. Edit the ./plugins/wb_quiz.php file that you unzipped. Find the $question_file section and change the code as follows:
    [quickcode:noclick]
    FROM THIS:

    $question_file = get_post_custom_values(“question_file”);
    if (!isset($question_file)) {
    $question_file[0] = ‘wb_quiz_questions.php’;

    TO THIS:

    $question_file[0] = ‘your_question_file.php’;
    if (!isset($question_file)) {
    $question_file[0] = ‘error.php’;

    [/quickcode]

  7. Create a new file named page-quiz.php with the following code:
    [quickcode:noclick]
    < ?php /*
    Template Name: wbQuiz
    */ ?>

    < ?php get_header(); ?>

    < ?php wb_quiz(); ?>

    < ?php get_footer(); ?>
    [/quickcode]

  8. Upload the following three files to the ./wp-content/plugins directory on your server: error.php, wbquiz.php your_question_file.php. I actually made a wbquiz subdirectory in my plugins directory to help keep things organized. WordPress is smart enough to pick up plugins in the subdirectories as well.
  9. Upload the page-quiz.php file to the ./wp-content/themes/k2 directory on your server.
  10. Activate wbQuiz in your Adminstration => Plugins panel
  11. Now create a new page (Write => Write Page) in WordPress. Enter a title for the page – I used the name of the quiz – and from the Page Template dropdown, select your new wbQuiz template.
  12. Your quiz should be up and working now!

[Editors Note: If anyone finds fault with my process, please let me know in the comments section. I documented this soon after the fact but didn't walk through the process in its entirety to verify it. If there are errors, I'll be sure to correct them.]

You can do more to customize your quiz location, like create a page for Quizzes and put your new quiz page as a sub-page to the top-level Quizzes page. Or you can exclude your quiz page so it’s not displayed as a top-level page. It’s your blog, customize it to your hearts content! But at least you should have a working quiz with K2 now.

Note that the caveat to all this is the fact that if you have more then one quiz, you’ll need to create a new wbQuiz PHP file and a new page template for each one. Yes, it’s a pain, and like I said, I wish wbQuiz had a nice administration interface and the custom field worked properly. But it doesn’t for me, so this is my work-around. YMMV.

:)

FireStats icon Powered by FireStats