Variables and Conditions
November 8, 2016 12:00 AM
I am working on creating an interactive bingo game in lectora. I have successfully been able to get the interactive card to populate using variables, however, what I have been unsuccessful at is not getting duplicates on the card.
I've attached a word doc with examples of what I have. Any suggestions on what I missed or need to do so that I can get 24 different responses on the card would be greatly appreciated!
Thanks,
Jen
Discussion (10)
Hi,
there are some poblems in the way you've set up the variable to contain unique random values. You give all your variables a random initial value between 1 and 52. Of course there's a good chance this will result in duplicates. Then you try to randomize it again, in case a value already exists?
An example with only 3 variables with random initial value between 1 -6 could be:
_B1 = 2
_B2 = 2
_B3 = 5
Your action to randomize _B1 again, is
Action: Modify variable
Target: _B1
Value: RAND(1,6)
Only if _B1 is not equal to _B2 AND is not equal to _B3
But in this example _B1 is equal to _B2 so the action is not executed and both variables _B1 and _B2 will keep their equal values and you'll have duplicates.
Even if the action was executed you have no precaution to prevent _B1 from being set to "2" again or being set to "5" and then being equal to _B3.
Another problem is that your action to randomize _B1 again is executed after the Change Content actions using this variable, i.e. the Change Content actions would react to the initial value of the variables.
I'd advise not to run all these actions with "On: Page show" actions attached to the various textfield, but use Action Groups. It'll be easier to control the sequence in that the actions are run. You should make sure the variables are set first and change the content of the textfields last when all the variables have their unique values.
Tim
I love this idea! I am not very familiar with JS, however it has been something that I want to learn. I just looked at the file you sent over, and I am following so far what its doing. But, with the suggestion of have 2-3 random options per box, how does that change the JS?
thank you so much for taking the time to help me out!!
undefined
I've noticed that, Sergey. I was actually working on my example when you posted.
US Presidents..she had to use US Presidents. LOL. For some reason when I see this sentence, "This way you will have a huge number of randomized bingos and guaranteed zero duplicates." I instead see, "you have a huge number of bozo's and one big guaranteed zero."
BTW, the alternative solution is awesome (and the way it is in real life)!
If you are open to using JS, it would be way, way, way easier to add a JS snippet that would populate your variables with the values you need without duplication. One action instead of dozens and dozens.
Darrel, you and I think like developers. I told my wife about this problem and she proposed the following solution:
Assign 2-3 values to each bing cell and randomize them. E.g. if your 52 values are US presidents, then cell B1 would be "Washington" or "Adams", I1 would be "Jefferson" or "Madison" ... O5 would be "Bush", "Obama" or "Trump". This way you will have a huge number of randomized bingos and guaranteed zero duplicates.
Alternatively, just create 10 pre-made bingo boards and show one of them randomly. No learner will play enough times to spot the difference.
One action instead of dozens and dozens.
In fact it would require 12.66 dozens of actions in 2.25 dozens of action groups ;-)
I forgot to delete the console.log statement in the script. While leaving it wont hurt, you can comment it out or delete the line.
With the 2-3 random options per box, you wouldn't need JS. Just 4 actions per each box, e.g. for the B1 box:
On Show - Set random value to B1 in the range of 1..3
On Show - set Textbox_B1 to "Jefferson" if B1 == 1
On Show - set Textbox_B1 to "Adams" if B1 == 2
On Show - set Textbox_B1 to "Washington" if B1 == 3
Hi Sergey -
Due to my time frame, I thought that what you suggested would be the quickest for me.
I still need to have a variable for each box right? and if so, should the initial value be 0? or should I have that be random?
Thanks,
Jen
undefined
Discussions have been disabled for this post