I have no idea hat your problem might be .... but here's what I'd try
next to see if I could figure out what's happening :-)
Change from
set the itemDel to tab
put "*" & item 3 of sRecSet into tPossibleAnswers -- correct answer
put cr & item 4 of sRecSet after tPossibleAnswers -- distractor 1
put cr & item 5 of sRecSet after tPossibleAnswers -- distractor 2
sort lines of tPossibleAnswers by random(999999) -- randomly re-order the list
to keeping a randomly generated value on the line ....
set the itemDel to tab
put "*" & item 3 of sRecSet &TAB& random(9999) into tPossibleAnswers -- correct
answer
put cr & item 4 of sRecSet &TAB& random(9999) after tPossibleAnswers --
distractor 1
put cr & item 5 of sRecSet &TAB& random(9999) after tPossibleAnswers --
distractor 2
then sort by those stored values
sort lines of tPossibleAnswers by item 2 of each -- randomly re-order the list
And then you can log/printout/examine in the debugger what the lines are
before/after the sort, and see if that helps you figure what is happening.
-- Alex.
On 22/05/2013 22:34, Chris Sheffield wrote:
Thanks for the suggestions everyone, but I'm still getting strange results, and
I'm beginning to think there's something I'm doing that's affecting use of the
random() function. Not really sure what it would be though. Here's my code:
set the itemDel to tab
put "*" & item 3 of sRecSet into tPossibleAnswers -- correct answer
put cr & item 4 of sRecSet after tPossibleAnswers -- distractor 1
put cr & item 5 of sRecSet after tPossibleAnswers -- distractor 2
sort lines of tPossibleAnswers by random(999999) -- randomly re-order the list
This app pulls words from a database and presents three possible answers to
choose from. The asterisk above is used to identify the correct answer after
the sort takes place. It's removed later on. The sort only works randomly one
time. After that, the same sort order is used every time, so the correct answer
*always* ends up listed first. It doesn't matter if I use a very high number or
if I use 'the number of lines of tPossibleAnswers'. Something is very strange.
Just as a quick test, I added a button to the card with this inside:
put "one" & cr & "two" & cr & "three" into tLines
sort lines of tLines by random(the number of lines of tLines)
answer tLines
This seems to work just fine. Yes, it does mean getting the same order
sometimes twice or maybe even three times in a row, but not usually more than
that, which would be fine in this case. So I'm not sure what's going on with my
actual code. I'm no longer setting the randomSeed or anything like that.
The other strange thing is no matter what I try, if I use the random() function or the
any keyword in anyway, I get similar results. Something is affecting the
"randomness". This is for an iOS app, btw, if that makes any difference to
anyone. This might be kind of a dumb thing to do, but the only other thing I can think of
would be to add several more lines of data to the three actual possible answers, then
sort the whole thing, then somehow filter out everything I added before the sort. With
more lines, maybe I'd get better results?
Thanks again,
Chris
On May 22, 2013, at 3:03 PM, Dar Scott <d...@swcp.com> wrote:
I think you are going to get the first line of the original list (correct
answer) about half the time. Does that seem right to you from what you have
seen? The correct answer will be in the first two about 80% of the time.
Using the larger argument for random should give you better proportions. You
should get it in the first line a third of the time.
If you only interested in the first line, there might be some methods that are
clearer and more fun.
Dar
On May 22, 2013, at 11:59 AM, Chris Sheffield wrote:
I have a list of three words that I need to be randomly sorted. To start with,
the first word is the correct answer to a question. I want to re-order the list
so that the correct answer may be the second or third word, and not necessarily
the first. How can I do this successfully every time? The docs give an example
like this:
sort lines of myVar by random(the number of lines of myVar)
But this only seems to work successfully one time. After that, the list is
always set so the first word is the correct answer. So then I tried randomly
setting the randomSeed value, since this value is supposed to affect the
random() function and the any keyword, but this didn't seem to make much
difference except to change it so either the second or third word is *always*
the right answer. I need it to be more mixed up than that.
So does anyone have a good way to do this?
Thanks,
Chris
--
Chris Sheffield
Read Naturally, Inc.
www.readnaturally.com
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode