Multiple-Choice Problems...

Ken Ray kray at sonsothunder.com
Tue Nov 11 13:19:10 CST 2003


> That's pretty much it, though  there is a problem, which appears as I 
> get to the end of the listings in gSourceData. Once there are 
> less than 
> four questions left, a line is left blank, meaning that there is no 
> path for the image in the following questions. So instead of a pretty 
> vocabulary image, there's a blank spot, which repeats until the last 
> item in the list happens to be the randomly-selected "correct" answer.
> 
> I haven't been able to figure out a simple way to run through the 
> complete list without getting this blank spot. Actually, I 
> did think of 
> one way, but have no idea how to do the code- I'm afraid I do 
> fine with 
> small steps, but trying to implement something large gets the 
> better of 
> me. I'm sure there is a much more elegant solution to than what I've 
> already created- unfortunately, I haven't any idea how to proceed!
> 
> Sorry for the long post. I've rambled enough- any ideas from 
> anyone out 
> there in Rev land?

Jason,

The problem is (IMHO) that you're removing the correct answers from the
list so that you "eat away" at your overall list of answers. I would
suggest that you maintain two lists in memory: one list is the one with
all of the possible answers (basically what you read in button 1 -
gSourceData), the other contains the list that gets correct answers
removed when they are used so they won't be used again (I'll call it
'gAvailableData'). 

When you start on a specific drill, you pick a line randomly from
gAvailableData for the correct answer and remove it from gAvailableData.
You then temporarily copy gSourceData into a temporary variable, remove
the correct answer ALSO, leaving you with a temporary variable that only
contains incorrect answers. Randomly pick the other three from this
temporary variable, and run the drill. For each drill you do,
gAvailableData will diminish, but gSourceData will not - thus avoiding
the problem of having not enough data to do a drill.

Hope this helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/ 




More information about the use-livecode mailing list