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