Announcement

Collapse
No announcement yet.

Altering "Quiz" Template

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Altering "Quiz" Template

    Hey everyone,

    I've been messing around with AMS, and I decided I'd like to make a game based on the rules of "Who Wants to be a Millionaire". So far it's been a success except for one little (major) problem, and that is loading the questions. (The lifelines are going to be a major headache in themselves, but I'll figure that out later when the time comes.)

    My ideal goal is to have one page for the quiz and one question database; that way I can create a "Custom Question Creator" sort of thing and have users load in their own questions. Long story short, I'm modifying the quiz template and the included XML file. Instead of having only two question types ("MC" and "MS" I think), I want to have 15, each type corresponding to a certain level of difficulty. For instance, a type of "1" would be the $100 question, and a type of 15 would be the $1,000,000 question.

    Where my problem lies is sorting the questions. It randomly generates a table of questions but I want to have it check the type, and if the type does not match, then I want it to find another question. I'm still really new to this (this is only the trial version) so I'm not sure what's going on and which code actually looks at, but if I use a loop then the game freezes. I put the code in the On Preload... section.

    Here's what I have so far in this section:

    Code:
    local type = 1
    
    while Table.Count(tbRnd) < nQtA do
    
    	--strPath = "quiz/items/item:".. nRnd;
    	
    	--sQ2Type = XML.GetAttribute(strPath .."/question", "type");
    
    	nRnd = Math.Random(1,Table.Count(tbQtA));
    	--strPath = "quiz/items/item:".. nRnd;
    	--result = XML.GetAttribute("quiz/items/item:" .. nRnd .."/question", "type");
    	
    	local nQ = Table.Remove(tbQtA, nRnd);
    	Table.Insert(tbRnd, Table.Count(tbRnd)+1, nQ);
    
    end
    I added the strPath and "result" variables as a test (the remnants of many tests to check for type), but they don't seem to be working. Any pushes in the right direction would be greatly appreciated, and if more information on this project is needed I can post some more tidbits!

    Thanks!

    -BT7

  • #2
    I would recommend building a table for each of your 15 levels of questions. Table 1 has all of your $100 questions table 2 has all of your $200 questions so on and so forth. Then when you build your quiz to use in your app I would start at one and loop through 15 and get a question from each table. Then you have a quiz randomly built from other pools containing your $100 through $1,000,000.

    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

    Comment


    • #3
      Originally posted by TJ_Tigger View Post
      I would recommend building a table for each of your 15 levels of questions. Table 1 has all of your $100 questions table 2 has all of your $200 questions so on and so forth. Then when you build your quiz to use in your app I would start at one and loop through 15 and get a question from each table. Then you have a quiz randomly built from other pools containing your $100 through $1,000,000.

      Tigg
      I agree, An ideal layout would be something like this for me.

      Code:
      Questions = {};
      
      Questions["Level 1"] = {};
      Questions["Level 1"][1] = {};
      Questions["Level 1"][1]["Question Title"] = "Who is very awesome?";
      Questions["Level 1"][1]["Answer 1"] = "ShadowUK";
      Questions["Level 1"][1]["Answer 2"] = "Reag";
      Questions["Level 1"][1]["Answer 3"] = "Elexar";
      Questions["Level 1"][1]["Answer 4"] = "Darkimmortal";
      Questions["Level 1"][1]["Correct Answer"] = 4;
      Or an XML equivilant.

      Code:
      <Questions>
      	<Level ID="1">
      		<Question ID="1" CorrectAnswer="4" Text="Who is very awesome?">
      			<Answer>ShadowUK</Answer>
      			<Answer>Reag</Answer>
      			<Answer>Elexar</Answer>
      			<Answer>Darkimmortal</Answer>
      		</Question>
      	</Level>
      </Questions>

      Comment


      • #4
        Thanks!

        Thanks guys, that helps! Definitely wouldn't have thought of that. It's a good suggestion and probably my best bet, would make things less messy anyways.

        Forgive the newbie question here, but where exactly would the code for this go? On Preload? On Startup?

        I'm using the XML code for questions that was included in the template, so they look like this:

        Code:
        		<item>
        			<question type="1">How many wheels does a unicycle usually have?</question>
        			<answer correct="y">1</answer>
        			<answer>2</answer>
        			<answer>4</answer>
        			<answer>18</answer>
        		</item>
        (Oh, these questions are terrible. I need to rewrite them. Well, in all fairness, it *is* the $100 question.)

        Also, I'm guessing this would be a for or a while loop to create the tables, right? Sigh, it's been a while since I took Visual Basic. :( But I've gotten this far, I can't quit now ahhh! :lol

        Thanks!

        -BT7

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎