00:00
00:00
Newgrounds Background Image Theme

JustAndrew just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

foss: quiz maker

1,686 Views | 6 Replies
New Topic Respond to this Topic

foss: quiz maker 2005-07-28 10:56:37


foss: main
its a quiz generator

format = new TextFormat();
format.size = 15;
format.font = "Arial";
_root.createTextField("q", 12, 150, 75, 375, 30);
q.setTextFormat(format);
_root.createTextField("a", 13, 90, 190, 165, 30);
a.setTextFormat(format);
_root.createTextField("b", 14, 300, 190, 165, 30);
b.setTextFormat(format);
_root.createTextField("c", 15, 90, 250, 165, 30);
c.setTextFormat(format);
_root.createTextField("d", 16, 300, 250, 165, 30);
d.setTextFormat(format);
a.selectable = b.selectable=c.selectable=d.selectable=fal
se;
//----------------------------------------
---------------
_root.createEmptyMovieClip("buttona", 7);
_root.buttona.lineStyle(3, "0x0099FF", 100);
_root.buttona.beginFill("0x00CCFF", 100);
_root.buttona.moveTo(-75, -10);
_root.buttona.lineTo(75, -10);
_root.buttona.lineTo(75, 10);
_root.buttona.lineTo(-75, 10);
_root.buttona.lineTo(-75, -10);
//----------------------------------------
---------------
_root.buttona._x = 150;
_root.buttona._y = 200;
_root.buttona.duplicateMovieClip("buttonb"
, 8);
_root.buttonb._x = 360;
_root.buttonb._y = 200;
_root.buttona.duplicateMovieClip("buttonc"
, 9);
_root.buttonc._x = 150;
_root.buttonc._y = 260;
_root.buttona.duplicateMovieClip("buttond"
, 10);
_root.buttond._x = 360;
_root.buttond._y = 260;
//----------------------------------------
---------------
_root.buttona.onPress = function() {
if (questions[done[currentQuestion-1]][used[0
]+1] == questions[done[currentQuestion-1]][1]) {
_root.score++;
}
if (done.length<questions.length) {
currentQuestion++;
addNew(questions.length, done);
arrangeAnswers();
} else {
endQuiz();
}
};
//--------------------
_root.buttonb.onPress = function() {
if (questions[done[currentQuestion-1]][used[1
]+1] == questions[done[currentQuestion-1]][1]) {
_root.score++;
}
if (done.length<questions.length) {
currentQuestion++;
addNew(questions.length, done);
arrangeAnswers();
} else {
endQuiz();
}
};
//--------------------
_root.buttonc.onPress = function() {
if (questions[done[currentQuestion-1]][used[2
]+1] == questions[done[currentQuestion-1]][1]) {
_root.score++;
}
if (done.length<questions.length) {
currentQuestion++;
addNew(questions.length, done);
arrangeAnswers();
} else {
endQuiz();
}
};
//--------------------
_root.buttond.onPress = function() {
if (questions[done[currentQuestion-1]][used[3
]+1] == questions[done[currentQuestion-1]][1]) {
_root.score++;
}
if (done.length<questions.length) {
currentQuestion++;
addNew(questions.length, done);
arrangeAnswers();
} else {
endQuiz();
}
};
//----------------------------------------
---------------
_root.score = 0;
done = new Array();
currentQuestion = 1;
questions = [["what color is the sky?", "blue", "red", "green", "yellow"],
["dogs go ____", "bark", "meow", "moo", "ROFFEL"],
["some other question", "correct answer", "wrong answer", "wrong answer2", "wrong answer3"]];
done[0] = random(questions.length);
//----------------------------------------
---------------
addNew = function (max, arr) {
unused = true;
ranmax = random(max);
for (i in arr) {
ranmax == arr[i] ? unused=false : null;
}
unused ? arr.push(ranmax) : addNew(max, arr);
};
//----------------------------------------
---------------
changeAnswers = function () {
_root.q.text = currentQuestion+".) "+questions[done[currentQuestion-1]][0];
_root.a.text = "A: "+questions[done[currentQuestion-1]][used[
0]+1];
_root.b.text = "B: "+questions[done[currentQuestion-1]][used[
1]+1];
_root.c.text = "C: "+questions[done[currentQuestion-1]][used[
2]+1];
_root.d.text = "D: "+questions[done[currentQuestion-1]][used[
3]+1];
};
//----------------------------------------
---------------
arrangeAnswers = function () {
used = new Array();
used[0] = random(4);
addNew(4, used);
addNew(4, used);
addNew(4, used);
changeAnswers();
};
arrangeAnswers();
//----------------------------------------
---------------
endQuiz = function () {
_root.q.text = "Score: "+_root.score+"/"+questions.length;
_root.a.text = _root.b.text=_root.c.text=_root.d.text="";
_root.buttona.clear();
_root.buttonb.clear();
_root.buttonc.clear();
_root.buttond.clear();
};

to make your own change questions to something like this
questions=[[question,correct answer, wrong answer, wrong answer, wrong answer],[question2,right,wrong,wrong,wrong
]]you can have as many questions as you want but only 4 answers for each question. this wasnt supposed to be api but i didnt want to have to explain what to do for each moviecip
here's the finished file

Response to foss: quiz maker 2005-07-28 10:58:35


crap newgrounds screwed up the seperators. i didnt wanna explain what each did, but i tought it helps to at least divide importent parts. so you can just delete all the ---------'s

Response to foss: quiz maker 2005-07-28 11:01:33


simple, but effective.


website :: hugostonge.com

my job :: we+are

Response to foss: quiz maker 2005-07-28 11:06:34


simple................ what. i never used so many function. theres a bunch a for loop and recursion. this is like the most complex thing ive made in a while...

also i realised i dont need to have a changeanswers function and an arrangeanswers function
so replace them with this

arrangeAnswers = function () {
used = new Array();
used[0] = random(4);
addNew(4, used);
addNew(4, used);
addNew(4, used);
changeAnswers();
_root.q.text = currentQuestion+".) "+questions[done[currentQuestion-1]][0];
_root.a.text = "A: "+questions[done[currentQuestion-1]][used[
0]+1];
_root.b.text = "B: "+questions[done[currentQuestion-1]][used[
1]+1];
_root.c.text = "C: "+questions[done[currentQuestion-1]][used[
2]+1];
_root.d.text = "D: "+questions[done[currentQuestion-1]][used[
3]+1];
};
its just simpler

Response to foss: quiz maker 2005-07-28 11:07:50


That is nice!

Watch out though toast will come and say "why not just make buttons"

Seriously though that is a really good idea.


- Matt, Rustyarcade.com

Response to foss: quiz maker 2005-07-28 11:09:30


what i meant is simple graphics.


website :: hugostonge.com

my job :: we+are

Response to foss: quiz maker 2005-07-28 11:12:24


ya i might make better ones..... but probly not