Register Quiz
#1

Hey everyone. I'm trying to make a quiz system, based on dialogs, but I'm kinda stuck. So, what I'm trying to achieve, is a set of questions (let's say 50 questions in total) with 4 answers, from which only 1 answer is correct.

Now, from those 50 questions, I want a quiz with only 20 questions, which are randomly selected from all those 50 questions. The quiz will only 'pop' when the player first registers on the server.

The thing is I don't know how to randomly select questions and check if the answer is correct.

Another thing, I want the answer orders to change. Let me give you an example, so you can understand better:

Question 1: How many apples I have?
Answers: a) 1; b) 5; c) 10; d) 20 (correct answer is c) 10)

The correct answer is 10. I want it to randomly change it's "position". At the next player, I want the answers to change, like:

Question 1: How many apples I have?
Answers: a) 10; b) 20; c) 5; d) 1 (correct answer is a) 10)
Reply
#2

pawn Код:
new rand = random(50);//number inside the () is the max number, so it will choose from 0-50(or 1-50 not sure).
ShowPlayerDialog(playerid, rand, bla bla bla bla)
That should get you started.
Reply
#3

Hah, no offense but that I know.

I know how to randomly select 20 questions out of 50. What I don't know, is how to check their correct answer? How can I 'assign' a correct answer to a question?
Reply
#4

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new rand = random(50);
    switch (dialogid)
    {
        case 1: // Register
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        SendClientMessage(playerid,-1,"Wrong answer! Try again!");
                        //bla bla bla
                    }
                    case 1:
                    {
                        SendClientMessage(playerid, -1, "Correct! Here's the next question...");
                        ShowPlayerDialog(playerid, rand, bla bla bla);
                        Quizlevel = ++;
                    }

                }
            }
        }
    }
    return 1;
}
Hope this helps.
Reply
#5

Honestly, that didn't help at all. I've used your 'example' in an older GM but I don't want to script every question and every answer for every question. Check the list item to see if it's correct and so on.

Let's say I have five (5) questions:

1. Question number 1? Correct answer is 'C'


2. Question number 2? Correct answer is 'B'


3. Question number 3? Correct answer is 'D'


4. Question number 4? Correct answer is 'B'


5. Question number 5? Correct answer is 'A'

Alright, so I 'configured' my questions.

Now, in a dialog, I randomly give out three (3) questions. How would I know what questions would randomly select? I can't guess what would the correct answer be.

I'm trying to avoid 'naming' questions, checking questions ID and then set the correct answer, that's the worst idea to make this script. I'm trying to script a 'dynamic' quiz. I want something like:

Question 1. What's my name? Correct answer 'B'.

Question 2. What's my age? Correct answer 'A'.

etc etc

The idea is to 'link' in someway the question with the correct answer.
Reply
#6

If you want, I could maybe be able to create this with Y_INI file system, because I can't really think of many other ways of doing it..Except that..

If you want that, tell me.

EDIT:But your still going to have to open each and every one of the files, and type in a question, couple of answers. And which answer is correct. Then the system will do the rest...
Reply
#7

Quote:
Originally Posted by JhnzRep
Посмотреть сообщение
If you want, I could maybe be able to create this with Y_INI file system, because I can't really think of many other ways of doing it..Except that..

If you want that, tell me.

EDIT:But your still going to have to open each and every one of the files, and type in a question, couple of answers. And which answer is correct. Then the system will do the rest...
That'd be perfect. I don't mind opening every file at a time, writing the question, answers and correct answer in it.

The thing is, I have no idea how to do it. I don't want you to script it all for me, I just want you to give me an example, or the base idea of how to do that.
Reply
#8

One bump. The post 'dissapeared' on page 5 or 6 ... Still waiting for a solution. I don't even know where to start from.
Reply
#9

pawn Код:
enum quiz {
    question[64],
    correctAnswer[64],
    wrongAnswer1[64],
    wrongAnswer2[64],
    wrongAnswer3[64],
};

new quizQuestions[][quiz] = {
   {"How many apples?", "10", "5", "15", "20"},
   // etc.
};
pawn Код:
new SelectedQuestions[20] = {-1, ...}, rand;

for(new i; i < sizeof(SelectedQuestions); i++)
{
    do rand = random(sizeof(quizQuestions));
    while(inArray(rand, SelectedQuestions));

    SelectedQuestions[i] = rand;
}
pawn Код:
stock inArray(value, const array[], size = sizeof(array))
{
    for(new i; i < size; i++)
        if(array[i] == value) return true;

    return false;
}
There's much more to it, but this should give you an idea.
Reply
#10

And how can I check if someone typed the correct answer of a question? Let's take your example:

"How many apples?". Correct answer is 5. How can I do it ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)