Problem with printing value captured by slider


Problem with printing value captured by slider

Author
Message
allthedecs
allthedecs
New Member
New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)

Group: Forum Members
Posts: 5, Visits: 8
I am writing a script where I need to capture a participant's response using a slider, and print it back to them in a subsequent trial, but I'm getting a peculiar issue.

The response is stored in a <values> item using the following command (it's actually first stored in another <values> item first and then transfered to values.selectedurn_bet, but I'm not sure if that's important here):
values.selectedurn_bet = format("%.2f", surveypage.known_urn_page.response/100)


and then printed to the screen using a <text> element:<text selectedbet_text>
/ items = ("For this urn, you bet $<%format(~"%.2f~", values.selectedurn_bet)%>")
/ size = (40%, 10%)
/ position = (50%, 72%)
/ hjustify = center
</text>

Everything works fine if the participant drags the slider to set their bet. However, if they use the default slider value (i.e. respond without actually clicking and dragging the slider to a different value), the number reported by the text element is 0.00:
For this urn, you bet $0.00

In case it helps I've attached the code here

Thanks in advance!
Attachments
urntask.iqx (31 views, 24.00 KB)
Dave
Dave
Supreme Being
Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)

Group: Administrators
Posts: 9K, Visits: 38K
allthedecs - Monday, August 13, 2018
I am writing a script where I need to capture a participant's response using a slider, and print it back to them in a subsequent trial, but I'm getting a peculiar issue.

The response is stored in a <values> item using the following command (it's actually first stored in another <values> item first and then transfered to values.selectedurn_bet, but I'm not sure if that's important here):
values.selectedurn_bet = format("%.2f", surveypage.known_urn_page.response/100)


and then printed to the screen using a <text> element:<text selectedbet_text>
/ items = ("For this urn, you bet $<%format(~"%.2f~", values.selectedurn_bet)%>")
/ size = (40%, 10%)
/ position = (50%, 72%)
/ hjustify = center
</text>

Everything works fine if the participant drags the slider to set their bet. However, if they use the default slider value (i.e. respond without actually clicking and dragging the slider to a different value), the number reported by the text element is 0.00:
For this urn, you bet $0.00

In case it helps I've attached the code here

Thanks in advance!

Don't use the format function here, just do

<surveypage known_practice_page>
/ stimulustimes = [0 = practice_known_pics, urncontents_label, practice_knownodds, quittext, practiceheader]
/ questions = [1 = slider.bet_slider]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (40%, 90%)
/ finishlabel = "Place bet"
/ navigationbuttonsize = (20%, 6%)
/ navigationbuttonfontstyle = ("Arial", 3.33%, false, false, false, false, 5, 1)
/ ontrialend = [values.practice_known60bet = slider.bet_slider.response/100]
</surveypage>


allthedecs
allthedecs
New Member
New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)

Group: Forum Members
Posts: 5, Visits: 8
I had originally inserted the format functions in those sections of the code as I was having the problem described in https://www.millisecond.com/forums/Topic25399.aspx and needed more rounded numbers to be saved for our purposes with the output

I can remove them there, however if possible I would still like the values to be printed rounded to exactly 2 decimal places as they represent dollars and cents. I've tried putting the format function in a range of other locations (e.g. in the <text> element, in an <expression>Wink but so long as it is somewhere in the path from the participant's slider response to the ultimate text element, the value is printed as 0.00 if the default slider response is used without clicking and dragging the slider


Dave
Dave
Supreme Being
Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)Supreme Being (467K reputation)

Group: Administrators
Posts: 9K, Visits: 38K
allthedecs - Tuesday, August 14, 2018
I had originally inserted the format functions in those sections of the code as I was having the problem described in https://www.millisecond.com/forums/Topic25399.aspx and needed more rounded numbers to be saved for our purposes with the output

I can remove them there, however if possible I would still like the values to be printed rounded to exactly 2 decimal places as they represent dollars and cents. I've tried putting the format function in a range of other locations (e.g. in the <text> element, in an <expression>Wink but so long as it is somewhere in the path from the participant's slider response to the ultimate text element, the value is printed as 0.00 if the default slider response is used without clicking and dragging the slider


I see. Best then to treat the default case separately:

<surveypage known_practice_page>
/ stimulustimes = [0 = practice_known_pics, urncontents_label, practice_knownodds, quittext, practiceheader]
/ questions = [1 = slider.bet_slider]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (40%, 90%)
/ finishlabel = "Place bet"
/ navigationbuttonsize = (20%, 6%)
/ navigationbuttonfontstyle = ("Arial", 3.33%, false, false, false, false, 5, 1)
/ ontrialend = [values.practice_known60bet = format("%.2f", slider.bet_slider.response/100)]
/ ontrialend = [
    if (slider.bet_slider.response == "500") values.practice_known60bet = "5.00";
]

</surveypage>

<surveypage unknown_practice_page>
/ stimulustimes = [0 = practice_unknown_pics, urncontents_label, practice_unknownodds, quittext, practiceheader]
/ questions = [1 = slider.bet_slider]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (40%, 90%)
/ finishlabel = "Place bet"
/ navigationbuttonsize = (20%, 6%)
/ navigationbuttonfontstyle = ("Arial", 3.33%, false, false, false, false, 5, 1)
/ ontrialend = [values.practice_unknown40bet = format("%.2f", slider.bet_slider.response/100)]
/ ontrialend = [
    if (slider.bet_slider.response == "500") values.practice_unknown40bet = "5.00";
]

</surveypage>

and

<surveypage known_urn_page>
/ stimulustimes = [0 = known_urn_pics, urncontents_label, knownodds, quittext, maintask_header]
/ questions = [1 = slider.bet_slider]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (40%, 90%)
/ finishlabel = "Place bet"
/ navigationbuttonsize = (20%, 6%)
/ navigationbuttonfontstyle = ("Arial", 3.33%, false, false, false, false, 5, 1)
/ ontrialend = [
    if (list.knownorderlist.nextvalue == 1) {values.known30bet = format("%.2f", slider.bet_slider.response/100)}
    if (list.knownorderlist.nextvalue == 2) {values.known40bet = format("%.2f", slider.bet_slider.response/100)}
    if (list.knownorderlist.nextvalue == 3) {values.known50bet = format("%.2f", slider.bet_slider.response/100)}
    if (list.knownorderlist.nextvalue == 4) {values.known60bet = format("%.2f", slider.bet_slider.response/100)}
    if (list.knownorderlist.nextvalue == 5) {values.known70bet = format("%.2f", slider.bet_slider.response/100)}
]
/ ontrialend = [
    if (list.knownorderlist.nextvalue == 1 && slider.bet_slider.response == "500") {values.known30bet = "5.00"}
    if (list.knownorderlist.nextvalue == 2 && slider.bet_slider.response == "500") {values.known40bet = "5.00"}
    if (list.knownorderlist.nextvalue == 3 && slider.bet_slider.response == "500") {values.known50bet = "5.00"}
    if (list.knownorderlist.nextvalue == 4 && slider.bet_slider.response == "500") {values.known60bet = "5.00"}
    if (list.knownorderlist.nextvalue == 5 && slider.bet_slider.response == "500") {values.known70bet = "5.00"}
]

</surveypage>

<surveypage unknown_urn_page>
/ stimulustimes = [0 = unknown_urn_pics, urncontents_label, unknownodds, quittext, maintask_header]
/ questions = [1 = slider.bet_slider]
/ showpagenumbers = false
/ showquestionnumbers = false
/ nextbuttonposition = (40%, 90%)
/ finishlabel = "Place bet"
/ navigationbuttonsize = (20%, 6%)
/ navigationbuttonfontstyle = ("Arial", 3.33%, false, false, false, false, 5, 1)
/ ontrialend = [
    if (list.unknownorderlist.nextvalue == 1) {values.unknown30bet = format("%.2f", surveypage.unknown_urn_page.response/100)}
    if (list.unknownorderlist.nextvalue == 2) {values.unknown40bet = format("%.2f", surveypage.unknown_urn_page.response/100)}
    if (list.unknownorderlist.nextvalue == 3) {values.unknown50bet = format("%.2f", surveypage.unknown_urn_page.response/100)}
    if (list.unknownorderlist.nextvalue == 4) {values.unknown60bet = format("%.2f", surveypage.unknown_urn_page.response/100)}
    if (list.unknownorderlist.nextvalue == 5) {values.unknown70bet = format("%.2f", surveypage.unknown_urn_page.response/100)}
]
/ ontrialend = [
    if (list.unknownorderlist.nextvalue == 1 && slider.bet_slider.response == "500") {values.unknown30bet = "5.00"}
    if (list.unknownorderlist.nextvalue == 2 && slider.bet_slider.response == "500") {values.unknown40bet = "5.00"}
    if (list.unknownorderlist.nextvalue == 3 && slider.bet_slider.response == "500") {values.unknown50bet = "5.00"}
    if (list.unknownorderlist.nextvalue == 4 && slider.bet_slider.response == "500") {values.unknown60bet = "5.00"}
    if (list.unknownorderlist.nextvalue == 5 && slider.bet_slider.response == "500") {values.unknown70bet = "5.00"}
]

</surveypage>

allthedecs
allthedecs
New Member
New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)New Member (34 reputation)

Group: Forum Members
Posts: 5, Visits: 8
Will do, thanks for all the help!
GO


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....






Millisecond Forums


Search