Hi,
I am trying to create a multiple choice test where the Questions and
stored in one field and displayed in another field. Similarly the
answers are stored in one field and displayed in another field. In my
storage field where i store all my answers i use a (,) as a delimiter
and (;) for the end of a question. How do i create a random answer
generator from the code below. This code pickups the answer depending onthe 
frame label number, but i want to have different answer choices like on 
first entry it is [1,2,3,4] and on second it is [3,2,1,4]



This code is applied to a frame script.

global gQuestionNum, gKeyCount

on enterFrame me
  question = value((the framelabel).word[2])
  gQuestionNum = question
  showAnswer
end

on showAnswer me
  set the lineHeight of field "answer_field" to 20
  testText = member("answers").text.line[gQuestionNum]
  the itemDelimiter = ","
  total = (testText.item.count)
  testLine = 1
  temp = ""
  repeat with x = 1 to total
    if x < total then
      put testText.item[x] & RETURN after temp
    else
      totChar = testText.item[x].char.count - 1
      put testText.item[x].char[1..totChar] after temp
    end if
    testLine = testLine+1
  end repeat
  member("answer_field").text = temp
end


on beginSprite me
  mySp = sprite(me.spriteNum)
  correctLine = 1
  sendAllSprites(#mixUpLines, correctLine)
  question = value((the framelabel).word[2])
  gQuestionNum = question
end

This behavior is applied to the field to check the correct answer
(stripped down version) and to change the answer pattern.

on mixUpLines me, correctLine
  correctAnswer = whatdo
  answerList = []
  repeat with n = 1 to mySp.member.lineCount
    randomNum = random (answerList.count+1)
    addAt answerList, randomNum, mySp.member.line[n]
  end repeat

  newText = EMPTY
  repeat with n = 1 to answerList.count
    put answerList[n] after newText
    if n < answerList.count then put RETURN after newText
  end repeat
  mySp.member.text = newText
end



ravi
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to