Without duplication of questions

I’ve made a program that ask the user 10 questions in random. However, some of the questions are duplicated and asked again. For example, the first question that appears is question 1 and once the user select the correct answer, the second question that appears is also the same as the first question. How can I validate such that the same question that has already asked will not be asked again?

1 Like

You can try adding a variable called “answered” or maybe “done” and if it = 1 (true), set up events to present a new question or some other action that returns only unanswered questions. What do your events look like for this? Are you using "RandomInRange(#, #) or Random(#)?

It might help to use more than one variable to control the questions being presented.

I am using Random(#).

Do you have any example to show me? I appreciate if you have because I am just a beginner. Thank you

I don’t have any examples specific to what you’re trying to achieve without making it; I’m familiar with variables and randomizing things, but have never worked on a Q&A type of project in GD before.

Can you post a screenshot of the events that you do have for this part?

It will be easier to advise where changes or additions are needed.

Thank you.

I’m going to see if I can come up with an example to upload, but it might take some time.

What are the events above that “first scene” comment? Timer values, etc? It looks related.

When the Start button is clicked.

The flow for my game is that when the user clicks start, the game will begin and the first question will appear (randomnise every time the user clicks start). There will be four multiple choices, and if the user chooses the correct answer, another randomnise question will be asked. I am able to make the questions randomnise but then sometimes the question asked in the first question will be asked in the second question.

That’s because it needs to do a bit more than just randomize questions.

All Random(10) will do, by itself, is cycle through your whole question pool. It doesn’t automatically ‘know’ that it should exclude questions that have already been asked. Doing +1 to “proceed” doesn’t tell it to do that; even if you had a Proceed = 2 condition. You’ll need to use a few more variables and probably different random expressions to create a kind of filter.

The example I’d like to make will just show you one possible approach to doing that, but it will be a ‘take what you need or like from it and discard the rest’ kind of thing. Nothing super fancy,

How can i store the question that has already appeared once so that i can use it in another scene?

Use a global variable to compare the text.

It looks like you’re trying to use QuestionPic as both a question ID and random selector.

Question ID’s should be a unique variable that never changes.

I’d use a 0 value on the QuestionPic variable to trigger a RandomInRange(1, 10) expression and you can also set that as an action when questions are answered correctly - it should automatically trigger the randomization then without having to put the expression in again.

What is the Proceed variable intended to do and what’s the reasoning behind +1 for that one?

Proceed is to show the second scene.

If you don’t mind, can you write out how the codes will look like? I understand what you mean but it is a little difficult for me to write out the codes.

Do this…

Create a separate event line above where your questions start:

Condition: the scene variable QuestionPic is = 0
Action: Do = RandomInRange(1, 10) to scene variable Question Pic.
You can include your timers here too, I think.

The value for first question should be set to = 1 where you have 0 on QuestionPic.

That’s only a matter of editing that existing number value.

In the actions for every correct answer,
Do = 0 to scene variable QuestionPic.

I think you need a few more variables such as “done” for correct answers and to figure out a system of assigning unique ID’s to finish the filter. I’m sorry, but I can’t write all of the code out for it. Some things that I’m doing with my project is difficult as well even though I’ve been using GD for just over a year now.

I’ve tried doing these but it can’t seem to work.

Have you solved your doubt?

Have a look at this post:

That looks like a different issue from what Meddy is having here.

I guess he wants a random without repeat. Or not?