Making quiz app score

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
totalnoob
Posts: 20
Joined: Tue Jul 02, 2013 10:40 am

Making quiz app score

Post by totalnoob » Tue Jul 02, 2013 11:13 am

Hi im new in livecode and i want make quiz app.
my code looks like

Code: Select all

on pickQuestion
  put 1 into currentQues
  put line currentQues of fld "questions" into qLine
  put item 1 of qLine into fld "Field"
  repeat with i = 2 to 5
    put "Answer" & i - 1 into fieldName 
  set label of btn "Answer1" to item i of qLine
 set label of btn "Answer2" to item 2 of qLine
 set label of btn "Answer3" to item 3 of qLine
 set label of btn "Answer4" to item 4 of qLine
end repeat

   
                
end pickQuestion
everything working fine but i want create some kind of score but dont know how can someone help me ?
i was trying to add score label with
on mouseUp
go to next card
add 10 to the field "Score"
end mouseUp
but it doesnt show same score after few cards even this
put number of fld "score" of card "card2" into fld "score" of card "card3"
doesnt working
thanks
Last edited by totalnoob on Tue Jul 02, 2013 12:03 pm, edited 1 time in total.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Making quiz app score

Post by shaosean » Tue Jul 02, 2013 11:56 am

Just curious about a couple of things..

Code: Select all

  repeat with i = 2 to 5
    put "Answer" & i - 1 into fieldName  --put field name into a variable
How come you are looping with 2 to 5 and then subtracting 1 on the next line? Why not just loop with 1 to 4?

Code: Select all

  set label of btn "Answer1" to item i of qLine
With your original script, your "Answer1" button will always be the same value as one of the other Answer buttons.. Is this what you are looking for?

Code: Select all

on mouseUp
  go to next card 
  add 10 to field "Score"  -- no need for "the" before field
end mouseUp

Code: Select all

put number of fld "score" of card "card2" into fld "score" of card "card3"
The "number" of the field is a special property and will not give you what you think it will.. Just refer to "the text" of a field and Rev will convert it to a number if it is a number..

Anything else, feel free to ask (your code is looking good, just a few little gotchas ;-) )

totalnoob
Posts: 20
Joined: Tue Jul 02, 2013 10:40 am

Re: Making quiz app score

Post by totalnoob » Wed Jul 03, 2013 9:44 am

thanks
but i dont know why its not working i allways must go to card script and click F5 it doesnt change immediately do you know why ?

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Making quiz app score

Post by shaosean » Wed Jul 03, 2013 11:22 am

If you want to arrange for a TeamViewer session, email me < support AT shaosean DOT tk > and I would be more than happy to check it out for you..

Post Reply