Reading number of correct responses in surveypage within the script?


Author
Message
AKrishna
AKrishna
Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)
Group: Forum Members
Posts: 118, Visits: 396
Hi all,

I just came across an issue in a script I'm working on that would be most elegantly solved by reading how many radiobutton questions were responded to correctly within a surveypage in order to calculate a reward for participants. For example, on the following surveypage, participants are supposed to get £0.05 per correct radiobutton response:

<values>
/CorrectAdvancedContentQuestions  = ""
</values>

<surveypage AttentionQuestions1>
/ questions = [1-3 = noreplace(BurntCity1, BurntCity2, BurntCity3)]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (50%,90%)
/ ontrialend = [values.CorrectAdvancedContentQuestions += surveypage.AttentionQuestions1.correctcount]
</surveypage>

<radiobuttons BurntCity1>
/ caption = "What was the cause of the city's initial prosperity?"
/ options = ("Its river's waters caused crops and animals to grow well", "Its inhabitants were highly skilled traders", "Kish had blessed the city with gold and jewels", "Its inhabitants robbed travelers")
/ correctresponse = ("Its river's waters caused crops and animals to grow well")
/ validresponse = ("Its river's waters caused crops and animals to grow well", "Its inhabitants were highly skilled traders", "Kish had blessed the city with gold and jewels", "Its inhabitants robbed travelers")
/ order = random
</radiobuttons>

<radiobuttons BurntCity2>
/ caption = "Why did Kish summon the fire spirit?"
/ options = ("She was angry because the people did not honor her any longer", "The inhabitants were freezing and needed warmth", "To punish the fire spirit for hurting the inhabitants", "To collect the offerings the people had brought to her")
/ correctresponse = ("She was angry because the people did not honor her any longer")
/ validresponse = ("She was angry because the people did not honor her any longer", "The inhabitants were freezing and needed warmth", "To punish the fire spirit for hurting the inhabitants", "To collect the offerings the people had brought to her")
/ order = random
</radiobuttons>

<radiobuttons BurntCity3>
/ caption = "What happened to the people of the city in the end?"
/ options = ("Many of them were burned to death and the rest were maimed", "They all joined together in rebuilding their city with Kish's help", "They united to fight the evil fire spirit", "They sailed away across their river")
/ correctresponse = ("Many of them were burned to death and the rest were maimed")
/ validresponse = ("Many of them were burned to death and the rest were maimed", "They all joined together in rebuilding their city with Kish's help", "They united to fight the evil fire spirit", "They sailed away across their river")
/ order = random
</radiobuttons>

My /ontrialend is an attempt to set that up (I would do the actual reward calculation in an expression later on, so I can set the reward dynamically for future task versions), but it seems as though all the attributes for the surveypage element that I could use (correct, totalcorrect, correctcount) apply to the page in its entirety (i.e. =0 if any question on the page is wrong, =1 if all questions are correct). The radiobuttons element doesn't have a correct attribute for me to reference. Is there any way to do this?

My current workaround is to use conditional logic based on the answers to each individual question, à la:

if (radiobuttons.BurntCity1.response == "Its river's waters caused crops and animals to grow well") values.CorrectAdvancedContentQuestions += 1

, but this seems very clunky for multiple survey pages with different questions.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
AKrishna - Monday, June 18, 2018
Hi all,

I just came across an issue in a script I'm working on that would be most elegantly solved by reading how many radiobutton questions were responded to correctly within a surveypage in order to calculate a reward for participants. For example, on the following surveypage, participants are supposed to get £0.05 per correct radiobutton response:

<values>
/CorrectAdvancedContentQuestions  = ""
</values>

<surveypage AttentionQuestions1>
/ questions = [1-3 = noreplace(BurntCity1, BurntCity2, BurntCity3)]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (50%,90%)
/ ontrialend = [values.CorrectAdvancedContentQuestions += surveypage.AttentionQuestions1.correctcount]
</surveypage>

<radiobuttons BurntCity1>
/ caption = "What was the cause of the city's initial prosperity?"
/ options = ("Its river's waters caused crops and animals to grow well", "Its inhabitants were highly skilled traders", "Kish had blessed the city with gold and jewels", "Its inhabitants robbed travelers")
/ correctresponse = ("Its river's waters caused crops and animals to grow well")
/ validresponse = ("Its river's waters caused crops and animals to grow well", "Its inhabitants were highly skilled traders", "Kish had blessed the city with gold and jewels", "Its inhabitants robbed travelers")
/ order = random
</radiobuttons>

<radiobuttons BurntCity2>
/ caption = "Why did Kish summon the fire spirit?"
/ options = ("She was angry because the people did not honor her any longer", "The inhabitants were freezing and needed warmth", "To punish the fire spirit for hurting the inhabitants", "To collect the offerings the people had brought to her")
/ correctresponse = ("She was angry because the people did not honor her any longer")
/ validresponse = ("She was angry because the people did not honor her any longer", "The inhabitants were freezing and needed warmth", "To punish the fire spirit for hurting the inhabitants", "To collect the offerings the people had brought to her")
/ order = random
</radiobuttons>

<radiobuttons BurntCity3>
/ caption = "What happened to the people of the city in the end?"
/ options = ("Many of them were burned to death and the rest were maimed", "They all joined together in rebuilding their city with Kish's help", "They united to fight the evil fire spirit", "They sailed away across their river")
/ correctresponse = ("Many of them were burned to death and the rest were maimed")
/ validresponse = ("Many of them were burned to death and the rest were maimed", "They all joined together in rebuilding their city with Kish's help", "They united to fight the evil fire spirit", "They sailed away across their river")
/ order = random
</radiobuttons>

My /ontrialend is an attempt to set that up (I would do the actual reward calculation in an expression later on, so I can set the reward dynamically for future task versions), but it seems as though all the attributes for the surveypage element that I could use (correct, totalcorrect, correctcount) apply to the page in its entirety (i.e. =0 if any question on the page is wrong, =1 if all questions are correct). The radiobuttons element doesn't have a correct attribute for me to reference. Is there any way to do this?

My current workaround is to use conditional logic based on the answers to each individual question, à la:

if (radiobuttons.BurntCity1.response == "Its river's waters caused crops and animals to grow well") values.CorrectAdvancedContentQuestions += 1

, but this seems very clunky for multiple survey pages with different questions.

The only way I can think of is to define /optionvalues in all your <radiobuttons> elements like so

<radiobuttons BurntCity1>
/ caption = "What was the cause of the city's initial prosperity?"
/ options = ("Its river's waters caused crops and animals to grow well",
"Its inhabitants were highly skilled traders",
"Kish had blessed the city with gold and jewels",
"Its inhabitants robbed travelers")
/ optionvalues = ("1", "2", "3", "4")
/ order = random
</radiobuttons>

and then simply use conditional logic as before, which then simplifies to

if (radiobuttons.BurntCity1.response == "1") values.CorrectAdvancedContentQuestions += 1 ...

AKrishna
AKrishna
Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)
Group: Forum Members
Posts: 118, Visits: 396
Dave - Monday, June 18, 2018
AKrishna - Monday, June 18, 2018
Hi all,

I just came across an issue in a script I'm working on that would be most elegantly solved by reading how many radiobutton questions were responded to correctly within a surveypage in order to calculate a reward for participants. For example, on the following surveypage, participants are supposed to get £0.05 per correct radiobutton response:

<values>
/CorrectAdvancedContentQuestions  = ""
</values>

<surveypage AttentionQuestions1>
/ questions = [1-3 = noreplace(BurntCity1, BurntCity2, BurntCity3)]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (50%,90%)
/ ontrialend = [values.CorrectAdvancedContentQuestions += surveypage.AttentionQuestions1.correctcount]
</surveypage>

<radiobuttons BurntCity1>
/ caption = "What was the cause of the city's initial prosperity?"
/ options = ("Its river's waters caused crops and animals to grow well", "Its inhabitants were highly skilled traders", "Kish had blessed the city with gold and jewels", "Its inhabitants robbed travelers")
/ correctresponse = ("Its river's waters caused crops and animals to grow well")
/ validresponse = ("Its river's waters caused crops and animals to grow well", "Its inhabitants were highly skilled traders", "Kish had blessed the city with gold and jewels", "Its inhabitants robbed travelers")
/ order = random
</radiobuttons>

<radiobuttons BurntCity2>
/ caption = "Why did Kish summon the fire spirit?"
/ options = ("She was angry because the people did not honor her any longer", "The inhabitants were freezing and needed warmth", "To punish the fire spirit for hurting the inhabitants", "To collect the offerings the people had brought to her")
/ correctresponse = ("She was angry because the people did not honor her any longer")
/ validresponse = ("She was angry because the people did not honor her any longer", "The inhabitants were freezing and needed warmth", "To punish the fire spirit for hurting the inhabitants", "To collect the offerings the people had brought to her")
/ order = random
</radiobuttons>

<radiobuttons BurntCity3>
/ caption = "What happened to the people of the city in the end?"
/ options = ("Many of them were burned to death and the rest were maimed", "They all joined together in rebuilding their city with Kish's help", "They united to fight the evil fire spirit", "They sailed away across their river")
/ correctresponse = ("Many of them were burned to death and the rest were maimed")
/ validresponse = ("Many of them were burned to death and the rest were maimed", "They all joined together in rebuilding their city with Kish's help", "They united to fight the evil fire spirit", "They sailed away across their river")
/ order = random
</radiobuttons>

My /ontrialend is an attempt to set that up (I would do the actual reward calculation in an expression later on, so I can set the reward dynamically for future task versions), but it seems as though all the attributes for the surveypage element that I could use (correct, totalcorrect, correctcount) apply to the page in its entirety (i.e. =0 if any question on the page is wrong, =1 if all questions are correct). The radiobuttons element doesn't have a correct attribute for me to reference. Is there any way to do this?

My current workaround is to use conditional logic based on the answers to each individual question, à la:

if (radiobuttons.BurntCity1.response == "Its river's waters caused crops and animals to grow well") values.CorrectAdvancedContentQuestions += 1

, but this seems very clunky for multiple survey pages with different questions.

The only way I can think of is to define /optionvalues in all your <radiobuttons> elements like so

<radiobuttons BurntCity1>
/ caption = "What was the cause of the city's initial prosperity?"
/ options = ("Its river's waters caused crops and animals to grow well",
"Its inhabitants were highly skilled traders",
"Kish had blessed the city with gold and jewels",
"Its inhabitants robbed travelers")
/ optionvalues = ("1", "2", "3", "4")
/ order = random
</radiobuttons>

and then simply use conditional logic as before, which then simplifies to

if (radiobuttons.BurntCity1.response == "1") values.CorrectAdvancedContentQuestions += 1 ...

Hm. Still a little clunky, but perfectly serviceable, certainly if there's no way to access radiobuttons.correct - that's just my inner OCD amateur programmer complaining! ;)

Thanks for your input, Dave.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
AKrishna - Tuesday, June 19, 2018
Dave - Monday, June 18, 2018
AKrishna - Monday, June 18, 2018
Hi all,

I just came across an issue in a script I'm working on that would be most elegantly solved by reading how many radiobutton questions were responded to correctly within a surveypage in order to calculate a reward for participants. For example, on the following surveypage, participants are supposed to get £0.05 per correct radiobutton response:

<values>
/CorrectAdvancedContentQuestions  = ""
</values>

<surveypage AttentionQuestions1>
/ questions = [1-3 = noreplace(BurntCity1, BurntCity2, BurntCity3)]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (50%,90%)
/ ontrialend = [values.CorrectAdvancedContentQuestions += surveypage.AttentionQuestions1.correctcount]
</surveypage>

<radiobuttons BurntCity1>
/ caption = "What was the cause of the city's initial prosperity?"
/ options = ("Its river's waters caused crops and animals to grow well", "Its inhabitants were highly skilled traders", "Kish had blessed the city with gold and jewels", "Its inhabitants robbed travelers")
/ correctresponse = ("Its river's waters caused crops and animals to grow well")
/ validresponse = ("Its river's waters caused crops and animals to grow well", "Its inhabitants were highly skilled traders", "Kish had blessed the city with gold and jewels", "Its inhabitants robbed travelers")
/ order = random
</radiobuttons>

<radiobuttons BurntCity2>
/ caption = "Why did Kish summon the fire spirit?"
/ options = ("She was angry because the people did not honor her any longer", "The inhabitants were freezing and needed warmth", "To punish the fire spirit for hurting the inhabitants", "To collect the offerings the people had brought to her")
/ correctresponse = ("She was angry because the people did not honor her any longer")
/ validresponse = ("She was angry because the people did not honor her any longer", "The inhabitants were freezing and needed warmth", "To punish the fire spirit for hurting the inhabitants", "To collect the offerings the people had brought to her")
/ order = random
</radiobuttons>

<radiobuttons BurntCity3>
/ caption = "What happened to the people of the city in the end?"
/ options = ("Many of them were burned to death and the rest were maimed", "They all joined together in rebuilding their city with Kish's help", "They united to fight the evil fire spirit", "They sailed away across their river")
/ correctresponse = ("Many of them were burned to death and the rest were maimed")
/ validresponse = ("Many of them were burned to death and the rest were maimed", "They all joined together in rebuilding their city with Kish's help", "They united to fight the evil fire spirit", "They sailed away across their river")
/ order = random
</radiobuttons>

My /ontrialend is an attempt to set that up (I would do the actual reward calculation in an expression later on, so I can set the reward dynamically for future task versions), but it seems as though all the attributes for the surveypage element that I could use (correct, totalcorrect, correctcount) apply to the page in its entirety (i.e. =0 if any question on the page is wrong, =1 if all questions are correct). The radiobuttons element doesn't have a correct attribute for me to reference. Is there any way to do this?

My current workaround is to use conditional logic based on the answers to each individual question, à la:

if (radiobuttons.BurntCity1.response == "Its river's waters caused crops and animals to grow well") values.CorrectAdvancedContentQuestions += 1

, but this seems very clunky for multiple survey pages with different questions.

The only way I can think of is to define /optionvalues in all your <radiobuttons> elements like so

<radiobuttons BurntCity1>
/ caption = "What was the cause of the city's initial prosperity?"
/ options = ("Its river's waters caused crops and animals to grow well",
"Its inhabitants were highly skilled traders",
"Kish had blessed the city with gold and jewels",
"Its inhabitants robbed travelers")
/ optionvalues = ("1", "2", "3", "4")
/ order = random
</radiobuttons>

and then simply use conditional logic as before, which then simplifies to

if (radiobuttons.BurntCity1.response == "1") values.CorrectAdvancedContentQuestions += 1 ...

Hm. Still a little clunky, but perfectly serviceable, certainly if there's no way to access radiobuttons.correct - that's just my inner OCD amateur programmer complaining! ;)

Thanks for your input, Dave.

That is true -- <radiobuttons> do not have a correct property, i.e. there is nothing that could be accessed.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search