How do I make a multi-answer quiz?

1 favourites
From the Asset Store
Comprehensive localization solution for Construct 3 projects, no addons required!
  • > 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?

    For me the tag "j" is "DrawAnswers" in ccase there was confusion

  • So in this project which would be the current loop that we are seeing the loop index for?

    loopindex always refers to the currently running loop. For example, in this "for" loop:

    For "i" from 0 to 3, append text loopindex to TextObject.

    the text displayed by TextObject would be "0123"; each time the loop runs it takes the current loopindex value (which steps up by 1 with each loop from 0 to 3) and adds it to the text string.

    The index tag allows you to differentiate between loopindices in nested loops e.g.

    For "i" from 1 to 2 --For "j" from 1 to 3, append loopindex("i") * loopindex("j") to TextObject

    ...would display "123246" - during this nested loop each step of "i" runs a complete loop from 1 to 3 of "j".

    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 for?

    txt_answers.no is an instance variable that distinguishes between the different instances of txt_answers - if you check the txt_answers objects in the layout you will see the value of "no" increases by one for each object as you go down the layout.

    txt_answers.correct is an instance variable that equals 1 if the answer it is displaying has been marked in the questions array as a correct answer (check the "Depth = 1" sheet in the array editor for a_questions: correct answers are marked with a 1, incorrect with a 0).

    Event 6 runs a loop through each of the answers in a_questions for the current question; if the current answer slot in the array isn't blank it picks the txt_answer object with a "no" value that corresponds to the current answer (loopindex "i"), then sets the text of that txt_answer object to the answer (using the shuffled permutation table, if the action specifies it).

    In Event 7 (function checkQuestion) each txt_answer is checked to see if it has been selected by the user (txt_answer.selected is true) and if it is a correct answer (txt_answer.correct is 1); if both are true or both are false spr_tickCross displays a tick, otherwise a cross is shown.

  • > So in this project which would be the current loop that we are seeing the loop index for?

    loopindex always refers to the currently running loop. For example, in this "for" loop:

    For "i" from 0 to 3, append text loopindex to TextObject.

    the text displayed by TextObject would be "0123"; each time the loop runs it takes the current loopindex value (which steps up by 1 with each loop from 0 to 3) and adds it to the text string.

    The index tag allows you to differentiate between loopindices in nested loops e.g.

    For "i" from 1 to 2 --For "j" from 1 to 3, append loopindex("i") * loopindex("j") to TextObject

    ...would display "123246" - during this nested loop each step of "i" runs a complete loop from 1 to 3 of "j".

    > 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 for?

    txt_answers.no is an instance variable that distinguishes between the different instances of txt_answers - if you check the txt_answers objects in the layout you will see the value of "no" increases by one for each object as you go down the layout.

    txt_answers.correct is an instance variable that equals 1 if the answer it is displaying has been marked in the questions array as a correct answer (check the "Depth = 1" sheet in the array editor for a_questions: correct answers are marked with a 1, incorrect with a 0).

    Event 6 runs a loop through each of the answers in a_questions for the current question; if the current answer slot in the array isn't blank it picks the txt_answer object with a "no" value that corresponds to the current answer (loopindex "i"), then sets the text of that txt_answer object to the answer (using the shuffled permutation table, if the action specifies it).

    In Event 7 (function checkQuestion) each txt_answer is checked to see if it has been selected by the user (txt_answer.selected is true) and if it is a correct answer (txt_answer.correct is 1); if both are true or both are false spr_tickCross displays a tick, otherwise a cross is shown.

    Thanks! How can I do it so that when you press the corre ct answer it adds one to the Corret variable.(new one tat i made) and when its wrong subtract 1

    + Answers: correct = 0
    ----+ Answers: Is selected
    ----+ System: Trigger once
    -----> System: Add 1 to Correct
    
    ----+ Answers: [X] Is selected
    ----+ System: Trigger once
    -----> System: Subtract 1 from Correct
    
    

    but it didnt work any help? Ribis? mekonbekon dop2000 blackhornet Ashley AllanR

  • but it didnt work any help? Ribis? mekonbekon dop2000 blackhornet Ashley AllanR

    Please stop tagging me, I don't know the answer to your question.

  • > but it didnt work any help? Ribis? mekonbekon dop2000 blackhornet Ashley AllanR

    Please stop tagging me.

    Sorry, I just thought you'd be able to help, and I know you odnt really like me, so you wouldnt read this post. Sorry :(

  • Do you want to want to score a point for each answer per question that is correct i.e. both a selected correct answer and an unselected incorrect answer score a point, or just one point per question if the answers are 100% correctly selected?

    Would the score for the current question only be shown after "submit" had been pressed?

    Do you intend to keep a running total score?

  • Do you want to want to score a point for each answer per question that is correct i.e. both a selected correct answer and an unselected incorrect answer score a point, or just one point per question if the answers are 100% correctly selected?

    Would the score for the current question only be shown after "submit" had been pressed?

    Do you intend to keep a running total score?

    1. Just one point per question if the answers are 100% correctly selected, please.

    2. After submit is pressed, please.

    3.What do you mean by that?

    I hope this is not to much work...

  • I've updated the template - grab it again from the link above.

    In the checkQuestions function there is a local variable "n" - this tracks the number of incorrect answers. After running checkQuestions, if "n" is 0 (no incorrect answers) then the score is increased by one.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried this with a global variable because, I only want it to show in another layout called end, where it will say Your Score is: x . It didnot work.

  • "score" is already a global variable, you shouldn't need to add or change anything to how the scoring works, just include whatever method you want to go to the next layout - for example, in the template I provided after event 21 you can just add:

    + System: Else

    + txt_nextQuestion: Text is "QUIZ COMPLETE!" (Ignore case)

    -> System: Go to next layout

    And then in the next layout set the text on a text object to "Your Score is: "&score

  • "score" is already a global variable, you shouldn't need to add or change anything to how the scoring works, just include whatever method you want to go to the next layout - for example, in the template I provided after event 21 you can just add:

    + System: Else

    + txt_nextQuestion: Text is "QUIZ COMPLETE!" (Ignore case)

    -> System: Go to next layout

    And then in the next layout set the text on a text object to "Your Score is: "&score

    Yay! it worked!

  • "score" is already a global variable, you shouldn't need to add or change anything to how the scoring works, just include whatever method you want to go to the next layout - for example, in the template I provided after event 21 you can just add:

    + System: Else

    + txt_nextQuestion: Text is "QUIZ COMPLETE!" (Ignore case)

    -> System: Go to next layout

    And then in the next layout set the text on a text object to "Your Score is: "&score

    In my timer after you press submit it should stop the timer and save the current time somewhere. At last it should show the time for each question. What is the 'somwhere' where it could hold all this and how would you save it?

  • You could either create a separate 1D array (e.g. a_questionTimes) or use the indices at a_questions.At(0,currentQuestion,1)

  • You could either create a separate 1D array (e.g. a_questionTimes) or use the indices at a_questions.At(0,currentQuestion,1)

    Thnaks mekonbekon. Sorry for the late reply. I've been trying to make the score work but its not. Here's my app. Do you think you could identify the problem and tell meh hoew to fix it?

  • applern You haven't included a link to your app - post it up and I'll take a look.

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