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










share|improve this question









New contributor




Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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















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










share|improve this question









New contributor




Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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













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










share|improve this question









New contributor




Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Ashley Mills

27.9k883110




27.9k883110






New contributor




Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Jonny Taylor

61




61




New contributor




Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Jonny Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 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










  • 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












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.






share|improve this answer





















  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Jonny Taylor is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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

























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.






share|improve this answer





















  • 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















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.






share|improve this answer





















  • 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













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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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










Jonny Taylor is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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.















 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen