How do I set up a database to display random questions?

0 favourites
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • Pretty new to construct 2 and i am trying to make an educational game for a school project. I want to have a textbox in game that shows a question for a certain amount of time, specifically about verbs. The player then has to select the correct verb form. Ideally the question would be a random question picked out of a database of questions.

    The problem is i have no idea how to implement this in C2 and the tutorials i am finding online about databases i find do not really help me with this particular thing. Is there someone that knows how this works and could maybe explain it to me?

  • ...just search forum for :Trivia or Quiz and Array..

    How do I

    simple quiz game.capx

  • In the Simple Quiz Game example, can it be changed to allow more than one correct answer per question?

  • Minoterrae

    you mean like...each question has two(three;four) correct answers.?

    ..or..

    ....the first question has two correct answers;

    ....the second question has three correct answers;

    ...the third question has one correct answer

    ..etc..?

  • Well, each particular question would be different. But an example would be:

    Who Was A U.S. President?

    Thomas Jefferson, George Washington, Nathan Hale, Patrick Henry

    Here there would be more than 1 correct answer.

  • Minoterrae

    ..maybe you cant build something like this:

    FindAll.capx

  • Terrific example!

  • Korbaach,

    In the Find All example you did, can you tell me what the following parameters mean? "c2array"":true,""size"":[8,6,1]

    The 8 is the number of questions, but what is the 6 and 1? Also, what is the string length? I put in a couple of my own answers but they were too long to be shown.

    Thanks,

  • .... what the following parameters mean? "c2array"":true,""size"":[8,6,1]

    The 8 is the number of questions, but what is the 6 and 1?

    Array

    One-Dimensional Array (5,1,1)

    Two-Dimensional Array (2,2,1)

    Array=Array2

    ..if you use "Load from JSON string" ..you can set size & data in only one action...

    Array X=5 ; Y=6 ; Z=1

    (..in example I use Two-Dimensional Array(8,6,1) similar to this...)

    Arrays are zero based ..just like Sprite animation (first frame have index 0)

    I advise you to download this little program Array contents editor

    set X to number of questions as you want...Y=6 (Rows) ; Z=1

    and now you can fill the slots

  • I am enjoying making changes to Findall.capx, but when I choose a wrong answer, how could I get C2 to also highlight what the correct answer should have been?

  • Korbaach,

    I would like to use sprites for the answers instead of text objects and was wondering how to associate images with the text information stored in the array in your example.

    Thank you for all your responses, by the way.

  • I would like to use sprites for the answers instead of text objects...

    even simpler..just instead of text store frames...

    so you need one "SpriteAnswers" with many frames as you need(0,1,2,3...44....77...254...)..

    and then just follow pattern..

    [quote:1r62q9ir]

    FINDaLLpIC.capx

  • Greatly appreciate the education. What further change would be needed so that questions which are correctly answered are not asked again? I.e. only unanswered or incorrectly answered questions are able to be asked?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • What further change would be needed so that questions which are correctly answered are not asked again? I.e. only unanswered or incorrectly answered questions are able to be asked?

    Ok.

    so..now.. when you answer on question(correct or not,irrelevant)..that question does not appear in game again..

    do you know why?

    in example..event 4..function "RandomizeQuestionOrder"...have 2 loops

    so..after second loop,"ArrayQuestionOrder" looks similar to this(4,9,2,10,5,1,7,6,8,3)

    (first question is no4,then no9..etc)

    then.. in second function

    after you set question....action- delete inex 0 from ArrayQuestionOrder..delete that question

    (first question is no4,then no9..etc)

    so..you always ask question on index 0..ask-delete..ask again ..but now the question

    that was the second(index 1), is first(on index 0)...

    to prevent this..just move action in

    now..only if answer is correct you will delete that question...

    but..what will happen if the answer is incorrect..nothing.

    .you would be constantly asked the same question,until you answer correctly..

    so you need ..if answer is incorrect

    you push that question on end of the line

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)