0 votes

Let's say I have a list of 15 questions which I want to show to a participant one at a time. However, before each question I want to ask the participant if he'd like to answer another question from that set or if they'd like to exit the study. If the participant indicates they'd like to answer a question, one question should be randomly taken from the list and shown to the participant. This loop should continue until the participant has exhausted the questions available or until the participant says indicates he'd like to leave the study.

So, for example, a participant would be asked the following

*question: Would you like to answer one more question?
	Yes, show me one question
	No, I'd like to end the study
	*save: question_decision

If Yes --> Pull a question from a list of questions and add one to counter. If No --> Exit Study.

I imagine this has to be done with a collection and goto and label statements which loop until the value of question_decision is "No." However, I couldn't figure out how to randomly pull a question and its associated answer choices for the purpose of this task. Any thoughts?

by (280 points)

1 Answer

+1 vote
Best answer

Hey there,

Great question!
If your questions are of one type, then something like this could work well. Does this fit the case you have in mind?

>> questions = ["First question", "Second question", "Third question", "Fourth question", "Fifth question"]
--randomizes questions
>> questionsRandom = questions
>> questionsRandom.shuffle

>> answers = {}

>> i = 1
*while: (not break) and (i <= questionsRandom.size)
	>> question = questionsRandom[i]
	*question: {question}
		*save: answer
	>> answers[question] = answer
	>> i = i + 1
	*if: i <= questionsRandom.size
		*question: Would you like to answer one more question?
			Yes, show me one question
			No, I'd like to end the study
				>> break = "Yes"
by (5.8k points)
selected by

This works perfectly! Thanks Olga. Just a follow-up question. It seems like this line: >> answers[question] = answer stores all the answers in a collection in the resulting .csv.

Is there a natural way on guidedtrack to unpack that collection into multiple columns in the .csv where the keys are column names and the values are the cell values?

To be clear, right now the output is of the form {"question":"answer","question_2":"answer_2"}. It would be nice if there was some way within GT to make it to where every key in that dictionary is a column header, and every value is the cell value.


You can map the answers to the questions that the user saw to separate variables so that you don't have to manipulate the csv file:

*if: (answers["First question"])	
	>>firstAnswer = answers["First question"]

With the *if statement you are checking if the user answered to that question, and if they did, you asign the value to a variable. You would the do the same for all the other questions.

Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
104 questions
112 answers
168 users