PDA

View Full Version : Another Quiz Question!!


stickck
08-24-2005, 08:20 PM
I finally got back and i'm trying to get these done before i have to leave again. what i want to do is keep the questions and answers in either a table or txt file and have them import into the quiz (depending on which quiz the user chooses) here is what i have for a smaller quiz (most of the tests are 100 to 150 questions each) 31 tests to build yet! i searched the forums here and i didnt find anything that really explained how. i seen a few samples that tigger put out (thanks Tigger for the certificate you built. i changed it around so that at the end of the quiz it added the score results and user name to it.) want to see what i built, email me and i'll send you a copy.

question_list = {};
question_list [1] ="In a lockout, an energy-isolating device is locked in the safe or off position.\n\nA - True.\nB - False.";
question_list [2] ="In a tagout, the energy-isolating device is placed in the safe position and a written warning is attached to it.\n\nA - True.\nB - False.";
question_list [3] ="Lockout/tagout should be used whenever you are performing service or maintenance around any machine where you could be injured by unexpected start-up or release of stored energy.\n\nA - True.\nB - False.";
question_list [4] ="Applying locks or tags in the right places de-energizes the equipment.\n\nA - True.\nB - False.";
question_list [5] ="Turning off the power switch removes all energy from powered equipment.\n\nA - True.\nB - False.";
question_list [6] ="Before lockout/tagout is applied, all workers in the affected area must be notified.\n\nA - True.\nB - False.";
question_list [7] ="Before you turn off equipment in order to lock or tag it out, you must know the type of energy it uses, the hazards of that energy and how to control the energy.\n\nA - True.\nB - False.";
question_list [8] ="After equipment has been isolated from its power source, it is still necessary to control any energy stored in the system.\n\nA - True.\nB - False.";
question_list [9] ="Before removing lockout/tagout devices, you must make sure the danger area is clear of tools and workers.\n\nA - True.\nB - False.";
question_list [10] ="If a worker is not present to remove his own lock, any co-worker can remove it as long as he first makes sure it is safe.\n\nA - True.\nB - False.";

-- This is a list of corresponding correct answers
answer_list = {"A","A","A","B","B","A","A","A","A","B"}

whole_list = {"In a lockout, an energy-isolating device is locked in the safe or off position.\n\nA - True","In a tagout, the energy-isolating device is placed in the safe position and a written warning is attached to it.\n\nA - True","Lockout/tagout should be used whenever you are performing service or maintenance around any machine where you could be injured by unexpected start-up or release of stored energy.\n\nA - True","Applying locks or tags in the right places de-energizes the equipment.\n\nB - False","Turning off the power switch removes all energy from powered equipment.\n\nB - False","Before lockout/tagout is applied, all workers in the affected area must be notified.\n\nA - True","Before you turn off equipment in order to lock or tag it out, you must know the type of energy it uses, the hazards of that energy and how to control the energy.\n\nA - True","After equipment has been isolated from its power source, it is still necessary to control any energy stored in the system.\n\nA - True","Before removing lockout/tagout devices, you must make sure the danger area is clear of tools and workers.\n\nA - True","If a worker is not present to remove his own lock, any co-worker can remove it as long as he first makes sure it is safe.\n\nB - Fasle",};

this is the basic quiz template, i just addes several things like the wrong_list that tell the user the correct answer when they answer wrong. i did have keystokes but if they answered wrong, they could hit the correct answer key and it would change thier score and mark it correct. i couldn't figure out the fix for that so i took it out. so my question is how can i put the questions / answers listed above in a txt file and have it imported into the quiz? also, will i have to format the questions just like those above when i do the TXT file or can i just have the questions and answers like normal with out the \n\n double space stuff.

I'm not that good at scripting. i know just enough to get myself in trouble! :)

thanks for any help you can give!!!!!

SSgt Chris Koehnle
U.S. Air Force

TJ_Tigger
08-24-2005, 09:12 PM
A couple suggestions are these

First with the format of the file, you could build the tables as you have them above in a text file(actually a .lua file) and then use the LUA function dofile(filename) to instantiate the tables for your quiz. This is nice because you could then easily change out the quiz you want to use with the engine.

Or you could have one question and answer set per line and use the TextFile.ReadToTable. to create your table, very similar to the above. I would have all the formatting in the text string when you read it to a table or at least to a String.Replace to add the correct syntax so it is readeable in the quiz tool.

HTH
Tigg

stickck
08-24-2005, 09:40 PM
i think i might try your first suggestion. so i should just put the questions and answers in the correct format into a txt file and change the extention to .lua? the dofile(filename) function--do i need the luacom plugin for that?

once it populates the table with the file info, let say they want to go back and do a different test. do i need to clear the table first of will it copy over the old info with the new info?

thanks for the help with this. i'm working on adding in the MSAGENT and have him tell the user the correct answer when they answer wrong.

i still cant attach the program. i get an error when i try. oh well.


Thanks again for your help.
Chris

TJ_Tigger
08-24-2005, 11:35 PM
No LuaCOM is not required. dofile() is a lua function that works in AMS, see www.lua.org for more details. It loads and runs the lua code from an ASCII file.

Once you use dofile the table is now loaded, the person can now take the test. If they want to go back and take another, then they can dofile on another file to load that one too. And what is really cool is you can use the Luacompile (http://www.indigorose.com/forums/showthread.php?t=8320) program that is on the board somewhere to convert the text file to a binary file and your questions are now more secure. :)

Tigg

stickck
08-24-2005, 11:44 PM
oh! i've been looking at www.LUA.org (http://www.LUA.org) and i've been trying to understand it. does AMS support all of the LUA functions?
thanks for the help with this. i like that much better. right now i have all the tests in word docs (we used to print them off and hand them out), but im going to import them into Excel and put in the codes that way (much quicker that way unless you know of a simpler way) and save it as a txt file.

thanks again

chris :yes :yes

stickck
08-25-2005, 01:02 AM
this is a little off the subject but anyways. MSAGENT. i got everything to work but how can i speed up the Speak command. i would like to speed up how fast it types the word in the speech bubble (whatever that call that thing)

MyAgent.Characters("Merlin"):Speak ("Welcome "..strName.."!")

MyAgent.Characters("Merlin"):Speak ("Incorrect. The correct answer is "..whole_list[question_index].."!")

;)

Intrigued
08-25-2005, 01:07 AM
FWIW, I.R.'s AMS 5 documentation (read: help) does cover the dofile and require built-ins.

http://www.indigorose.com/webhelp/ams50/Scripting_Guide/Other_Built-in_Functions.htm

:yes

stickck
08-25-2005, 02:17 AM
Thanks Tigger & Intrigued! It works perfect!!! i'll upload the APZ from home. i think our LAN system is blocking the upload here. The way i was doing it, i would of used up about 200 meg. now it should only be about 6 meg!

THANK YOU!!!!!! :lol

screenshot for you.

chris

Corey
08-25-2005, 02:18 AM
Snazzy looking project! :yes

stickck
08-25-2005, 05:26 AM
Thanks Corey

you helped me out with this project when i started it back april 2004. been in the middle east most of last year. now i can get back on it. Thanks for the help with it. i know i'll be asking for more help with it in the near future.


Thanks again

chris

mewahid
10-03-2005, 02:28 AM
i want this project stickck
tanx alot

stickck
10-03-2005, 02:59 AM
i got off it again. i'll eventually get it completed. there are several errors in it right now. i changed the way it get the questions and i havent worked out the new bugs. i used to keep the questions and answers in the global list, but now i use LUA files and import them during runtime. its much better. now the user can create thier own tests and they're automaticly imported into the test program. (i havent added that in yet.) i'm just going to use a list box that populates with the LUA files a folder.

i cant get the site to let me upload from work. ill try from home to get it to work. send me a private message with your email and i can email you the file. i have 2 different ones. one that links all the test together (5 Meg) and the other only opens one test (1 Meg).

chris

stickck
10-03-2005, 04:16 AM
i still cant get it to upload. i can email it to you if you want. i fixed a few of the errors real quick. just send me a private message unless you dont mind your email address in a post....

let me know

chris

stickck
10-03-2005, 05:18 PM
all the errors are fixed now. when i created the APZ file, I didnt notice that it deleted the gif files for the certificate. easy fix!

stickck
10-10-2005, 01:58 AM
more help please! i've searched the forum for this and i've tried several different ways but i still cant get it to work right. i want to write sting to a text file and it does, but i want it to add some info like user and score and date. here is what i have right now.

Print Button OnClick
TextFile.WriteFromString("AutoPlay\\Docs\\Results.txt", '..strName', true);

Page Preload
strName = Dialog.Input("Vehicle Maintenance Test Module", "Please Enter your Name", "Your Name Here!!!", MB_ICONQUESTION);

but when it rights to the text file it only writes ..strName not the actual name tha was input. and suggestions?

thanks

chris

JimS
10-10-2005, 04:04 AM
Try this:

TextFile.WriteFromString("AutoPlay\\Docs\\Results.txt", strName, true);


HTH :)

stickck
10-10-2005, 04:47 AM
I know i've tried that before but it works now. thank you! one more question. how can i get it to copy to a new line in the text file everytime? ive tried this but it didnt work for me.

TextFile.WriteFromString("AutoPlay\\Docs\\Results.txt", r\n\ strName,true);

thanks for your help.

chris

JimS
10-10-2005, 05:45 AM
Try this one:

TextFile.WriteFromString("AutoPlay\\Docs\\Results.txt", "\r\n".. strName,true);

stickck
10-10-2005, 06:20 AM
THANK YOU!!!!! i couldnt figure that out for anything. it works great. thank you again! I really appriciate your help!

chris

JimS
10-10-2005, 06:57 AM
Glad to help.

stickck
10-10-2005, 07:36 AM
Here's a good one. i gave up on it a couple of weeks ago but now i have nothing else to do so i'm back at it.
i have a listbox that i want to populate with several LUA files. currently i have a seperate button for each LUA file. (36 files/tests in all) i dont like the look of all the buttons.

button events:

Application.LoadScript("2T351AVol1.lua");
module = "2T351 Volume 1"
Page.Jump("Page1")

how can i get the listbox to do all that when i double click on it in the list.
i can get it to open the LUA file in wordpad with the file.open but i cant get it to load the LUA file.
i hope you understand what i'm asking.
i have a list of these

2T351
2T370

when i double click on 2T351, i want that LUA file to load with the Aplication.LoadScript action.
when i double click on 2T370, i want that LUA file to load with the Aplication.LoadScript action.

any suggestions?

stickck
10-10-2005, 07:39 AM
i also would rather have the ListBox because it would be much easier to add and remove tests.

TJ_Tigger
10-10-2005, 10:28 AM
I would suggest that you load the path to the file into the data portion of the Listbox and then when it is clicked, get the data portion and use that in the Application.LoadScript(ListBox.GetItemData("ListBox1", ListBox.GetSelected("ListBox1")[1])); Or something along those lines.

Tigg

stickck
10-10-2005, 10:34 PM
I'm lost! i tried what you were saying but i couldn't get it right. when you said "I would suggest that you load the path to the file into the data portion of the Listbox" did you mean type it into the Item Data field or did you mean put something like this under preload for page, ListBox.AddItem("ListBox1", String.SplitPath(file_path).Folder, String.SplitPath(file_path).Filename);. i'm hoping to be able to just drop the new test in a *.Lua file into the script folder and it automatically be loaded into the listbox.

chris

TJ_Tigger
10-11-2005, 07:26 AM
I'm lost! i tried what you were saying but i couldn't get it right. when you said "I would suggest that you load the path to the file into the data portion of the Listbox" did you mean type it into the Item Data field or did you mean put something like this under preload for page, ListBox.AddItem("ListBox1", String.SplitPath(file_path).Folder, String.SplitPath(file_path).Filename);. i'm hoping to be able to just drop the new test in a *.Lua file into the script folder and it automatically be loaded into the listbox.

chris

I was thinking more like this


ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);

Now the displayed text is the file name but the data associated with that name is the full path to the file.

Now On Double Click you can get the data portion (ListBox.GetSelected and ListBox.GetItemData) and use that in your Application.LoadScript and then jump to the appropriate page.

HTH
Tigg

TJ_Tigger
10-11-2005, 08:09 AM
Here is a sample file, albeit uncommented.

Tigg

stickck
10-11-2005, 05:56 PM
hey Tig, are you using version 6? i cant open the APZ file. i'm running 5.0.3.0 just wondering. ill get the trial of 6 and try it again.

thanks for your help with this. i have what you wrote in the other post right, it populates the listbox with whats in the scripts folder but when you double click on the script that you want to load, it load the same file everytime.

ie file1 file2 file3 double click on any of the files and it will keep loading file1.

ill let you know if your sample helps. they usually do!

thanks again

chris

TJ_Tigger
10-11-2005, 10:05 PM
oops yeah I did that. Sorry, Here is an AMS5 version

stickck
10-11-2005, 10:29 PM
thank you. i download the trial version of 6. it looks different. just messing around with it and it seems more user friendly. i'm gonna have to try it out some more before i decide if i like it. thanks for reposting that.

chris

stickck
10-12-2005, 09:01 AM
Thanks again Tigg! It works great. I ended up changing out the listbox for a combobox. it has a cleaner look. I really appriciate your help!! It took me a while to figure out how to clear out the ComboBox so it would stop createing duplicates every time the page loaded. I dont know if there is an easier way, but I put this under page--close. ComboBox.DeleteItem("Plugin1", 1) I put it there 30 times since there are 30 items in the combobox. I tried to figure out the sting.repeat but i couldn't get it to work right.

Do you know why i can't post a apz file in the forum? I would like to post this test taker for whoever may need it but i can only post images. just wondering.

thank you again Tigg!

Chris

Desmond
10-12-2005, 09:54 AM
Hello,

ComboBox.ResetContent("ComboBox1");

Description
Removes all items from the specified combobox object.

Parameters
ObjectName
(string) The name of the combobox object.

Returns
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

stickck
10-12-2005, 11:40 PM
oh, now i feel stupid. i looked for hours on how to do that. i guess i need to slow down and take my time. thank you for the code. i pretty much gave up on it, thats why i used the code i mentioned above. it worked but i looked messy.

chris