I am building a Trivia Quiz Game and I'd like to rank people based on their answers.
The questions are basic trivia and people can answer A, B, C or D and then they are right or wrong.
I would like to rank them based on their answers but there are issue on some specific case :
Player 1 has answered 10 questions and had 5 right answers Player 2 has answered 6 questions and had 5 right answers
Which one should be ranked higher in this case ?
Should I use a total of right answers or the ratio or right answer to rank people ? Is there an algorithm that would use both data to provide a fair ranking based on those two metrics ? On the technical side, how to organize the data so I can be able to tell the rank of a player without scanning all the user DB ?
Let me know if you need more details. Thanks for your help.
You can punish the person by a -1
point to the wrong answer and prise by a +3
point to the right answer. As a person who chooses randomly the answer, the expected point would be zero such that 1/4 * 3 + 3/4 * -1 = 0
.
In a technical side, if you have two columns for each person which contain numbers of wrong and correct answers, you can compute the score for each person and then order them such as the following:
SELECT person_id, (wrong_num * (-1) + correct_num * 3) as rank
FROM scores
Order by rank