Articles Archive
Articles Search
Director Wiki
 

Making a quiz

December 18, 1997
by Pat McClellan

Dear Multimedia Handyman
I'm a Director beginner and I'd like some help making a quiz.

Anders Swensson

Dear Anders,

There are many, many approaches to creating a quiz -- from both the technical and educational design perspectives. First, think about what you want the quiz to do. Here are some questions to consider:

There are many other considerations as well. I'm going to make some assumptions for our example. In our quiz, we are going to have 10 multiple choice questions, each counting the same amount. The total score will be given at the end of the quiz, but the user will not be told which answers are right or wrong. While taking the quiz, the user may change their answer before advancing, but may not go back to a previous question to change an answer. Any unanswered questions will be considered an incorrect answer. Finally, we'll assume that no record will be made of the user's participation or performance on the quiz.

You need <a href="http://www.macromedia.com/shockwave/">ShockWave</a> 6 to view this movie!

I'm going to focus here on tracking the the user's input and comparing that to the real answers to yield a score. I'm going to start (in the startMovie handler) by creating a property list which holds the correct answers to the questions. I have arbitrarily set up my buttons so that the button for A is in sprite channel 43, B is in channel 44, C is in 45, and D is in 46. I will use the sprite numbers to designate the correct answers.

global gUserPicks, gRealAnswers
set gRealAnswers = [1:44, 2:46, 3:46, 4:43, 5:45,¬
  6:44, 7:45, 8:44, 9:45, 10:44]

Next, create a similar property list that will hold the values of the user's choices. You can set the initial values to anything other than the values which correspond to the answers.

set gUserPicks = [1:50, 2:50, 3:50, 4:50, 5:50, ¬
  6:50, 7:50, 8:50, 9:50, 10:50]

As the user selects an answer, we need to change the value for the corresponding question in gUserPicks. I use the following handler on all of the buttons. (Note that I am using a global variable called gWhichQ to track which question the user is currently on. You can update this value everytime the user clicks the next question arrow.)

on mouseUp
global gWhichQ, gUserPicks
set whichAnswer = the clickOn
setaProp (gUserPicks, gWhichQ, whichAnswer)
end mouseUp

After answering all the questions, call the handler "tallyScore". This handler sets the score to zero; counts the number of questions in the list and divides 100 by that number to yield the percentage points per question; moves through each list, comparing the user's answer to the correct answer; and finally posts a message based on the user's score.

on tallyScore
global gUserPicks, gRealAnswers
  set score = 0
  -- checks to see how many questions
  set howManyQs = count(gRealAnswers)
  -- assigns points per question 
  set pointsPerQ = 100.00/howManyQs 
  -- cycles through all answers
  repeat with i = 1 to howManyQs 
    if getaProp (gUserPicks, i) = getaProp ¬
     (gRealAnswers, i) then
      -- got it right 
      set score = score + pointsPerQ
    end if
  end repeat
  -- rounds score to nearest integer
  set score = integer(score) 
  if score > 80 then
    put "Congratulation! You scored "&score&"% ¬
      in this self-assessment quiz." ¬
      into field "score"
  else
    put "You scored "&score&"% in this ¬
     self-assessment quiz. You should have ¬
     spent more time watching television in the ¬
     60s and 70s." into field "score"
  end if
end tallyScore

I've created many quizzes in my work and it seems that I'm always evolving them in one way or another. On a recent Shockwave quiz, I created another property list of URLs corresponding to the lesson content of each question. Then at the end of the quiz, I reported which questions they missed, and the user could simply click a link to review the content.

Good luck with your project and learning Director.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2024, Director Online. Article content copyright by respective authors.