How do I make a multi-answer quiz?

  • I create a json file by saving a txt file as a json then importing it into the files folder in the project bar by right-clicking on the folder icon and selecting import files.

    You might also be able to do it by right-clicking on the folder and selecting New>JSON - I haven't tried that method though.

  • Sorry, should have mentioned the other (most obvious) way to create the array json - right click on the Files folder, and select New>Array; you can then use the built-in array editor.

  • Sorry, should have mentioned the other (most obvious) way to create the array json - right click on the Files folder, and select New>Array; you can then use the built-in array editor.

    No its fine

  • You're welcome :-)

    If you don't want to shuffle the questions, disable the call to the shuffleQuestion function in the On Start event.

    If you don't want to shuffle the answers, in event 5 you can swap both references to AdvancedRandom.Permutation(loopindex("j") to just loopindex("j")

    I did what you said but now when you press next question, the question doesnt change. It keeps going to question 1

  • Sorry, my bad - you also need to change the references to a_questionOrder:

    In event 4 change:

    -> txt_question: Set text to a_questions.At(0,a_questionOrder.At(currentQuestion),0)

    to

    -> txt_question: Set text to a_questions.At(0,currentQuestion,0)

    In event 5 change:

    -> txt_answer: Set text to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),a_questionOrder.At(currentQuestion),0)

    to

    -> txt_answer: Set text to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),currentQuestion,0)

    // Set the "correct" instance value on the answer.

    and

    -> txt_answer: Set correct to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),a_questionOrder.At(currentQuestion),1)

    to

    -> txt_answer: Set correct to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),currentQuestion,1)

    I've updated the demo to reflect these changes - the original actions are still there but disabled, in case you want to switch back. I also fixed a couple of other bugs, so it's worth grabbing again:

    dropbox.com/s/qc9dourwsf4f7g6/quizTemplate2.c3p

  • Sorry, my bad - you also need to change the references to a_questionOrder:

    In event 4 change:

    -> txt_question: Set text to a_questions.At(0,a_questionOrder.At(currentQuestion),0)

    to

    -> txt_question: Set text to a_questions.At(0,currentQuestion,0)

    In event 5 change:

    -> txt_answer: Set text to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),a_questionOrder.At(currentQuestion),0)

    to

    -> txt_answer: Set text to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),currentQuestion,0)

    // Set the "correct" instance value on the answer.

    and

    -> txt_answer: Set correct to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),a_questionOrder.At(currentQuestion),1)

    to

    -> txt_answer: Set correct to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),currentQuestion,1)

    I've updated the demo to reflect these changes - the original actions are still there but disabled, in case you want to switch back. I also fixed a couple of other bugs, so it's worth grabbing again:

    https://www.dropbox.com/s/qc9dourwsf4f7g6/quizTemplate2.c3p?dl=0

    I have a couple questions (sorry, not undderstanding)

    1. Is 'totalquestions' a function? (event 1)

    2.What is BBoxRight (event 1)

    3.What is "i" (event 3)

    4.What does permutation mean for advanced random?

    5.What does 'Self.selected=0?rgbEx(0, 0, 0):rgbEx(0, 0, 255)' mean? (event 16)

    I'm sorry for all the questions :( But thnaks for all your help :)

  • Sorry, my bad - you also need to change the references to a_questionOrder:

    In event 4 change:

    -> txt_question: Set text to a_questions.At(0,a_questionOrder.At(currentQuestion),0)

    to

    -> txt_question: Set text to a_questions.At(0,currentQuestion,0)

    In event 5 change:

    -> txt_answer: Set text to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),a_questionOrder.At(currentQuestion),0)

    to

    -> txt_answer: Set text to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),currentQuestion,0)

    // Set the "correct" instance value on the answer.

    and

    -> txt_answer: Set correct to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),a_questionOrder.At(currentQuestion),1)

    to

    -> txt_answer: Set correct to a_questions.At(AdvancedRandom.Permutation(LoopIndex("j")),currentQuestion,1)

    I've updated the demo to reflect these changes - the original actions are still there but disabled, in case you want to switch back. I also fixed a couple of other bugs, so it's worth grabbing again:

    https://www.dropbox.com/s/qc9dourwsf4f7g6/quizTemplate2.c3p?dl=0

    So Let say some questions of 4 answer choices, and some have 5 and some have 6. Should they be in seperate arrays?

  • 1. Is 'totalquestions' a function? (event 1)

    No, it's a global variable that takes it value from the height of the a_questions array (i.e. the number of questions)

    2.What is BBoxRight (event 1)

    BBoxRight is the X coordinate of the right-hand edge of the spr_tickCross box.

    3.What is "i" (event 3)

    "i" is just a tag for the loopindex - in this instance it's not really needed, but when you use nested loops you give them different tags to be able to reference specific loop indices.

    4.What does permutation mean for advanced random?

    A permutation is an arrangement of values; the AdvancedRandom plugin can generate a random permutation of values without repetition - in this instance we randomise the order of questions and stick the values into a_questionOrder.

    5.What does 'Self.selected=0?rgbEx(0, 0, 0):rgbEx(0, 0, 255)' mean? (event 16)

    This expression uses the conditional operator to set the colour of the text. The conditional operator works as follows: Is this statement true ? If so do this : otherwise do this

    I'm sorry for all the questions :( But thnaks for all your help :)

    No problem :-)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > 1. Is 'totalquestions' a function? (event 1)

    No, it's a global variable that takes it value from the height of the a_questions array (i.e. the number of questions)

    > 2.What is BBoxRight (event 1)

    BBoxRight is the X coordinate of the right-hand edge of the spr_tickCross box.

    > 3.What is "i" (event 3)

    "i" is just a tag for the loopindex - in this instance it's not really needed, but when you use nested loops you give them different tags to be able to reference specific loop indices.

    > 4.What does permutation mean for advanced random?

    A permutation is an arrangement of values; the AdvancedRandom plugin can generate a random permutation of values without repetition - in this instance we randomise the order of questions and stick the values into a_questionOrder.

    > 5.What does 'Self.selected=0?rgbEx(0, 0, 0):rgbEx(0, 0, 255)' mean? (event 16)

    This expression uses the conditional operator to set the colour of the text. The conditional operator works as follows: Is this statement true ? If so do this : otherwise do this

    >

    > I'm sorry for all the questions :( But thnaks for all your help :)

    No problem :-)

    Thanks! This was really helpful ! :DDDD

  • So Let say some questions of 4 answer choices, and some have 5 and some have 6. Should they be in seperate arrays?

    You can still use just one array. You would set the array width to the maximum number of answers. For those questions with less than the maximum number of answers leave the answer cells in the array blank. You can then do a check to see if the answer is blank (text = "") and if so set the corresponding spr_tickCross invisible.

    I've updated the demo to include this feature:

    dropbox.com/s/qc9dourwsf4f7g6/quizTemplate2.c3p

  • You odnt have to make a new project. I know it a lot of work .

    What does

    + a_questions: Value at (LoopIndex("j"), currentQuestion, 0) ≠ ""
    

    mean? (Event 6 condition 2)

  • What does

    > + a_questions: Value at (LoopIndex("j"), currentQuestion, 0) ≠ ""
    

    mean? (Event 6 condition 2)

    This checks tif the answer in the a_questions array at the current loopindex is not an empty cell (text does not equal "").

  • > What does

    >

    > > + a_questions: Value at (LoopIndex("j"), currentQuestion, 0) ≠ ""
    > 

    mean? (Event 6 condition 2)

    This checks tif the answer in the a_questions array at the current loopindex is not an empty cell (text does not equal "").

    So what is loopindex?

  • The Loopindex is the current iteration of the referenced loop.

    From the manual:

    LoopIndex

    Get the index (number of repeats so far) in any currently running loop.

    LoopIndex(name)

    Get the index (number of repeats so far) of the loop with the given name. Useful for getting indices in nested loops.

  • The Loopindex is the current iteration of the referenced loop.

    From the manual:

    LoopIndex

    Get the index (number of repeats so far) in any currently running loop.

    LoopIndex(name)

    Get the index (number of repeats so far) of the loop with the given name. Useful for getting indices in nested loops.

    So in this project which would be the curretn loop that we are seeingg thr loop index for? Also what does

     + Answers: no = LoopIndex("DrawAnswers") 

    mean? I know we drew the answers from the array, but now what is that code used for.What are the instance variables correct and no used fr?

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