Help using if-else /onTrialEnd


Author
Message
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: 108K
EN - 7/12/2025
Hello
why is the if-else below returning values.att_check1 equal 0, even when _all_ conditions in parentheses are met?
I'm probably missing something very obvious here, please, help!

if (radiobuttons.att_check1_1==0 && radioButtons.att_check1_2==2 && radioButtons.att_check1_3==0) {
   values.att_check1 = 1;
  } else {
   values.att_check1 = 0;
  }

Below is the entire IQX for the record.
EN
---


//<defaults>
///fontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
///canvassize = (95%,95%)
///halign = center
//</defaults>


// Comment out
<values>
/att_check1 = -1
/att_check2 = -1
</values>

// Data to summarized for each subject
<summarydata>
/columns = (values.att_check1, radioButtons.att_check1_1.response, radioButtons.att_check1_2.response, radioButtons.att_check1_3.response,
            values.att_check2, radioButtons.att_check2_1.response, radioButtons.att_check2_2.response, radioButtons.att_check2_3.response
            )
</summarydata>
//
// Gratitude - Attention Check1
//

<survey attent_check1>
/pages = [1=att_check1]
</survey>

<surveypage att_check1>
/caption = "<b><u>先ほどご覧いただいた動画について、お答えください。</u></b>"
/questions = [1-3=noreplace(att_check1_1, att_check1_2, att_check1_3)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 1.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ finishlabel = "次へ"
/ nextlabel = "次へ"
/ onTrialEnd = [
    if (radiobuttons.att_check1_1==0 && radioButtons.att_check1_2==2 && radioButtons.att_check1_3==0) {
        values.att_check1 = 1;
    } else {
        values.att_check1 = 0;
    }
]
</surveypage>

<radiobuttons att_check1_1>
// correct response is 0
/ caption="<b>動画の舞台はどこでしたか? </b>"
/ options=("病院の食堂", "建物の外", "寝室")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

<radiobuttons att_check1_2>
// correcto response is 2
/ caption="<b>動画に登場した主な登場人物は誰でしたか? </b>"
/ options=("女性二人", "男性一人と女性一人", "男性二人")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

<radiobuttons att_check1_3>
// correct response is 0
/ caption="<b>動画ではどのような出来事が起こりましたか? </b>"
/ options=("男性が職場の人たちから<br>思いがけないお金を受け取った", "男性が亡くなった妻を<br>悼んでいた", "男性が木製のカウンタートップの<br>作り方を説明していた")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

///
///
/// END - Attention Check1
///


//
// Neutral - Attention Check2
//

<survey attent_check2>
/pages = [1=att_check2]
</survey>

<surveypage att_check2>
/caption = "<b><u>先ほどご覧いただいた動画について、お答えください。</u></b>"
/questions = [1-3=noreplace(att_check2_1, att_check2_2, att_check2_3)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 1.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ finishlabel = "次へ"
/ nextlabel = "次へ"
/ onTrialEnd = [
    if (radiobuttons.att_check2_1==0 && radioButtons.att_check2_2==1 && radioButtons.att_check2_3==2) {
        values.att_check2 = 1;
    } else {
        values.att_check2 = 0;
    }
]
</surveypage>

<radiobuttons att_check2_1>
// correct response is 0
/ caption="<b>動画の舞台はどこでしたか? </b>"
/ options=("建物の中", "建物の外", "さまざまな場所")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

<radiobuttons att_check2_2>
// correct response is 1
/ caption="<b>動画の主な登場人物は誰でしたか? </b>"
/ options=("男性一人", "男性一人と女性一人", "男性二人")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

<radiobuttons att_check2_3>
//correct response is 2
/ caption="<b>動画の中で何が起きましたか? </b>"
/ options=("女性が同僚から思いがけず<br>お金を受け取った", "男性が激しい<br>口論になった", "二人が一緒に<br>家具を組み立てた")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

///
///
/// END - Attention Check1
///

Because radiobuttons.name does not return anything, much less the response given. If you want to check the response, then you need to check the response property.

https://www.millisecond.com/support/docs/v6/html/language/properties/response.htm


EN
EN
Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)Associate Member (188 reputation)
Group: Forum Members
Posts: 45, Visits: 224
Hello
why is the if-else below returning values.att_check1 equal 0, even when _all_ conditions in parentheses are met?
I'm probably missing something very obvious here, please, help!

if (radiobuttons.att_check1_1==0 && radioButtons.att_check1_2==2 && radioButtons.att_check1_3==0) {
   values.att_check1 = 1;
  } else {
   values.att_check1 = 0;
  }

Below is the entire IQX for the record.
EN
---


//<defaults>
///fontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
///canvassize = (95%,95%)
///halign = center
//</defaults>


// Comment out
<values>
/att_check1 = -1
/att_check2 = -1
</values>

// Data to summarized for each subject
<summarydata>
/columns = (values.att_check1, radioButtons.att_check1_1.response, radioButtons.att_check1_2.response, radioButtons.att_check1_3.response,
            values.att_check2, radioButtons.att_check2_1.response, radioButtons.att_check2_2.response, radioButtons.att_check2_3.response
            )
</summarydata>
//
// Gratitude - Attention Check1
//

<survey attent_check1>
/pages = [1=att_check1]
</survey>

<surveypage att_check1>
/caption = "<b><u>先ほどご覧いただいた動画について、お答えください。</u></b>"
/questions = [1-3=noreplace(att_check1_1, att_check1_2, att_check1_3)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 1.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ finishlabel = "次へ"
/ nextlabel = "次へ"
/ onTrialEnd = [
    if (radiobuttons.att_check1_1==0 && radioButtons.att_check1_2==2 && radioButtons.att_check1_3==0) {
        values.att_check1 = 1;
    } else {
        values.att_check1 = 0;
    }
]
</surveypage>

<radiobuttons att_check1_1>
// correct response is 0
/ caption="<b>動画の舞台はどこでしたか? </b>"
/ options=("病院の食堂", "建物の外", "寝室")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

<radiobuttons att_check1_2>
// correcto response is 2
/ caption="<b>動画に登場した主な登場人物は誰でしたか? </b>"
/ options=("女性二人", "男性一人と女性一人", "男性二人")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

<radiobuttons att_check1_3>
// correct response is 0
/ caption="<b>動画ではどのような出来事が起こりましたか? </b>"
/ options=("男性が職場の人たちから<br>思いがけないお金を受け取った", "男性が亡くなった妻を<br>悼んでいた", "男性が木製のカウンタートップの<br>作り方を説明していた")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

///
///
/// END - Attention Check1
///


//
// Neutral - Attention Check2
//

<survey attent_check2>
/pages = [1=att_check2]
</survey>

<surveypage att_check2>
/caption = "<b><u>先ほどご覧いただいた動画について、お答えください。</u></b>"
/questions = [1-3=noreplace(att_check2_1, att_check2_2, att_check2_3)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 1.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ finishlabel = "次へ"
/ nextlabel = "次へ"
/ onTrialEnd = [
    if (radiobuttons.att_check2_1==0 && radioButtons.att_check2_2==1 && radioButtons.att_check2_3==2) {
        values.att_check2 = 1;
    } else {
        values.att_check2 = 0;
    }
]
</surveypage>

<radiobuttons att_check2_1>
// correct response is 0
/ caption="<b>動画の舞台はどこでしたか? </b>"
/ options=("建物の中", "建物の外", "さまざまな場所")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

<radiobuttons att_check2_2>
// correct response is 1
/ caption="<b>動画の主な登場人物は誰でしたか? </b>"
/ options=("男性一人", "男性一人と女性一人", "男性二人")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

<radiobuttons att_check2_3>
//correct response is 2
/ caption="<b>動画の中で何が起きましたか? </b>"
/ options=("女性が同僚から思いがけず<br>お金を受け取った", "男性が激しい<br>口論になった", "二人が一緒に<br>家具を組み立てた")
/ optionvalues = ("0", "1", "2")
/ required = true
/ orientation = horizontalequal
/ order = random
</radiobuttons>

///
///
/// END - Attention Check1
///
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search