ilmtest / ilmtest-bb10

Ilm Test trivia game
0 stars 0 forks source link

Random question picking can get into an infinite loop state #102

Open ragaeeb opened 9 years ago

ragaeeb commented 9 years ago

Assume there are only 2 ordered questions in the entire database [id = 3,4].

Currently the logic for picking questions is:

  1. x = random # between 1 and 10.

if (x == 5) then fetch an ordered question.

y = ordered_question_id = 4;

user gets question right.

x = random # between 1 and 10 = 5; fetch an ordered question where question_id NOT IN [4] y = ordered_question_id= 3;

user gets question right.

x = random # between 1 and 10 = 5; fetch an ordered question where question_id NOT IN [3,4] no questions found.

x = random # between 1 and 10 = 5; fetch an ordered question where question_id NOT IN [3,4] no questions found. ...

infinite loop

ragaeeb commented 9 years ago

Possible solution:

database has N = 20 questions total. there are S = 19 standard multiple choice questions available. there are B = 4 bool questions available. there are O = 2 ordered questions available. we want to display a total of X = 10 questions for the session. [may need to be adjusted with N]

we want total standard multiple choice to be: X*( rand(0.7,0.8) ) = 7

3 remaining.

we want total bool questions to be (10%): Y*( rand(0.1,0.1) )...

1 remaining, rest of them will be ordered questions.

ragaeeb commented 9 years ago

a21b6cbb90ed52781dea46ad79ad6541fdb4808c