I'm burning my mind and I cannot solve this problem.
I have a DB with QUESTIONS for a QUIZ.
I have 100 questions with 10 Points and 30 questions with 20 Points (and the idea is that I can have another questions with 30, 40 points)
I need to select randomly 20 questions.
But I need to select ALWAYS 15 questions with 10 points and 5 with 20 points.
and random all..
I can random all questions WITHOUT the "Always 15/5"
****
' Determines how many unique random numbers to be produced
tot_unique = 20
' Determines the highest value for any unique random number
top_number = 100
dim random_number, counter, check, unique_numbers
' When passing a varible for an array use redim
redim random_number(tot_unique)
' begin random function
randomize
' Begin a for next loop from one to the max number of unique numbers
For counter = 1 to tot_unique
' select a number between 1 and the top number value
random_number(counter) = Int(Rnd * top_number)+1
' For next loop to compare the values stored in the array to
' the new random value being assigned
for check=1 to counter-1
if random_number(check)= random_number(counter) then
' If the current value is equal to a previous value
' subject
counter=counter-1
end if
next ' Repeat loop to check values
next ' Repeat loop to assign values to the ar
Here I dont inform the questions with 10 or 20 points and the script random 20 UNIQUE numbers between 1-100.
I dont know how I can do this.. Any Idea?
Aucun commentaire:
Enregistrer un commentaire