# Run my quiz question randomly

**URL:** <https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956>\
**Category:** Uncategorized\
**Created:** [July 9, 2004, 3:31am UTC](https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956 "2004-07-09T03:31:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![karena](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@karena](https://forum.kirupa.com/u/karena)\
**Post date:** [July 9, 2004, 3:31am UTC](https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956/1 "2004-07-09T03:31:06Z")

</div>

i have an idea that i want to do a few quiz questions. But i want my question run randomly each time when different people play it.  
Any idea to do it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 9, 2004, 8:23pm UTC](https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956/2 "2004-07-09T20:23:57Z")

</div>

> [@karena](#):
>
> i have an idea that i want to do a few quiz questions. But i want my question run randomly each time when different people play it.  
> Any idea to do it?

not sure if you want the answers displayed as well but i`ve set up the code to show answers slightly later.  
Just 2 textfields answer & quest, this is typed on the timeline

questions = ;  
question = ;  
question.push(“first”);  
question.push(“firstanswer”);  
questions.push(question);  
question = ;  
question.push(“second”);  
question.push(“secondanswer”);  
questions.push(question);  
question = ;  
question.push(“third”);  
question.push(“thirdanswer”);  
questions.push(question);  
question = ;  
question.push(“forth”);  
question.push(“forthanswer”);  
questions.push(question);  
//etc  
delete question;  
shuffle = function () {  
return Math.round(Math.random());  
};

questions.sort(shuffle);

var i = 0;  
function changequestion() {  
answer.text = “”;  
quest.text = questions\*[0];

```
otherInterval = setInterval(showanswer, 2000, questions*[1]);
i++;
if (i&gt;questions.length) {
	clearInterval(myInterval);
}

```

}  
function showanswer(thing) {  
answer.text = thing;  
clearInterval(otherinterval);  
}  
myInterval = setInterval(changequestion, 5000);

Hope this helps

[http://www.gifsrus.com/testfile/arrayquestions.swf](http://www.gifsrus.com/testfile/arrayquestions.swf)  
keep refreshing and hopefully they should appear in a different order

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 11, 2004, 4:58am UTC](https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956/3 "2004-07-11T04:58:57Z")

</div>

a more simple aproach…hehehe

> [@stringy](#):
>
> not sure if you want the answers displayed as well but i`ve set up the code to show answers slightly later.  
> Just 2 textfields answer & quest, this is typed on the timeline
> 
> questions = ;  
> question = ;  
> question.push(“first”);  
> question.push(“firstanswer”);  
> questions.push(question);  
> question = ;  
> question.push(“second”);  
> question.push(“secondanswer”);  
> questions.push(question);  
> question = ;  
> question.push(“third”);  
> question.push(“thirdanswer”);  
> questions.push(question);  
> question = ;  
> question.push(“forth”);  
> question.push(“forthanswer”);  
> questions.push(question);  
> //etc  
> delete question;  
> shuffle = function () {  
> return Math.round(Math.random());  
> };
> 
> questions.sort(shuffle);
> 
> var i = 0;  
> function changequestion() {  
> answer.text = “”;  
> quest.text = questions\*[0];
> 
> ```
> otherInterval = setInterval(showanswer, 2000, questions*[1]);
> i++;
> if (i&gt;questions.length) {
> clearInterval(myInterval);
> }
> 
> ```
> 
> }  
> function showanswer(thing) {  
> answer.text = thing;  
> clearInterval(otherinterval);  
> }  
> myInterval = setInterval(changequestion, 5000);
> 
> Hope this helps
> 
> [http://www.gifsrus.com/testfile/arrayquestions.swf](http://www.gifsrus.com/testfile/arrayquestions.swf)  
> keep refreshing and hopefully they should appear in a different order

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 12, 2004, 1:26am UTC](https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956/4 "2004-07-12T01:26:31Z")

</div>

thankx …i will try out stringy method…  
g-shock i understand ur coding but waht i want is the every question will be load but the sequence is different each time when different user answer the question…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 12, 2004, 6:31am UTC](https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956/5 "2004-07-12T06:31:53Z")

</div>

i try out stringy method but what i want is i hav a ‘next’ button .When i click the button, the next random question will show.Each time any user answer those question ,the sequence of those question will be different.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 12, 2004, 4:00pm UTC](https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956/6 "2004-07-12T16:00:34Z")

</div>

> [@karena](#):
>
> i try out stringy method but what i want is i hav a ‘next’ button .When i click the button, the next random question will show.Each time any user answer those question ,the sequence of those question will be different.

delete the code you have put on the button and give it an instance name myButton, then back on the main timeline

questions = ;  
question = ;  
myButton.btn\_txt = “Start”;  
question.push(“first”);  
question.push(“firstanswer”);  
questions.push(question);  
question = ;  
question.push(“second”);  
question.push(“secondanswer”);  
questions.push(question);  
question = ;  
question.push(“third”);  
question.push(“thirdanswer”);  
questions.push(question);  
question = ;  
question.push(“forth”);  
question.push(“forthanswer”);  
questions.push(question);  
//etc  
delete question;  
shuffle = function () {  
return Math.round(Math.random());  
};  
questions.sort(shuffle);  
var i = 0;  
function changequestion() {  
myButton.enabled = false;  
clearInterval(otherinterval);  
answer.text = “”;  
quest.text = questions\*[0];  
otherInterval = setInterval(showanswer, 2000, questions\*[1]);  
i++;  
if (i\>questions.length) {  
quest.text = “End of Quiz”;  
myButton.btn\_txt = “Finished”;  
}  
}  
function showanswer(thing) {  
answer.text = thing;  
clearInterval(otherinterval);  
myButton.enabled = true;  
}  
myButton.onPress = changequestion;

//you might also consider having a dynamic textfield in the button.(myButton.btn\_txt)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 13, 2004, 1:20am UTC](https://forum.kirupa.com/t/run-my-quiz-question-randomly/56956/7 "2004-07-13T01:20:30Z")

</div>

thank you stringy…  
i able to do that again…thousand of thank you and thank you…:panda:
