Created
May 26, 2010 18:41
-
-
Save adelevie/414870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #read more about abingo here: http://www.bingocardcreator.com/abingo/ | |
| def self.find_alternative_for_user(test_name, alternatives) | |
| alternatives_array = retrieve_alternatives(test_name, alternatives) | |
| alternatives_array[self.modulo_choice(test_name, alternatives_array.size)] | |
| end | |
| #Quickly determines what alternative to show a given user. Given a test name | |
| #and their identity, we hash them together (which, for MD5, provably introduces | |
| #enough entropy that we don't care) otherwise | |
| def self.modulo_choice(test_name, choices_count) | |
| Digest::MD5.hexdigest(Abingo.salt.to_s + test_name + self.identity.to_s).to_i(16) % choices_count | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment