How can I increase the recurrence of a question in a quiz?
up vote
1
down vote
favorite
I am developing a quiz based app on Swift and the questions repeat several times within a set time limit. If the user gets a specific question wrong I would like the app to increase the recurrence of this question.
Any help would be appreciated greatly!
Many thanks,
Jonny
swift
New contributor
add a comment |
up vote
1
down vote
favorite
I am developing a quiz based app on Swift and the questions repeat several times within a set time limit. If the user gets a specific question wrong I would like the app to increase the recurrence of this question.
Any help would be appreciated greatly!
Many thanks,
Jonny
swift
New contributor
Could you show us your class, or any code you have written?
– J. Doe
2 days ago
Thanks for your reply. I have not yet started writing the code. I am a complete beginner in Swift and so I am just trying to get an idea of what is possible and any possible solutions to this problem. Many thanks!
– Jonny Taylor
yesterday
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am developing a quiz based app on Swift and the questions repeat several times within a set time limit. If the user gets a specific question wrong I would like the app to increase the recurrence of this question.
Any help would be appreciated greatly!
Many thanks,
Jonny
swift
New contributor
I am developing a quiz based app on Swift and the questions repeat several times within a set time limit. If the user gets a specific question wrong I would like the app to increase the recurrence of this question.
Any help would be appreciated greatly!
Many thanks,
Jonny
swift
swift
New contributor
New contributor
edited 2 days ago
Ashley Mills
27.9k883110
27.9k883110
New contributor
asked 2 days ago
Jonny Taylor
61
61
New contributor
New contributor
Could you show us your class, or any code you have written?
– J. Doe
2 days ago
Thanks for your reply. I have not yet started writing the code. I am a complete beginner in Swift and so I am just trying to get an idea of what is possible and any possible solutions to this problem. Many thanks!
– Jonny Taylor
yesterday
add a comment |
Could you show us your class, or any code you have written?
– J. Doe
2 days ago
Thanks for your reply. I have not yet started writing the code. I am a complete beginner in Swift and so I am just trying to get an idea of what is possible and any possible solutions to this problem. Many thanks!
– Jonny Taylor
yesterday
Could you show us your class, or any code you have written?
– J. Doe
2 days ago
Could you show us your class, or any code you have written?
– J. Doe
2 days ago
Thanks for your reply. I have not yet started writing the code. I am a complete beginner in Swift and so I am just trying to get an idea of what is possible and any possible solutions to this problem. Many thanks!
– Jonny Taylor
yesterday
Thanks for your reply. I have not yet started writing the code. I am a complete beginner in Swift and so I am just trying to get an idea of what is possible and any possible solutions to this problem. Many thanks!
– Jonny Taylor
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Not really a Swift question - more about what approach to take to solve your problem. There are many ways to achieve this and which one is right for you will probably depend upon how precise you want to be with the probabilities of a particular question being asked and your own coding ability.
The simplest approach would probably be to have an array of questions and use array.randomElement() to choose a question randomly from that array. If the user gets the question wrong you add that question to the array again. That's definitely not the best approach but if you are having trouble with this yourself it may be the best for you.
This is the right approach, but if OP wants to increase the incorrect question's occurrence, he should not only re-add it to the list, but add it again so that its likelihood of being selected again increases by that much.
– NRitH
2 days ago
@NRitH that's why I said he should add the question to the array again...
– 365SplendidSuns
2 days ago
Thank you both for your replies. That method would definitely be a good starting point for me. @365SplendidSuns what approach would you take to solve this problem? (as you mentioned this is not the best approach). Also some additional detail: If the user “repeatedly" got a question wrong I would like to continue increasing the occurrence of that question until it is being asked every 3 questions. Equally once the user started getting the question correct I would like to reduce it back down until it has an equal chance of being selected again.
– Jonny Taylor
yesterday
@JonnyTaylor A lo depends on the context but I guess I would make a Question class holding the question text as a property along with the answer and methods for checking the answer etc. The class would have a variable holding a float between 0 and 1 indicating the weighting that question should have fro being chosen to be displayed. In my main code I would have an array of Question objects. Pick a question from the array at random then generate a random number between 0 and 1. If the number is < that question's weighting property you display the question if > you repeat with another question.
– 365SplendidSuns
20 hours ago
If the user gets the question wrong you increase the weighting up to a limit. Right you decrease it. Forcing it to be asked every 3 questions when at the limit will make things a bit more complex because on every third question you will have to use a different approach to choosing the question. It also means that if they keep getting a lot of questions wrong they will be stuck with the same three repeatedly until they get it right so personally I would avoid that unless it is a specification I have to work with.
– 365SplendidSuns
20 hours ago
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Not really a Swift question - more about what approach to take to solve your problem. There are many ways to achieve this and which one is right for you will probably depend upon how precise you want to be with the probabilities of a particular question being asked and your own coding ability.
The simplest approach would probably be to have an array of questions and use array.randomElement() to choose a question randomly from that array. If the user gets the question wrong you add that question to the array again. That's definitely not the best approach but if you are having trouble with this yourself it may be the best for you.
This is the right approach, but if OP wants to increase the incorrect question's occurrence, he should not only re-add it to the list, but add it again so that its likelihood of being selected again increases by that much.
– NRitH
2 days ago
@NRitH that's why I said he should add the question to the array again...
– 365SplendidSuns
2 days ago
Thank you both for your replies. That method would definitely be a good starting point for me. @365SplendidSuns what approach would you take to solve this problem? (as you mentioned this is not the best approach). Also some additional detail: If the user “repeatedly" got a question wrong I would like to continue increasing the occurrence of that question until it is being asked every 3 questions. Equally once the user started getting the question correct I would like to reduce it back down until it has an equal chance of being selected again.
– Jonny Taylor
yesterday
@JonnyTaylor A lo depends on the context but I guess I would make a Question class holding the question text as a property along with the answer and methods for checking the answer etc. The class would have a variable holding a float between 0 and 1 indicating the weighting that question should have fro being chosen to be displayed. In my main code I would have an array of Question objects. Pick a question from the array at random then generate a random number between 0 and 1. If the number is < that question's weighting property you display the question if > you repeat with another question.
– 365SplendidSuns
20 hours ago
If the user gets the question wrong you increase the weighting up to a limit. Right you decrease it. Forcing it to be asked every 3 questions when at the limit will make things a bit more complex because on every third question you will have to use a different approach to choosing the question. It also means that if they keep getting a lot of questions wrong they will be stuck with the same three repeatedly until they get it right so personally I would avoid that unless it is a specification I have to work with.
– 365SplendidSuns
20 hours ago
|
show 2 more comments
up vote
0
down vote
Not really a Swift question - more about what approach to take to solve your problem. There are many ways to achieve this and which one is right for you will probably depend upon how precise you want to be with the probabilities of a particular question being asked and your own coding ability.
The simplest approach would probably be to have an array of questions and use array.randomElement() to choose a question randomly from that array. If the user gets the question wrong you add that question to the array again. That's definitely not the best approach but if you are having trouble with this yourself it may be the best for you.
This is the right approach, but if OP wants to increase the incorrect question's occurrence, he should not only re-add it to the list, but add it again so that its likelihood of being selected again increases by that much.
– NRitH
2 days ago
@NRitH that's why I said he should add the question to the array again...
– 365SplendidSuns
2 days ago
Thank you both for your replies. That method would definitely be a good starting point for me. @365SplendidSuns what approach would you take to solve this problem? (as you mentioned this is not the best approach). Also some additional detail: If the user “repeatedly" got a question wrong I would like to continue increasing the occurrence of that question until it is being asked every 3 questions. Equally once the user started getting the question correct I would like to reduce it back down until it has an equal chance of being selected again.
– Jonny Taylor
yesterday
@JonnyTaylor A lo depends on the context but I guess I would make a Question class holding the question text as a property along with the answer and methods for checking the answer etc. The class would have a variable holding a float between 0 and 1 indicating the weighting that question should have fro being chosen to be displayed. In my main code I would have an array of Question objects. Pick a question from the array at random then generate a random number between 0 and 1. If the number is < that question's weighting property you display the question if > you repeat with another question.
– 365SplendidSuns
20 hours ago
If the user gets the question wrong you increase the weighting up to a limit. Right you decrease it. Forcing it to be asked every 3 questions when at the limit will make things a bit more complex because on every third question you will have to use a different approach to choosing the question. It also means that if they keep getting a lot of questions wrong they will be stuck with the same three repeatedly until they get it right so personally I would avoid that unless it is a specification I have to work with.
– 365SplendidSuns
20 hours ago
|
show 2 more comments
up vote
0
down vote
up vote
0
down vote
Not really a Swift question - more about what approach to take to solve your problem. There are many ways to achieve this and which one is right for you will probably depend upon how precise you want to be with the probabilities of a particular question being asked and your own coding ability.
The simplest approach would probably be to have an array of questions and use array.randomElement() to choose a question randomly from that array. If the user gets the question wrong you add that question to the array again. That's definitely not the best approach but if you are having trouble with this yourself it may be the best for you.
Not really a Swift question - more about what approach to take to solve your problem. There are many ways to achieve this and which one is right for you will probably depend upon how precise you want to be with the probabilities of a particular question being asked and your own coding ability.
The simplest approach would probably be to have an array of questions and use array.randomElement() to choose a question randomly from that array. If the user gets the question wrong you add that question to the array again. That's definitely not the best approach but if you are having trouble with this yourself it may be the best for you.
answered 2 days ago
365SplendidSuns
2,00511221
2,00511221
This is the right approach, but if OP wants to increase the incorrect question's occurrence, he should not only re-add it to the list, but add it again so that its likelihood of being selected again increases by that much.
– NRitH
2 days ago
@NRitH that's why I said he should add the question to the array again...
– 365SplendidSuns
2 days ago
Thank you both for your replies. That method would definitely be a good starting point for me. @365SplendidSuns what approach would you take to solve this problem? (as you mentioned this is not the best approach). Also some additional detail: If the user “repeatedly" got a question wrong I would like to continue increasing the occurrence of that question until it is being asked every 3 questions. Equally once the user started getting the question correct I would like to reduce it back down until it has an equal chance of being selected again.
– Jonny Taylor
yesterday
@JonnyTaylor A lo depends on the context but I guess I would make a Question class holding the question text as a property along with the answer and methods for checking the answer etc. The class would have a variable holding a float between 0 and 1 indicating the weighting that question should have fro being chosen to be displayed. In my main code I would have an array of Question objects. Pick a question from the array at random then generate a random number between 0 and 1. If the number is < that question's weighting property you display the question if > you repeat with another question.
– 365SplendidSuns
20 hours ago
If the user gets the question wrong you increase the weighting up to a limit. Right you decrease it. Forcing it to be asked every 3 questions when at the limit will make things a bit more complex because on every third question you will have to use a different approach to choosing the question. It also means that if they keep getting a lot of questions wrong they will be stuck with the same three repeatedly until they get it right so personally I would avoid that unless it is a specification I have to work with.
– 365SplendidSuns
20 hours ago
|
show 2 more comments
This is the right approach, but if OP wants to increase the incorrect question's occurrence, he should not only re-add it to the list, but add it again so that its likelihood of being selected again increases by that much.
– NRitH
2 days ago
@NRitH that's why I said he should add the question to the array again...
– 365SplendidSuns
2 days ago
Thank you both for your replies. That method would definitely be a good starting point for me. @365SplendidSuns what approach would you take to solve this problem? (as you mentioned this is not the best approach). Also some additional detail: If the user “repeatedly" got a question wrong I would like to continue increasing the occurrence of that question until it is being asked every 3 questions. Equally once the user started getting the question correct I would like to reduce it back down until it has an equal chance of being selected again.
– Jonny Taylor
yesterday
@JonnyTaylor A lo depends on the context but I guess I would make a Question class holding the question text as a property along with the answer and methods for checking the answer etc. The class would have a variable holding a float between 0 and 1 indicating the weighting that question should have fro being chosen to be displayed. In my main code I would have an array of Question objects. Pick a question from the array at random then generate a random number between 0 and 1. If the number is < that question's weighting property you display the question if > you repeat with another question.
– 365SplendidSuns
20 hours ago
If the user gets the question wrong you increase the weighting up to a limit. Right you decrease it. Forcing it to be asked every 3 questions when at the limit will make things a bit more complex because on every third question you will have to use a different approach to choosing the question. It also means that if they keep getting a lot of questions wrong they will be stuck with the same three repeatedly until they get it right so personally I would avoid that unless it is a specification I have to work with.
– 365SplendidSuns
20 hours ago
This is the right approach, but if OP wants to increase the incorrect question's occurrence, he should not only re-add it to the list, but add it again so that its likelihood of being selected again increases by that much.
– NRitH
2 days ago
This is the right approach, but if OP wants to increase the incorrect question's occurrence, he should not only re-add it to the list, but add it again so that its likelihood of being selected again increases by that much.
– NRitH
2 days ago
@NRitH that's why I said he should add the question to the array again...
– 365SplendidSuns
2 days ago
@NRitH that's why I said he should add the question to the array again...
– 365SplendidSuns
2 days ago
Thank you both for your replies. That method would definitely be a good starting point for me. @365SplendidSuns what approach would you take to solve this problem? (as you mentioned this is not the best approach). Also some additional detail: If the user “repeatedly" got a question wrong I would like to continue increasing the occurrence of that question until it is being asked every 3 questions. Equally once the user started getting the question correct I would like to reduce it back down until it has an equal chance of being selected again.
– Jonny Taylor
yesterday
Thank you both for your replies. That method would definitely be a good starting point for me. @365SplendidSuns what approach would you take to solve this problem? (as you mentioned this is not the best approach). Also some additional detail: If the user “repeatedly" got a question wrong I would like to continue increasing the occurrence of that question until it is being asked every 3 questions. Equally once the user started getting the question correct I would like to reduce it back down until it has an equal chance of being selected again.
– Jonny Taylor
yesterday
@JonnyTaylor A lo depends on the context but I guess I would make a Question class holding the question text as a property along with the answer and methods for checking the answer etc. The class would have a variable holding a float between 0 and 1 indicating the weighting that question should have fro being chosen to be displayed. In my main code I would have an array of Question objects. Pick a question from the array at random then generate a random number between 0 and 1. If the number is < that question's weighting property you display the question if > you repeat with another question.
– 365SplendidSuns
20 hours ago
@JonnyTaylor A lo depends on the context but I guess I would make a Question class holding the question text as a property along with the answer and methods for checking the answer etc. The class would have a variable holding a float between 0 and 1 indicating the weighting that question should have fro being chosen to be displayed. In my main code I would have an array of Question objects. Pick a question from the array at random then generate a random number between 0 and 1. If the number is < that question's weighting property you display the question if > you repeat with another question.
– 365SplendidSuns
20 hours ago
If the user gets the question wrong you increase the weighting up to a limit. Right you decrease it. Forcing it to be asked every 3 questions when at the limit will make things a bit more complex because on every third question you will have to use a different approach to choosing the question. It also means that if they keep getting a lot of questions wrong they will be stuck with the same three repeatedly until they get it right so personally I would avoid that unless it is a specification I have to work with.
– 365SplendidSuns
20 hours ago
If the user gets the question wrong you increase the weighting up to a limit. Right you decrease it. Forcing it to be asked every 3 questions when at the limit will make things a bit more complex because on every third question you will have to use a different approach to choosing the question. It also means that if they keep getting a lot of questions wrong they will be stuck with the same three repeatedly until they get it right so personally I would avoid that unless it is a specification I have to work with.
– 365SplendidSuns
20 hours ago
|
show 2 more comments
Jonny Taylor is a new contributor. Be nice, and check out our Code of Conduct.
Jonny Taylor is a new contributor. Be nice, and check out our Code of Conduct.
Jonny Taylor is a new contributor. Be nice, and check out our Code of Conduct.
Jonny Taylor is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372973%2fhow-can-i-increase-the-recurrence-of-a-question-in-a-quiz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you show us your class, or any code you have written?
– J. Doe
2 days ago
Thanks for your reply. I have not yet started writing the code. I am a complete beginner in Swift and so I am just trying to get an idea of what is possible and any possible solutions to this problem. Many thanks!
– Jonny Taylor
yesterday