Hi saratogacoach,
Depending on what you're doing, you are often best off using just ONE card, and simply looping through the questions or instructions. Granted, you may want to use separate stacks for the quiz versus the tutorial, but even those can often be merged into a single card each! Let's say you have a survey with 50 questions. Just for fun, I'll also assume that you have a different graphic associated with each question, and you want that to appear on the card too. First, put your questions into a global variable called myQuestions in the stack script, like this:
Code: Select all
put "This is the first question" & CR after myQuestions
put "This is the second question" & CR after myQuestions
etc.
Then on the card, let's say you had a rating scale in the form of 5 regular button, named 1,2,3,4, and 5 (and then you could put verbal anchors (e.g., "strongly agree") in a text box underneath the button if you wanted. After naming the buttons, you would simply put identical code inside each button (although see my note about Rev 3.5 and "behaviors" below). The code would look like this:
Code: Select all
on mouseUp
put the name of me & comma after gResponse
add 1 to i
If i > 50, [b]then
go card "Done!"
else
put line i of myQuestions into field "Question"
end if
end mouseUp
Line 1: I assume you've named your buttons 1,2,3,4 corresponding to your scale. They could also be named "Yes" "No" "Maybe" etc. Depends on what you're doing with the data. "Put...& comma...after" appends each response (i.e., the name of the button clicked) so that responses to all 50 questions are stored (separated by a comma) in a single variable called "gResponse". This variable needs to be global to hold the values for the entire experiment. You can always access the response to the xth question later by calling "item x of gResponse" You can also separate responses by CR (carriage return) and tab.
Line 2: This is your standard counter. Your counter variable "i" must be global so that it keeps its value until the next iteration.
Line 3: If you have 50 survey items, then this will kick you out of the loop (onto a second card called "Done!") when participant has answered them all.
Line 4: If the participant hasn't finished all 50 items, then this will display the next question in the survey. Note that you could have multiple lines that also displayed graphics and pictures associated with the question. If you have images stored and named neatly in a folder (e.g., pic1.jpg, pic2.jpg, etc.) you could simply use these two lines to display the picture associated with the text at the same time:
Code: Select all
put "c:\mypictures\pic" & i & ".jpg" into piclocation
set the filename of image "myImage" to piclocation
On question #1, it will display pic1.jpg in the container called "myImage" that is on your card. Finally, let's say you have three different types of questions you ask in the survey. You could make each question into a group, put them ALL onto the card (on top of each other), but only display the one that is relevant, perhaps by using a switch statement
Code: Select all
switch i
case 1
set the visible of group "True/False" to true
set the visible of group "rating scale" to false
set the visible of group "open ended" to false
break
case 10
case 15
case 40
set the visible of group "True/False" to false
set the visible of group "rating scale" to true
set the visible of group "open ended" to false
break
default
set the visible of group "True/False" to false
set the visible of group "rating scale" to true
set the visible of group "open ended" to false
break
end switch
end mouseUp
In this example, the first of your 50 questions (the case where i = 1) will display the true/false option, questions# 10,15, and 40 will display the rating scale, and all the other items will display the open ended question.
This whole approach uses just one card (well, maybe three counting the "Done!" card, and a "splash" card). And even though it seems like more work, is usually easier in the long run, because if you have problems, the code is all in one location, and thus easier to fix. (NOTE: In Revolution 3.5 you could put the code in just one button make it a "behavior", and then have the other buttons just call that code. That way if you change the code, you only have to change it once and all the other buttons will reflect the change.
Oh, almost forgot, to store the response of radiobuttons instead of regular buttons like I assumed above, you'd first set them so none of them are selected. Right when you make them visible, do this too:
Code: Select all
set the hilitedButton of group "radiobutton" to zero
When using radio buttons, I tend to use a separate continue button. The continue button would have the same code as I used above (i.e, add 1 to i, If i > 50... etc.) but instead of this line:
Code: Select all
put the name of me & comma after gResponse
You'd modify a bit to say this:
Code: Select all
on mouseUp
global gResponse
If the hilitedButton of group "radiobutton" = zero then
answer "Oops! You forgot to answer"
else
put the hilitedbuttonname of group "radiobutton" & comma after gResponse
end if
end mouseUp
Finally, to get total score you could write your own handler (essentially a subroutine that you'd call) that said something like this:
Code: Select all
on CalculateTotal
repeat for each item x in gResponse
add x to myTotal
end repeat
answer "You have a total score of" && x
end CalculateTotal
myTotal should be global if you wish to use it outside of this handler.
I was just working on a project yesterday to do all this, so the timing was perfect. Hope it actually helps. If others think I've offered bad advice, please chime in. I'm still relatively new at this myself!
BTW, I'm curious what program you used to originally code this?
- Good Luck!
Mark P.