Making a Basic Quiz/Testing Application
Document ID: IR10051The information in this article applies to:
- AutoPlay Media Studio 5.0 Standard Edition
- AutoPlay Media Studio 5.0 Professional Edition
SUMMARY
This article describes how to make a simple quiz.
DISCUSSION
As an example, we will create a two page test, and a third page to display the results:
- Create a project with three pages.
- Insert the following code in the Global Functions:
--Each of the following tables contains a question, and 4 answers:
Q_01 = {Question="How many legs does a three leg'd dog have?", A1="One", A2="Two", A3="Four", ACorrect="Three"};
Q_02 = {Question="How many legs does a one leg'd cat have?", A1="Three", A2="Two", A3="Four", ACorrect="One"};
Correct={Q1="",Q2=""};
- On Page1, create one paragraph object, and four button objects.
- In the On Preload event of Page1, insert the following code:
Paragraph.SetText("Paragraph2", Q_01.Question);
Button.SetText("Button1", Q_01.A2);
Button.SetText("Button2", Q_01.A1);
Button.SetText("Button3", Q_01.ACorrect);
Button.SetText("Button4", Q_01.A3);
- Insert the following code into the On Click event of Button1:
Correct.Q1 = "InCorrect";
Page.Navigate(PAGE_NEXT);
- Insert the following code into the On Click event of Button2:
Correct.Q1 = "InCorrect";
Page.Navigate(PAGE_NEXT);
- Insert the following code into the On Click event of Button3:
Correct.Q1 = "Correct";
Page.Navigate(PAGE_NEXT);
- Insert the following code into the On Click event of Button4:
Correct.Q1 = "InCorrect";
Page.Navigate(PAGE_NEXT);
- On Page2, create one paragraph object, and four button objects.
- In the On Preload event of Page2, insert the following code:
Paragraph.SetText("Paragraph2", Q_02.Question);
Button.SetText("Button1", Q_02.A3);
Button.SetText("Button2", Q_02.A2);
Button.SetText("Button3", Q_02.A1);
Button.SetText("Button4", Q_02.ACorrect);
- Insert the following code into the On Click event of Button1:
Correct.Q2 = "InCorrect";
Page.Navigate(PAGE_NEXT);
- Insert the following code into the On Click event of Button2:
Correct.Q2 = "InCorrect";
Page.Navigate(PAGE_NEXT);
- Insert the following code into the On Click event of Button3:
Correct.Q2 = "InCorrect";
Page.Navigate(PAGE_NEXT);
- Insert the following code into the On Click event of Button4:
Correct.Q2 = "Correct";
Page.Navigate(PAGE_NEXT);
- Create one paragraph object on the last page of your project.
- Insert the following code into the On Preload event of the last page:
string_correct="";
correct = 0;
possible = 0;
for j,k in Correct do
possible = possible + 1;
if k == "Correct" then
correct = correct + 1;
end
end
Paragraph.SetText("Paragraph2", "Question 1: " .. Correct.Q1 .. "\r\n" ..
"Question 2: " .. Correct.Q2 .. "\r\n" ..
"You answered correctly " .. correct .. " out of " .. possible ..
" possible questions for a score of " .. ((correct/possible)*100) .. "%."
);
KEYWORDS: AutoPlay Media Studio 5.0, Quiz, Test, Multiple Choice
Last reviewed: September 26, 2003
Copyright © 2003 Indigo Rose Corporation. All rights reserved.
Comment