Computer Science Canada Help With Randomizing the sequence of a quiz or anything like a quiz. |
Author: | shams1204 [ Sun Dec 17, 2017 7:54 pm ] | ||
Post subject: | Help With Randomizing the sequence of a quiz or anything like a quiz. | ||
What is it you are trying to achieve? I am trying to randomize the question pattern in my project. For example I have ten questions and the pattern of how the computer will ask the user the questions will be different. What is the problem you are having? <Answer Here> Describe what you have tried to solve this problem I tried using the rand but i dont know how to do it with the strings . Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using <Answer Here> 4.1.1 |
Author: | TokenHerbz [ Mon Dec 18, 2017 4:07 am ] |
Post subject: | RE:Help With Randomizing the sequence of a quiz or anything like a quiz. |
learn about arrays : http://compsci.ca/v3/viewtopic.php?t=14333 |
Author: | LolADuck [ Mon Dec 18, 2017 6:00 pm ] |
Post subject: | Re: Help With Randomizing the sequence of a quiz or anything like a quiz. |
Make an array, put ur question in there and have randint chose a cell in the array randomly. When the question has been answered, the cell is replaced with a filler word where if the filler word is in a cell it will redo the random int and pick another cell (assuming you want each question to only be asked once). |
Author: | shams1204 [ Tue Dec 19, 2017 7:11 pm ] |
Post subject: | Re: Help With Randomizing the sequence of a quiz or anything like a quiz. |
Okay so I did this and I dont know if i am doing it correctly. Help me with this please. And how do I make the randint choose a cell for once so that it asks the question only once. This is my code so far: procedure randomQuestions randint (randQuestions,1,4) for x: 1..4 questions (x) := 1 end for for x: 1..4 if repeatQuestions = randomQuestions (x) then repeatQuestions := false end if end for end randomQuestions var repeatQuestions:boolean:=true var questions: array1..4 of string var randQuestions:int these are my variables. |
Author: | LolADuck [ Wed Dec 20, 2017 11:20 am ] |
Post subject: | RE:Help With Randomizing the sequence of a quiz or anything like a quiz. |
after you go into that cell and ask the question replace it with a value so that if that value is in the cell that your rand int chooses, it goes back to the rand int line and selects a different cell. Also, im sorry but the code you wrote dosent make any sense to me... it has 6 errors. ![]() |
Author: | LolADuck [ Wed Dec 20, 2017 11:50 am ] | ||
Post subject: | Re: Help With Randomizing the sequence of a quiz or anything like a quiz. | ||
With the code you gave me this is what i assummed you meant. If not, can i get more detail??
|
Author: | shams1204 [ Thu Dec 21, 2017 9:15 am ] |
Post subject: | Re: Help With Randomizing the sequence of a quiz or anything like a quiz. |
Thank You for the code but its a quiz so I need the question to be displayed once only. The code works, thank you but what should I change in it so that it displays the questions only once. I'll send you my work. My work has a lot other things. Sorry if it bothers you. I also have a lot of things to fix but just look at my thing. |
Author: | TokenHerbz [ Thu Dec 21, 2017 5:21 pm ] | ||
Post subject: | RE:Help With Randomizing the sequence of a quiz or anything like a quiz. | ||
please take a look at flexible arrays, you want to remove the question after its displayed to avoid duplicates. http://compsci.ca/v3/viewtopic.php?t=7390 http://compsci.ca/holtsoft/doc/flexible.html you should play around with it and understand how it works otherwise you'll have a big headache.
|
Author: | shams1204 [ Thu Dec 21, 2017 6:53 pm ] |
Post subject: | Re: Help With Randomizing the sequence of a quiz or anything like a quiz. |
Sorry but we are not allowed to use flexible arrays. Just arrays and randint, not Rand.Int because we still didn't learn it yet. |
Author: | TokenHerbz [ Fri Dec 22, 2017 12:47 am ] |
Post subject: | RE:Help With Randomizing the sequence of a quiz or anything like a quiz. |
ranint is just a proc so you can still use it just modify it then, and if your not aloud to use flexible arrays just have a counter inside the loop to fine which question was posted to avoid posting it again. |
Author: | TokenHerbz [ Fri Dec 22, 2017 5:55 pm ] | ||
Post subject: | RE:Help With Randomizing the sequence of a quiz or anything like a quiz. | ||
|
Author: | shams1204 [ Sun Dec 24, 2017 3:18 pm ] |
Post subject: | Re: Help With Randomizing the sequence of a quiz or anything like a quiz. |
Um Thank You for helping me with this problem. I finally solved it but I have another Question. In my program I have buttons included and as I have random questions, I cannot say that this is question 1 and this is question 2. How do I do it. I tried this and it kind of works but it doesnt show my GUI Buttons. What should I do. Code I tried to use for this problem: % Program User Input procedure userInput for x:1..4 title put "YOU ARE ON QUESTION ",x,"." randomQuestions if randQuestion = 1 then firstQuestion elsif randQuestion = 2 then secondQuestion elsif randQuestion = 3 then thirdQuestion elsif randQuestion = 4 then fourthQuestion end if end for end userInput My whole project is given Below. |
Author: | TokenHerbz [ Tue Dec 26, 2017 7:03 pm ] |
Post subject: | RE:Help With Randomizing the sequence of a quiz or anything like a quiz. |
i'm not sure what exactly you mean, what is it you wanted to accomplish? browsing your code is a bit confusing so i'd like to know specifically, to better assist you, thanks. |
Author: | shams1204 [ Tue Dec 26, 2017 7:20 pm ] |
Post subject: | Re: Help With Randomizing the sequence of a quiz or anything like a quiz. |
Never mind. I managed to solve the problem by my own. Thank you btw for all the help. |
Author: | shams1204 [ Tue Jan 02, 2018 11:38 am ] |
Post subject: | Re: Help With Randomizing the sequence of a quiz or anything like a quiz. |
I just have one more problem. My program doesn't repeat itself after it the user has answered all the questions. It doesn't randomize either. Actually it stops there. Can u check why this happens. My project is given below. I havent finished it yet. I have done only 13 questions. I need to do 7 more but please help. |