EN
|
|
Group: Forum Members
Posts: 42,
Visits: 211
|
Hello:
I wanted to provide feedback to participants immediately after a <trial> that has a /branch section within it. The /branch will--depending on the participant's response--call a <surveypage> using 'return' (I copied the current code below in case it's helpful -- the <trial> in case is BoxClick_Trial).
To display the feedback after each <trial>, I thought about using additional 'return' commands inside the /onTrialEnd section. The idea was to use 'return' to call another <trial> (after updating some global variables) whose only job is to display a customized message on the screen. However, using 'return' inside the /onTrialEnd section does not seem to be allowed.
After some fiddling, I decided to move portions of the code that were originally inside /onTrialEnd to inside the /branch, right after the conditional call to <surveypage>. However, and somehow expectedly in hindsight, because the flow of the program returns directly to /onTrialEnd after it is deviated by the /branch, I still have not found a way to display the feedback if the <surveypage> is called (if <surveypage> is _not called_, feedbacks are properly displayed by the code following the 'return' command in the /branch).
I guess this is a fairly common case but I wonder what would be the best way to handle it? Any help would be greatly appreciated! With very best wishes, EN -- // Global variables -- some of these variables should be re-defined in emot_induction.iqx
<values> //Thresholds specified by the procedure defined in calibration_time_boxcount.iqx // Here defined only for testing purposes / easyThresh50 = 8 //The number of boxes at the 50% level / mediumThresh65 = 10 //The number of boxes at the 65% level / mediumThresh80 = 13 //The number of boxes at the 80% level / hardThresh95 = 15 //The number of boxes at the 95% level
// From here -- may have to be specified globally to be used in other places // Total number of boxes clicked in box_clicking / box_clicking_boxesChecked = -1 / YOU_reward = 0 / OTHER_reward = 0 / choice_made = 0 / choice_not_made = 0 / obtained_reward = 0
// From here -- specific to social_effort_box_click_task.iqx //Color of trial type -- in fact, red (YOU) or blue (OTHER) / c_colorname = black //Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward / eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST
// Position of the two choices / effortX = 0% / restX = 0%
// Trial type / trialType = null
// Strings to be displayed at every trial / centerLabel = null // will be either YOU or OTHER / effortCredits = 0 / effortBoxes = 0
</values>
<parameters> // //These are the rewards (fixed for all participants) / low_pay = 2 //Low reward / medium_pay = 6 //Medium reward / high_pay = 10 //High reward
/ num_trials = 24 // total number of trials </parameters>
// data to be saved in summary file -- CONSIDER ADDING ITEMS in the future <summarydata> /columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.YOU_reward, values.OTHER_reward, values.choice_made, values.choice_not_made) </summarydata>
// data to be saved in raw data file <data> /columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode, pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked, values.effortBoxes, values.effortCredits, values.obtained_reward, values.effortX) </data>
// These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring! <checkboxes row1> / caption=" " / options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") / optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10") / required = true / orientation = horizontalequal </checkboxes>
<checkboxes row2> / caption=" " / options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20") / optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20") / required = true / orientation = horizontalequal </checkboxes>
<checkboxes row3> / caption=" " / options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30") / optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30") / required = true / orientation = horizontalequal </checkboxes>
<checkboxes row4> / caption=" " / options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40") / optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40") / required = true / orientation = horizontalequal </checkboxes>
<checkboxes row5> / caption=" " / options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50") / optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50") / required = true / orientation = horizontalequal </checkboxes>
<surveypage box_clicking> / onTrialBegin = [ values.box_clicking_boxesChecked = -1 ] / onTrialEnd = [ values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount; ] /caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes" /questions = [1-5=sequence(row1, row2, row3, row4, row5)] / itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1) / itemspacing = 0.0% / showpagenumbers = false / showbackbutton = false / showquestionnumbers = false / responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1) / timeout = 10000 // 10 seconds / showNextButton = false </surveypage>
<block SocialEffort_Block> / onBlockBegin = [ // Randomized trial type order -- 24 trials list.trialTypeList.appendItem(list.trialType.nextValue); //1 list.trialTypeList.appendItem(list.trialType.nextValue); //2 list.trialTypeList.appendItem(list.trialType.nextValue); //3 list.trialTypeList.appendItem(list.trialType.nextValue); //4 list.trialTypeList.appendItem(list.trialType.nextValue); //5 list.trialTypeList.appendItem(list.trialType.nextValue); //6 list.trialTypeList.appendItem(list.trialType.nextValue); //7 list.trialTypeList.appendItem(list.trialType.nextValue); //8 list.trialTypeList.appendItem(list.trialType.nextValue); //9 list.trialTypeList.appendItem(list.trialType.nextValue); //10 list.trialTypeList.appendItem(list.trialType.nextValue); //11 list.trialTypeList.appendItem(list.trialType.nextValue); //12 list.trialTypeList.appendItem(list.trialType.nextValue); //13 list.trialTypeList.appendItem(list.trialType.nextValue); //14 list.trialTypeList.appendItem(list.trialType.nextValue); //15 list.trialTypeList.appendItem(list.trialType.nextValue); //16 list.trialTypeList.appendItem(list.trialType.nextValue); //17 list.trialTypeList.appendItem(list.trialType.nextValue); //18 list.trialTypeList.appendItem(list.trialType.nextValue); //19 list.trialTypeList.appendItem(list.trialType.nextValue); //20 list.trialTypeList.appendItem(list.trialType.nextValue); //21 list.trialTypeList.appendItem(list.trialType.nextValue); //22 list.trialTypeList.appendItem(list.trialType.nextValue); //23 list.trialTypeList.appendItem(list.trialType.nextValue); //24 // Randomized YOU effort-reward 12 pairs list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12 // Randomized OTHER effort-reward 12 pairs list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12 ] // trials = [1-parameters.num_trials = BoxClick_Trial] / trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually....
// trials = [1-24 = Full_Trial] // ATTENTION: defining the number of trials manually....
</block>
<trial BoxClick_Trial> / onTrialBegin = [ // pick random postion for effort_option values.effortX = list.x.nextValue; // pick position for rest_option values.restX = list.x.nextValue; // set trial type values.trialType = list.trialTypeList.nextValue; // set center label according to trial type if (values.trialType == "YOU") { values.c_colorname = red; values.eff_rew = list.YOU_eff_rewList.nextValue; } else { // OTHER values.c_colorname = blue; values.eff_rew = list.OTHER_eff_rewList.nextValue; } // set winnings and effort according to the value in eff_rew if (values.eff_rew == "e1_r1") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e1_r2") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e1_r3") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e2_r1") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e2_r2") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e2_r3") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e3_r1") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e3_r2") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e3_r3") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e4_r1") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e4_r2") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e4_r3") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.high_pay; } // Reset the variable box_clicking_boxesChecked values.box_clicking_boxesChecked = -1; ] / stimulusframes = [1=effort_option, rest_option, center_label] / inputdevice = mouse / validresponse = (effort_option, rest_option) / timeout = 4000 // participant must make a choice in 4000 ms
/ branch = [ if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option // run the clicking box survey return surveyPage.box_clicking; // otherwise, update the rewards (rest option) --> display feedback } else if (trial.BoxClick_Trial.response=="rest_option"){ // chose the rest option -- assuming that rest option's reward is 1 values.choice_made = values.choice_made + 1; values.obtained_reward = 1; if (values.trialType == "YOU") { values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_YOU; } else { values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_OTHER; } } else { // or perhaps, participant did not make a choice in time --> display feedback values.choice_not_made = values.choice_not_made + 1; values.obtained_reward = 0; if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { return trial.show_box_clicking_feedback_OTHER; } } ] / onTrialend = [ // update the rewards after surveypage.box_clicking (e.g., if participant chose the effortful option) if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option values.choice_made = values.choice_made + 1; if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task values.obtained_reward = values.effortCredits; if (values.trialType == "YOU") { // add the reward to YOU_reward values.YOU_reward = values.YOU_reward + values.effortCredits; //return trial.show_box_clicking_feedback_YOU; } else { // add the reward to OTHER_reward values.OTHER_reward = values.OTHER_reward + values.effortCredits; //return trial.show_box_clicking_feedback_OTHER; } } else { values.obtained_reward = 0; //if (values.trialType == "YOU") { //return trial.show_box_clicking_feedback_YOU; //} else { //return trial.show_box_clicking_feedback_OTHER; //} } } ] </trial>
// show the obtained number of credits after each trial // CURRENTLY NOT USED <trial Show_Feedback> /timeout = 2000 /branch = [ if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { // "OTHER" return trial.show_box_clicking_feedback_OTHER; } ] </trial>
<text box_clicking_feedback_YOU> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = red//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text>
<trial show_box_clicking_feedback_YOU> /stimulusTimes = [0=box_clicking_feedback_YOU] /timeout = 2000 // displays the message for 2 seconds </trial>
<text box_clicking_feedback_OTHER> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = blue//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text>
<trial show_box_clicking_feedback_OTHER> /stimulusTimes = [0=box_clicking_feedback_OTHER] /timeout = 2000 // displays the message for 2 seconds </trial>
// Block containing one full trial -- BoxClick_Trial --> Show_Feedback //<block Full_Trial> /// trials = [1=BoxClick_Trial; 2=Show_Feedback] //</block>
//<page feedback> //^<%values.trialType%> //^<%values.obtained_reward%> //</page>
// Stores the order of the 24 trial types -- YOU or OTHER <list trialTypeList> / selectionMode = sequence </list>
// Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials <list YOU_eff_rewList> / selectionMode = sequence </list>
// Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials <list OTHER_eff_rewList> / selectionMode = sequence </list>
<text effort_option> / items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes") / hPosition = values.effortX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text>
<text rest_option> / items = ("1 credit for Rest") / hPosition = values.restX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text>
<text center_label> / items = ("<%values.trialType%>") // this is the label that should be used in the exp! // items = ("<%values.eff_rew%>") // testing the list selection! / position = (50%, 30%) / txColor = values.c_colorname / fontStyle = ("arial", 16pt, true) </text>
<list trialType> / items = ("YOU", "OTHER") / poolsize = parameters.num_trials / selectionmode = random / selectionrate = always </list>
// This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials // It will be used to to sample --once-- all the 12 combinations <list eff_rew_YOU> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list>
// Likewise for the OTHER trials <list eff_rew_OTHER> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list>
<list x> / items = (35%, 65%) / selectionrate = always </list>
|
|
|
Dave
|
|
Group: Administrators
Posts: 13K,
Visits: 108K
|
+xHello: I wanted to provide feedback to participants immediately after a <trial> that has a /branch section within it. The /branch will--depending on the participant's response--call a <surveypage> using 'return' (I copied the current code below in case it's helpful -- the <trial> in case is BoxClick_Trial). To display the feedback after each <trial>, I thought about using additional 'return' commands inside the /onTrialEnd section. The idea was to use 'return' to call another <trial> (after updating some global variables) whose only job is to display a customized message on the screen. However, using 'return' inside the /onTrialEnd section does not seem to be allowed. After some fiddling, I decided to move portions of the code that were originally inside /onTrialEnd to inside the /branch, right after the conditional call to <surveypage>. However, and somehow expectedly in hindsight, because the flow of the program returns directly to /onTrialEnd after it is deviated by the /branch, I still have not found a way to display the feedback if the <surveypage> is called (if <surveypage> is _not called_, feedbacks are properly displayed by the code following the 'return' command in the /branch). I guess this is a fairly common case but I wonder what would be the best way to handle it? Any help would be greatly appreciated! With very best wishes, EN -- // Global variables -- some of these variables should be re-defined in emot_induction.iqx <values> //Thresholds specified by the procedure defined in calibration_time_boxcount.iqx // Here defined only for testing purposes / easyThresh50 = 8 //The number of boxes at the 50% level / mediumThresh65 = 10 //The number of boxes at the 65% level / mediumThresh80 = 13 //The number of boxes at the 80% level / hardThresh95 = 15 //The number of boxes at the 95% level // From here -- may have to be specified globally to be used in other places // Total number of boxes clicked in box_clicking / box_clicking_boxesChecked = -1 / YOU_reward = 0 / OTHER_reward = 0 / choice_made = 0 / choice_not_made = 0 / obtained_reward = 0 // From here -- specific to social_effort_box_click_task.iqx //Color of trial type -- in fact, red (YOU) or blue (OTHER) / c_colorname = black //Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward / eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST // Position of the two choices / effortX = 0% / restX = 0% // Trial type / trialType = null // Strings to be displayed at every trial / centerLabel = null // will be either YOU or OTHER / effortCredits = 0 / effortBoxes = 0 </values> <parameters> // //These are the rewards (fixed for all participants) / low_pay = 2 //Low reward / medium_pay = 6 //Medium reward / high_pay = 10 //High reward / num_trials = 24 // total number of trials </parameters> // data to be saved in summary file -- CONSIDER ADDING ITEMS in the future <summarydata> /columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.YOU_reward, values.OTHER_reward, values.choice_made, values.choice_not_made) </summarydata> // data to be saved in raw data file <data> /columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode, pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked, values.effortBoxes, values.effortCredits, values.obtained_reward, values.effortX) </data> // These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring! <checkboxes row1> / caption=" " / options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") / optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row2> / caption=" " / options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20") / optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row3> / caption=" " / options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30") / optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row4> / caption=" " / options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40") / optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row5> / caption=" " / options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50") / optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50") / required = true / orientation = horizontalequal </checkboxes> <surveypage box_clicking> / onTrialBegin = [ values.box_clicking_boxesChecked = -1 ] / onTrialEnd = [ values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount; ] /caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes" /questions = [1-5=sequence(row1, row2, row3, row4, row5)] / itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1) / itemspacing = 0.0% / showpagenumbers = false / showbackbutton = false / showquestionnumbers = false / responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1) / timeout = 10000 // 10 seconds / showNextButton = false </surveypage> <block SocialEffort_Block> / onBlockBegin = [ // Randomized trial type order -- 24 trials list.trialTypeList.appendItem(list.trialType.nextValue); //1 list.trialTypeList.appendItem(list.trialType.nextValue); //2 list.trialTypeList.appendItem(list.trialType.nextValue); //3 list.trialTypeList.appendItem(list.trialType.nextValue); //4 list.trialTypeList.appendItem(list.trialType.nextValue); //5 list.trialTypeList.appendItem(list.trialType.nextValue); //6 list.trialTypeList.appendItem(list.trialType.nextValue); //7 list.trialTypeList.appendItem(list.trialType.nextValue); //8 list.trialTypeList.appendItem(list.trialType.nextValue); //9 list.trialTypeList.appendItem(list.trialType.nextValue); //10 list.trialTypeList.appendItem(list.trialType.nextValue); //11 list.trialTypeList.appendItem(list.trialType.nextValue); //12 list.trialTypeList.appendItem(list.trialType.nextValue); //13 list.trialTypeList.appendItem(list.trialType.nextValue); //14 list.trialTypeList.appendItem(list.trialType.nextValue); //15 list.trialTypeList.appendItem(list.trialType.nextValue); //16 list.trialTypeList.appendItem(list.trialType.nextValue); //17 list.trialTypeList.appendItem(list.trialType.nextValue); //18 list.trialTypeList.appendItem(list.trialType.nextValue); //19 list.trialTypeList.appendItem(list.trialType.nextValue); //20 list.trialTypeList.appendItem(list.trialType.nextValue); //21 list.trialTypeList.appendItem(list.trialType.nextValue); //22 list.trialTypeList.appendItem(list.trialType.nextValue); //23 list.trialTypeList.appendItem(list.trialType.nextValue); //24 // Randomized YOU effort-reward 12 pairs list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12 // Randomized OTHER effort-reward 12 pairs list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12 ] // trials = [1-parameters.num_trials = BoxClick_Trial] / trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually.... // trials = [1-24 = Full_Trial] // ATTENTION: defining the number of trials manually.... </block> <trial BoxClick_Trial> / onTrialBegin = [ // pick random postion for effort_option values.effortX = list.x.nextValue; // pick position for rest_option values.restX = list.x.nextValue; // set trial type values.trialType = list.trialTypeList.nextValue; // set center label according to trial type if (values.trialType == "YOU") { values.c_colorname = red; values.eff_rew = list.YOU_eff_rewList.nextValue; } else { // OTHER values.c_colorname = blue; values.eff_rew = list.OTHER_eff_rewList.nextValue; } // set winnings and effort according to the value in eff_rew if (values.eff_rew == "e1_r1") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e1_r2") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e1_r3") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e2_r1") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e2_r2") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e2_r3") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e3_r1") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e3_r2") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e3_r3") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e4_r1") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e4_r2") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e4_r3") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.high_pay; } // Reset the variable box_clicking_boxesChecked values.box_clicking_boxesChecked = -1; ] / stimulusframes = [1=effort_option, rest_option, center_label] / inputdevice = mouse / validresponse = (effort_option, rest_option) / timeout = 4000 // participant must make a choice in 4000 ms / branch = [ if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option // run the clicking box survey return surveyPage.box_clicking; // otherwise, update the rewards (rest option) --> display feedback } else if (trial.BoxClick_Trial.response=="rest_option"){ // chose the rest option -- assuming that rest option's reward is 1 values.choice_made = values.choice_made + 1; values.obtained_reward = 1; if (values.trialType == "YOU") { values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_YOU; } else { values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_OTHER; } } else { // or perhaps, participant did not make a choice in time --> display feedback values.choice_not_made = values.choice_not_made + 1; values.obtained_reward = 0; if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { return trial.show_box_clicking_feedback_OTHER; } } ] / onTrialend = [ // update the rewards after surveypage.box_clicking (e.g., if participant chose the effortful option) if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option values.choice_made = values.choice_made + 1; if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task values.obtained_reward = values.effortCredits; if (values.trialType == "YOU") { // add the reward to YOU_reward values.YOU_reward = values.YOU_reward + values.effortCredits; //return trial.show_box_clicking_feedback_YOU; } else { // add the reward to OTHER_reward values.OTHER_reward = values.OTHER_reward + values.effortCredits; //return trial.show_box_clicking_feedback_OTHER; } } else { values.obtained_reward = 0; //if (values.trialType == "YOU") { //return trial.show_box_clicking_feedback_YOU; //} else { //return trial.show_box_clicking_feedback_OTHER; //} } } ] </trial> // show the obtained number of credits after each trial // CURRENTLY NOT USED <trial Show_Feedback> /timeout = 2000 /branch = [ if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { // "OTHER" return trial.show_box_clicking_feedback_OTHER; } ] </trial> <text box_clicking_feedback_YOU> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = red//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_YOU> /stimulusTimes = [0=box_clicking_feedback_YOU] /timeout = 2000 // displays the message for 2 seconds </trial> <text box_clicking_feedback_OTHER> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = blue//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_OTHER> /stimulusTimes = [0=box_clicking_feedback_OTHER] /timeout = 2000 // displays the message for 2 seconds </trial> // Block containing one full trial -- BoxClick_Trial --> Show_Feedback //<block Full_Trial> /// trials = [1=BoxClick_Trial; 2=Show_Feedback] //</block> //<page feedback> //^<%values.trialType%> //^<%values.obtained_reward%> //</page> // Stores the order of the 24 trial types -- YOU or OTHER <list trialTypeList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials <list YOU_eff_rewList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials <list OTHER_eff_rewList> / selectionMode = sequence </list> <text effort_option> / items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes") / hPosition = values.effortX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text rest_option> / items = ("1 credit for Rest") / hPosition = values.restX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text center_label> / items = ("<%values.trialType%>") // this is the label that should be used in the exp! // items = ("<%values.eff_rew%>") // testing the list selection! / position = (50%, 30%) / txColor = values.c_colorname / fontStyle = ("arial", 16pt, true) </text> <list trialType> / items = ("YOU", "OTHER") / poolsize = parameters.num_trials / selectionmode = random / selectionrate = always </list> // This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials // It will be used to to sample --once-- all the 12 combinations <list eff_rew_YOU> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> // Likewise for the OTHER trials <list eff_rew_OTHER> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> <list x> / items = (35%, 65%) / selectionrate = always </list> The /branch obviously ought to be in the <surveyPage>. Once the <trial> has /branches to the <surveypage>, the <trial> is over. It cannot then somehow /branch to yet another thing after the <surveypage>. The <surveypage> has to /branch. Moving things around between /onTrialEnd and /barnch will not change a thing about this. /onTrialEnd attributes are for executing logic (performing calculations, etc.) at the end of a trial. They are executed in the order given top to bottom. You cannot "return" a trial from /onTrialEnd, that is not what it's for. /branch is for dynamically deciding where to go next after the trial.
|
|
|
EN
|
|
Group: Forum Members
Posts: 42,
Visits: 211
|
+x+xHello: I wanted to provide feedback to participants immediately after a <trial> that has a /branch section within it. The /branch will--depending on the participant's response--call a <surveypage> using 'return' (I copied the current code below in case it's helpful -- the <trial> in case is BoxClick_Trial). To display the feedback after each <trial>, I thought about using additional 'return' commands inside the /onTrialEnd section. The idea was to use 'return' to call another <trial> (after updating some global variables) whose only job is to display a customized message on the screen. However, using 'return' inside the /onTrialEnd section does not seem to be allowed. After some fiddling, I decided to move portions of the code that were originally inside /onTrialEnd to inside the /branch, right after the conditional call to <surveypage>. However, and somehow expectedly in hindsight, because the flow of the program returns directly to /onTrialEnd after it is deviated by the /branch, I still have not found a way to display the feedback if the <surveypage> is called (if <surveypage> is _not called_, feedbacks are properly displayed by the code following the 'return' command in the /branch). I guess this is a fairly common case but I wonder what would be the best way to handle it? Any help would be greatly appreciated! With very best wishes, EN -- // Global variables -- some of these variables should be re-defined in emot_induction.iqx <values> //Thresholds specified by the procedure defined in calibration_time_boxcount.iqx // Here defined only for testing purposes / easyThresh50 = 8 //The number of boxes at the 50% level / mediumThresh65 = 10 //The number of boxes at the 65% level / mediumThresh80 = 13 //The number of boxes at the 80% level / hardThresh95 = 15 //The number of boxes at the 95% level // From here -- may have to be specified globally to be used in other places // Total number of boxes clicked in box_clicking / box_clicking_boxesChecked = -1 / YOU_reward = 0 / OTHER_reward = 0 / choice_made = 0 / choice_not_made = 0 / obtained_reward = 0 // From here -- specific to social_effort_box_click_task.iqx //Color of trial type -- in fact, red (YOU) or blue (OTHER) / c_colorname = black //Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward / eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST // Position of the two choices / effortX = 0% / restX = 0% // Trial type / trialType = null // Strings to be displayed at every trial / centerLabel = null // will be either YOU or OTHER / effortCredits = 0 / effortBoxes = 0 </values> <parameters> // //These are the rewards (fixed for all participants) / low_pay = 2 //Low reward / medium_pay = 6 //Medium reward / high_pay = 10 //High reward / num_trials = 24 // total number of trials </parameters> // data to be saved in summary file -- CONSIDER ADDING ITEMS in the future <summarydata> /columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.YOU_reward, values.OTHER_reward, values.choice_made, values.choice_not_made) </summarydata> // data to be saved in raw data file <data> /columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode, pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked, values.effortBoxes, values.effortCredits, values.obtained_reward, values.effortX) </data> // These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring! <checkboxes row1> / caption=" " / options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") / optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row2> / caption=" " / options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20") / optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row3> / caption=" " / options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30") / optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row4> / caption=" " / options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40") / optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row5> / caption=" " / options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50") / optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50") / required = true / orientation = horizontalequal </checkboxes> <surveypage box_clicking> / onTrialBegin = [ values.box_clicking_boxesChecked = -1 ] / onTrialEnd = [ values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount; ] /caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes" /questions = [1-5=sequence(row1, row2, row3, row4, row5)] / itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1) / itemspacing = 0.0% / showpagenumbers = false / showbackbutton = false / showquestionnumbers = false / responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1) / timeout = 10000 // 10 seconds / showNextButton = false </surveypage> <block SocialEffort_Block> / onBlockBegin = [ // Randomized trial type order -- 24 trials list.trialTypeList.appendItem(list.trialType.nextValue); //1 list.trialTypeList.appendItem(list.trialType.nextValue); //2 list.trialTypeList.appendItem(list.trialType.nextValue); //3 list.trialTypeList.appendItem(list.trialType.nextValue); //4 list.trialTypeList.appendItem(list.trialType.nextValue); //5 list.trialTypeList.appendItem(list.trialType.nextValue); //6 list.trialTypeList.appendItem(list.trialType.nextValue); //7 list.trialTypeList.appendItem(list.trialType.nextValue); //8 list.trialTypeList.appendItem(list.trialType.nextValue); //9 list.trialTypeList.appendItem(list.trialType.nextValue); //10 list.trialTypeList.appendItem(list.trialType.nextValue); //11 list.trialTypeList.appendItem(list.trialType.nextValue); //12 list.trialTypeList.appendItem(list.trialType.nextValue); //13 list.trialTypeList.appendItem(list.trialType.nextValue); //14 list.trialTypeList.appendItem(list.trialType.nextValue); //15 list.trialTypeList.appendItem(list.trialType.nextValue); //16 list.trialTypeList.appendItem(list.trialType.nextValue); //17 list.trialTypeList.appendItem(list.trialType.nextValue); //18 list.trialTypeList.appendItem(list.trialType.nextValue); //19 list.trialTypeList.appendItem(list.trialType.nextValue); //20 list.trialTypeList.appendItem(list.trialType.nextValue); //21 list.trialTypeList.appendItem(list.trialType.nextValue); //22 list.trialTypeList.appendItem(list.trialType.nextValue); //23 list.trialTypeList.appendItem(list.trialType.nextValue); //24 // Randomized YOU effort-reward 12 pairs list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12 // Randomized OTHER effort-reward 12 pairs list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12 ] // trials = [1-parameters.num_trials = BoxClick_Trial] / trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually.... // trials = [1-24 = Full_Trial] // ATTENTION: defining the number of trials manually.... </block> <trial BoxClick_Trial> / onTrialBegin = [ // pick random postion for effort_option values.effortX = list.x.nextValue; // pick position for rest_option values.restX = list.x.nextValue; // set trial type values.trialType = list.trialTypeList.nextValue; // set center label according to trial type if (values.trialType == "YOU") { values.c_colorname = red; values.eff_rew = list.YOU_eff_rewList.nextValue; } else { // OTHER values.c_colorname = blue; values.eff_rew = list.OTHER_eff_rewList.nextValue; } // set winnings and effort according to the value in eff_rew if (values.eff_rew == "e1_r1") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e1_r2") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e1_r3") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e2_r1") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e2_r2") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e2_r3") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e3_r1") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e3_r2") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e3_r3") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e4_r1") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e4_r2") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e4_r3") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.high_pay; } // Reset the variable box_clicking_boxesChecked values.box_clicking_boxesChecked = -1; ] / stimulusframes = [1=effort_option, rest_option, center_label] / inputdevice = mouse / validresponse = (effort_option, rest_option) / timeout = 4000 // participant must make a choice in 4000 ms / branch = [ if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option // run the clicking box survey return surveyPage.box_clicking; // otherwise, update the rewards (rest option) --> display feedback } else if (trial.BoxClick_Trial.response=="rest_option"){ // chose the rest option -- assuming that rest option's reward is 1 values.choice_made = values.choice_made + 1; values.obtained_reward = 1; if (values.trialType == "YOU") { values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_YOU; } else { values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_OTHER; } } else { // or perhaps, participant did not make a choice in time --> display feedback values.choice_not_made = values.choice_not_made + 1; values.obtained_reward = 0; if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { return trial.show_box_clicking_feedback_OTHER; } } ] / onTrialend = [ // update the rewards after surveypage.box_clicking (e.g., if participant chose the effortful option) if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option values.choice_made = values.choice_made + 1; if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task values.obtained_reward = values.effortCredits; if (values.trialType == "YOU") { // add the reward to YOU_reward values.YOU_reward = values.YOU_reward + values.effortCredits; //return trial.show_box_clicking_feedback_YOU; } else { // add the reward to OTHER_reward values.OTHER_reward = values.OTHER_reward + values.effortCredits; //return trial.show_box_clicking_feedback_OTHER; } } else { values.obtained_reward = 0; //if (values.trialType == "YOU") { //return trial.show_box_clicking_feedback_YOU; //} else { //return trial.show_box_clicking_feedback_OTHER; //} } } ] </trial> // show the obtained number of credits after each trial // CURRENTLY NOT USED <trial Show_Feedback> /timeout = 2000 /branch = [ if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { // "OTHER" return trial.show_box_clicking_feedback_OTHER; } ] </trial> <text box_clicking_feedback_YOU> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = red//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_YOU> /stimulusTimes = [0=box_clicking_feedback_YOU] /timeout = 2000 // displays the message for 2 seconds </trial> <text box_clicking_feedback_OTHER> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = blue//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_OTHER> /stimulusTimes = [0=box_clicking_feedback_OTHER] /timeout = 2000 // displays the message for 2 seconds </trial> // Block containing one full trial -- BoxClick_Trial --> Show_Feedback //<block Full_Trial> /// trials = [1=BoxClick_Trial; 2=Show_Feedback] //</block> //<page feedback> //^<%values.trialType%> //^<%values.obtained_reward%> //</page> // Stores the order of the 24 trial types -- YOU or OTHER <list trialTypeList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials <list YOU_eff_rewList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials <list OTHER_eff_rewList> / selectionMode = sequence </list> <text effort_option> / items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes") / hPosition = values.effortX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text rest_option> / items = ("1 credit for Rest") / hPosition = values.restX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text center_label> / items = ("<%values.trialType%>") // this is the label that should be used in the exp! // items = ("<%values.eff_rew%>") // testing the list selection! / position = (50%, 30%) / txColor = values.c_colorname / fontStyle = ("arial", 16pt, true) </text> <list trialType> / items = ("YOU", "OTHER") / poolsize = parameters.num_trials / selectionmode = random / selectionrate = always </list> // This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials // It will be used to to sample --once-- all the 12 combinations <list eff_rew_YOU> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> // Likewise for the OTHER trials <list eff_rew_OTHER> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> <list x> / items = (35%, 65%) / selectionrate = always </list> The /branch obviously ought to be in the <surveyPage>. Once the <trial> has /branches to the <surveypage>, the <trial> is over. It cannot then somehow /branch to yet another thing after the <surveypage>. The <surveypage> has to /branch. Moving things around between /onTrialEnd and /barnch will not change a thing about this. /onTrialEnd attributes are for executing logic (performing calculations, etc.) at the end of a trial. They are executed in the order given top to bottom. You cannot "return" a trial from /onTrialEnd, that is not what it's for. /branch is for dynamically deciding where to go next after the trial. Thanks, Dave! However, if I want to provide feedback _after_ participants have completed the <surveypage> AND customize the feedback according to the responses given by participants in the <surveypage>, I thought I would have to add that "logic" in the /onTrialEnd of the <surveypage>, which would not work either, no? I don't see how using /branch inside the <surveypage> could help... Could you provide an example where (1) responses are given to a <surveypage> , and (2) feedback is displayed on screen depending on the responses given in the <surveypage> (in my code, that is in effect the number of boxes that were clicked by the participant)? Thanks in advance! EN
|
|
|
Dave
|
|
Group: Administrators
Posts: 13K,
Visits: 108K
|
+x+x+xHello: I wanted to provide feedback to participants immediately after a <trial> that has a /branch section within it. The /branch will--depending on the participant's response--call a <surveypage> using 'return' (I copied the current code below in case it's helpful -- the <trial> in case is BoxClick_Trial). To display the feedback after each <trial>, I thought about using additional 'return' commands inside the /onTrialEnd section. The idea was to use 'return' to call another <trial> (after updating some global variables) whose only job is to display a customized message on the screen. However, using 'return' inside the /onTrialEnd section does not seem to be allowed. After some fiddling, I decided to move portions of the code that were originally inside /onTrialEnd to inside the /branch, right after the conditional call to <surveypage>. However, and somehow expectedly in hindsight, because the flow of the program returns directly to /onTrialEnd after it is deviated by the /branch, I still have not found a way to display the feedback if the <surveypage> is called (if <surveypage> is _not called_, feedbacks are properly displayed by the code following the 'return' command in the /branch). I guess this is a fairly common case but I wonder what would be the best way to handle it? Any help would be greatly appreciated! With very best wishes, EN -- // Global variables -- some of these variables should be re-defined in emot_induction.iqx <values> //Thresholds specified by the procedure defined in calibration_time_boxcount.iqx // Here defined only for testing purposes / easyThresh50 = 8 //The number of boxes at the 50% level / mediumThresh65 = 10 //The number of boxes at the 65% level / mediumThresh80 = 13 //The number of boxes at the 80% level / hardThresh95 = 15 //The number of boxes at the 95% level // From here -- may have to be specified globally to be used in other places // Total number of boxes clicked in box_clicking / box_clicking_boxesChecked = -1 / YOU_reward = 0 / OTHER_reward = 0 / choice_made = 0 / choice_not_made = 0 / obtained_reward = 0 // From here -- specific to social_effort_box_click_task.iqx //Color of trial type -- in fact, red (YOU) or blue (OTHER) / c_colorname = black //Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward / eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST // Position of the two choices / effortX = 0% / restX = 0% // Trial type / trialType = null // Strings to be displayed at every trial / centerLabel = null // will be either YOU or OTHER / effortCredits = 0 / effortBoxes = 0 </values> <parameters> // //These are the rewards (fixed for all participants) / low_pay = 2 //Low reward / medium_pay = 6 //Medium reward / high_pay = 10 //High reward / num_trials = 24 // total number of trials </parameters> // data to be saved in summary file -- CONSIDER ADDING ITEMS in the future <summarydata> /columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.YOU_reward, values.OTHER_reward, values.choice_made, values.choice_not_made) </summarydata> // data to be saved in raw data file <data> /columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode, pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked, values.effortBoxes, values.effortCredits, values.obtained_reward, values.effortX) </data> // These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring! <checkboxes row1> / caption=" " / options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") / optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row2> / caption=" " / options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20") / optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row3> / caption=" " / options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30") / optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row4> / caption=" " / options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40") / optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row5> / caption=" " / options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50") / optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50") / required = true / orientation = horizontalequal </checkboxes> <surveypage box_clicking> / onTrialBegin = [ values.box_clicking_boxesChecked = -1 ] / onTrialEnd = [ values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount; ] /caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes" /questions = [1-5=sequence(row1, row2, row3, row4, row5)] / itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1) / itemspacing = 0.0% / showpagenumbers = false / showbackbutton = false / showquestionnumbers = false / responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1) / timeout = 10000 // 10 seconds / showNextButton = false </surveypage> <block SocialEffort_Block> / onBlockBegin = [ // Randomized trial type order -- 24 trials list.trialTypeList.appendItem(list.trialType.nextValue); //1 list.trialTypeList.appendItem(list.trialType.nextValue); //2 list.trialTypeList.appendItem(list.trialType.nextValue); //3 list.trialTypeList.appendItem(list.trialType.nextValue); //4 list.trialTypeList.appendItem(list.trialType.nextValue); //5 list.trialTypeList.appendItem(list.trialType.nextValue); //6 list.trialTypeList.appendItem(list.trialType.nextValue); //7 list.trialTypeList.appendItem(list.trialType.nextValue); //8 list.trialTypeList.appendItem(list.trialType.nextValue); //9 list.trialTypeList.appendItem(list.trialType.nextValue); //10 list.trialTypeList.appendItem(list.trialType.nextValue); //11 list.trialTypeList.appendItem(list.trialType.nextValue); //12 list.trialTypeList.appendItem(list.trialType.nextValue); //13 list.trialTypeList.appendItem(list.trialType.nextValue); //14 list.trialTypeList.appendItem(list.trialType.nextValue); //15 list.trialTypeList.appendItem(list.trialType.nextValue); //16 list.trialTypeList.appendItem(list.trialType.nextValue); //17 list.trialTypeList.appendItem(list.trialType.nextValue); //18 list.trialTypeList.appendItem(list.trialType.nextValue); //19 list.trialTypeList.appendItem(list.trialType.nextValue); //20 list.trialTypeList.appendItem(list.trialType.nextValue); //21 list.trialTypeList.appendItem(list.trialType.nextValue); //22 list.trialTypeList.appendItem(list.trialType.nextValue); //23 list.trialTypeList.appendItem(list.trialType.nextValue); //24 // Randomized YOU effort-reward 12 pairs list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12 // Randomized OTHER effort-reward 12 pairs list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12 ] // trials = [1-parameters.num_trials = BoxClick_Trial] / trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually.... // trials = [1-24 = Full_Trial] // ATTENTION: defining the number of trials manually.... </block> <trial BoxClick_Trial> / onTrialBegin = [ // pick random postion for effort_option values.effortX = list.x.nextValue; // pick position for rest_option values.restX = list.x.nextValue; // set trial type values.trialType = list.trialTypeList.nextValue; // set center label according to trial type if (values.trialType == "YOU") { values.c_colorname = red; values.eff_rew = list.YOU_eff_rewList.nextValue; } else { // OTHER values.c_colorname = blue; values.eff_rew = list.OTHER_eff_rewList.nextValue; } // set winnings and effort according to the value in eff_rew if (values.eff_rew == "e1_r1") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e1_r2") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e1_r3") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e2_r1") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e2_r2") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e2_r3") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e3_r1") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e3_r2") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e3_r3") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e4_r1") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e4_r2") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e4_r3") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.high_pay; } // Reset the variable box_clicking_boxesChecked values.box_clicking_boxesChecked = -1; ] / stimulusframes = [1=effort_option, rest_option, center_label] / inputdevice = mouse / validresponse = (effort_option, rest_option) / timeout = 4000 // participant must make a choice in 4000 ms / branch = [ if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option // run the clicking box survey return surveyPage.box_clicking; // otherwise, update the rewards (rest option) --> display feedback } else if (trial.BoxClick_Trial.response=="rest_option"){ // chose the rest option -- assuming that rest option's reward is 1 values.choice_made = values.choice_made + 1; values.obtained_reward = 1; if (values.trialType == "YOU") { values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_YOU; } else { values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_OTHER; } } else { // or perhaps, participant did not make a choice in time --> display feedback values.choice_not_made = values.choice_not_made + 1; values.obtained_reward = 0; if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { return trial.show_box_clicking_feedback_OTHER; } } ] / onTrialend = [ // update the rewards after surveypage.box_clicking (e.g., if participant chose the effortful option) if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option values.choice_made = values.choice_made + 1; if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task values.obtained_reward = values.effortCredits; if (values.trialType == "YOU") { // add the reward to YOU_reward values.YOU_reward = values.YOU_reward + values.effortCredits; //return trial.show_box_clicking_feedback_YOU; } else { // add the reward to OTHER_reward values.OTHER_reward = values.OTHER_reward + values.effortCredits; //return trial.show_box_clicking_feedback_OTHER; } } else { values.obtained_reward = 0; //if (values.trialType == "YOU") { //return trial.show_box_clicking_feedback_YOU; //} else { //return trial.show_box_clicking_feedback_OTHER; //} } } ] </trial> // show the obtained number of credits after each trial // CURRENTLY NOT USED <trial Show_Feedback> /timeout = 2000 /branch = [ if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { // "OTHER" return trial.show_box_clicking_feedback_OTHER; } ] </trial> <text box_clicking_feedback_YOU> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = red//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_YOU> /stimulusTimes = [0=box_clicking_feedback_YOU] /timeout = 2000 // displays the message for 2 seconds </trial> <text box_clicking_feedback_OTHER> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = blue//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_OTHER> /stimulusTimes = [0=box_clicking_feedback_OTHER] /timeout = 2000 // displays the message for 2 seconds </trial> // Block containing one full trial -- BoxClick_Trial --> Show_Feedback //<block Full_Trial> /// trials = [1=BoxClick_Trial; 2=Show_Feedback] //</block> //<page feedback> //^<%values.trialType%> //^<%values.obtained_reward%> //</page> // Stores the order of the 24 trial types -- YOU or OTHER <list trialTypeList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials <list YOU_eff_rewList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials <list OTHER_eff_rewList> / selectionMode = sequence </list> <text effort_option> / items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes") / hPosition = values.effortX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text rest_option> / items = ("1 credit for Rest") / hPosition = values.restX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text center_label> / items = ("<%values.trialType%>") // this is the label that should be used in the exp! // items = ("<%values.eff_rew%>") // testing the list selection! / position = (50%, 30%) / txColor = values.c_colorname / fontStyle = ("arial", 16pt, true) </text> <list trialType> / items = ("YOU", "OTHER") / poolsize = parameters.num_trials / selectionmode = random / selectionrate = always </list> // This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials // It will be used to to sample --once-- all the 12 combinations <list eff_rew_YOU> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> // Likewise for the OTHER trials <list eff_rew_OTHER> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> <list x> / items = (35%, 65%) / selectionrate = always </list> The /branch obviously ought to be in the <surveyPage>. Once the <trial> has /branches to the <surveypage>, the <trial> is over. It cannot then somehow /branch to yet another thing after the <surveypage>. The <surveypage> has to /branch. Moving things around between /onTrialEnd and /barnch will not change a thing about this. /onTrialEnd attributes are for executing logic (performing calculations, etc.) at the end of a trial. They are executed in the order given top to bottom. You cannot "return" a trial from /onTrialEnd, that is not what it's for. /branch is for dynamically deciding where to go next after the trial. Thanks, Dave! However, if I want to provide feedback _after_ participants have completed the <surveypage> AND customize the feedback according to the responses given by participants in the <surveypage>, I thought I would have to add that "logic" in the /onTrialEnd of the <surveypage>, which would not work either, no? I don't see how using /branch inside the <surveypage> could help... Could you provide an example where (1) responses are given to a <surveypage> , and (2) feedback is displayed on screen depending on the responses given in the <surveypage> (in my code, that is in effect the number of boxes that were clicked by the participant)? Thanks in advance! EN Why do you think that would not wokr? It's really not complicated. Of course you can have /onTrialEnd logic in a <surveyPage> that counts up how many boxes where check and then display that in a feedback trial after.
|
|
|
Dave
|
|
Group: Administrators
Posts: 13K,
Visits: 108K
|
+x+x+x+xHello: I wanted to provide feedback to participants immediately after a <trial> that has a /branch section within it. The /branch will--depending on the participant's response--call a <surveypage> using 'return' (I copied the current code below in case it's helpful -- the <trial> in case is BoxClick_Trial). To display the feedback after each <trial>, I thought about using additional 'return' commands inside the /onTrialEnd section. The idea was to use 'return' to call another <trial> (after updating some global variables) whose only job is to display a customized message on the screen. However, using 'return' inside the /onTrialEnd section does not seem to be allowed. After some fiddling, I decided to move portions of the code that were originally inside /onTrialEnd to inside the /branch, right after the conditional call to <surveypage>. However, and somehow expectedly in hindsight, because the flow of the program returns directly to /onTrialEnd after it is deviated by the /branch, I still have not found a way to display the feedback if the <surveypage> is called (if <surveypage> is _not called_, feedbacks are properly displayed by the code following the 'return' command in the /branch). I guess this is a fairly common case but I wonder what would be the best way to handle it? Any help would be greatly appreciated! With very best wishes, EN -- // Global variables -- some of these variables should be re-defined in emot_induction.iqx <values> //Thresholds specified by the procedure defined in calibration_time_boxcount.iqx // Here defined only for testing purposes / easyThresh50 = 8 //The number of boxes at the 50% level / mediumThresh65 = 10 //The number of boxes at the 65% level / mediumThresh80 = 13 //The number of boxes at the 80% level / hardThresh95 = 15 //The number of boxes at the 95% level // From here -- may have to be specified globally to be used in other places // Total number of boxes clicked in box_clicking / box_clicking_boxesChecked = -1 / YOU_reward = 0 / OTHER_reward = 0 / choice_made = 0 / choice_not_made = 0 / obtained_reward = 0 // From here -- specific to social_effort_box_click_task.iqx //Color of trial type -- in fact, red (YOU) or blue (OTHER) / c_colorname = black //Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward / eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST // Position of the two choices / effortX = 0% / restX = 0% // Trial type / trialType = null // Strings to be displayed at every trial / centerLabel = null // will be either YOU or OTHER / effortCredits = 0 / effortBoxes = 0 </values> <parameters> // //These are the rewards (fixed for all participants) / low_pay = 2 //Low reward / medium_pay = 6 //Medium reward / high_pay = 10 //High reward / num_trials = 24 // total number of trials </parameters> // data to be saved in summary file -- CONSIDER ADDING ITEMS in the future <summarydata> /columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.YOU_reward, values.OTHER_reward, values.choice_made, values.choice_not_made) </summarydata> // data to be saved in raw data file <data> /columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode, pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked, values.effortBoxes, values.effortCredits, values.obtained_reward, values.effortX) </data> // These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring! <checkboxes row1> / caption=" " / options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") / optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row2> / caption=" " / options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20") / optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row3> / caption=" " / options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30") / optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row4> / caption=" " / options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40") / optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row5> / caption=" " / options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50") / optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50") / required = true / orientation = horizontalequal </checkboxes> <surveypage box_clicking> / onTrialBegin = [ values.box_clicking_boxesChecked = -1 ] / onTrialEnd = [ values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount; ] /caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes" /questions = [1-5=sequence(row1, row2, row3, row4, row5)] / itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1) / itemspacing = 0.0% / showpagenumbers = false / showbackbutton = false / showquestionnumbers = false / responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1) / timeout = 10000 // 10 seconds / showNextButton = false </surveypage> <block SocialEffort_Block> / onBlockBegin = [ // Randomized trial type order -- 24 trials list.trialTypeList.appendItem(list.trialType.nextValue); //1 list.trialTypeList.appendItem(list.trialType.nextValue); //2 list.trialTypeList.appendItem(list.trialType.nextValue); //3 list.trialTypeList.appendItem(list.trialType.nextValue); //4 list.trialTypeList.appendItem(list.trialType.nextValue); //5 list.trialTypeList.appendItem(list.trialType.nextValue); //6 list.trialTypeList.appendItem(list.trialType.nextValue); //7 list.trialTypeList.appendItem(list.trialType.nextValue); //8 list.trialTypeList.appendItem(list.trialType.nextValue); //9 list.trialTypeList.appendItem(list.trialType.nextValue); //10 list.trialTypeList.appendItem(list.trialType.nextValue); //11 list.trialTypeList.appendItem(list.trialType.nextValue); //12 list.trialTypeList.appendItem(list.trialType.nextValue); //13 list.trialTypeList.appendItem(list.trialType.nextValue); //14 list.trialTypeList.appendItem(list.trialType.nextValue); //15 list.trialTypeList.appendItem(list.trialType.nextValue); //16 list.trialTypeList.appendItem(list.trialType.nextValue); //17 list.trialTypeList.appendItem(list.trialType.nextValue); //18 list.trialTypeList.appendItem(list.trialType.nextValue); //19 list.trialTypeList.appendItem(list.trialType.nextValue); //20 list.trialTypeList.appendItem(list.trialType.nextValue); //21 list.trialTypeList.appendItem(list.trialType.nextValue); //22 list.trialTypeList.appendItem(list.trialType.nextValue); //23 list.trialTypeList.appendItem(list.trialType.nextValue); //24 // Randomized YOU effort-reward 12 pairs list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12 // Randomized OTHER effort-reward 12 pairs list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12 ] // trials = [1-parameters.num_trials = BoxClick_Trial] / trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually.... // trials = [1-24 = Full_Trial] // ATTENTION: defining the number of trials manually.... </block> <trial BoxClick_Trial> / onTrialBegin = [ // pick random postion for effort_option values.effortX = list.x.nextValue; // pick position for rest_option values.restX = list.x.nextValue; // set trial type values.trialType = list.trialTypeList.nextValue; // set center label according to trial type if (values.trialType == "YOU") { values.c_colorname = red; values.eff_rew = list.YOU_eff_rewList.nextValue; } else { // OTHER values.c_colorname = blue; values.eff_rew = list.OTHER_eff_rewList.nextValue; } // set winnings and effort according to the value in eff_rew if (values.eff_rew == "e1_r1") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e1_r2") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e1_r3") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e2_r1") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e2_r2") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e2_r3") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e3_r1") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e3_r2") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e3_r3") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e4_r1") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e4_r2") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e4_r3") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.high_pay; } // Reset the variable box_clicking_boxesChecked values.box_clicking_boxesChecked = -1; ] / stimulusframes = [1=effort_option, rest_option, center_label] / inputdevice = mouse / validresponse = (effort_option, rest_option) / timeout = 4000 // participant must make a choice in 4000 ms / branch = [ if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option // run the clicking box survey return surveyPage.box_clicking; // otherwise, update the rewards (rest option) --> display feedback } else if (trial.BoxClick_Trial.response=="rest_option"){ // chose the rest option -- assuming that rest option's reward is 1 values.choice_made = values.choice_made + 1; values.obtained_reward = 1; if (values.trialType == "YOU") { values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_YOU; } else { values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_OTHER; } } else { // or perhaps, participant did not make a choice in time --> display feedback values.choice_not_made = values.choice_not_made + 1; values.obtained_reward = 0; if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { return trial.show_box_clicking_feedback_OTHER; } } ] / onTrialend = [ // update the rewards after surveypage.box_clicking (e.g., if participant chose the effortful option) if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option values.choice_made = values.choice_made + 1; if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task values.obtained_reward = values.effortCredits; if (values.trialType == "YOU") { // add the reward to YOU_reward values.YOU_reward = values.YOU_reward + values.effortCredits; //return trial.show_box_clicking_feedback_YOU; } else { // add the reward to OTHER_reward values.OTHER_reward = values.OTHER_reward + values.effortCredits; //return trial.show_box_clicking_feedback_OTHER; } } else { values.obtained_reward = 0; //if (values.trialType == "YOU") { //return trial.show_box_clicking_feedback_YOU; //} else { //return trial.show_box_clicking_feedback_OTHER; //} } } ] </trial> // show the obtained number of credits after each trial // CURRENTLY NOT USED <trial Show_Feedback> /timeout = 2000 /branch = [ if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { // "OTHER" return trial.show_box_clicking_feedback_OTHER; } ] </trial> <text box_clicking_feedback_YOU> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = red//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_YOU> /stimulusTimes = [0=box_clicking_feedback_YOU] /timeout = 2000 // displays the message for 2 seconds </trial> <text box_clicking_feedback_OTHER> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = blue//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_OTHER> /stimulusTimes = [0=box_clicking_feedback_OTHER] /timeout = 2000 // displays the message for 2 seconds </trial> // Block containing one full trial -- BoxClick_Trial --> Show_Feedback //<block Full_Trial> /// trials = [1=BoxClick_Trial; 2=Show_Feedback] //</block> //<page feedback> //^<%values.trialType%> //^<%values.obtained_reward%> //</page> // Stores the order of the 24 trial types -- YOU or OTHER <list trialTypeList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials <list YOU_eff_rewList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials <list OTHER_eff_rewList> / selectionMode = sequence </list> <text effort_option> / items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes") / hPosition = values.effortX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text rest_option> / items = ("1 credit for Rest") / hPosition = values.restX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text center_label> / items = ("<%values.trialType%>") // this is the label that should be used in the exp! // items = ("<%values.eff_rew%>") // testing the list selection! / position = (50%, 30%) / txColor = values.c_colorname / fontStyle = ("arial", 16pt, true) </text> <list trialType> / items = ("YOU", "OTHER") / poolsize = parameters.num_trials / selectionmode = random / selectionrate = always </list> // This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials // It will be used to to sample --once-- all the 12 combinations <list eff_rew_YOU> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> // Likewise for the OTHER trials <list eff_rew_OTHER> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> <list x> / items = (35%, 65%) / selectionrate = always </list> The /branch obviously ought to be in the <surveyPage>. Once the <trial> has /branches to the <surveypage>, the <trial> is over. It cannot then somehow /branch to yet another thing after the <surveypage>. The <surveypage> has to /branch. Moving things around between /onTrialEnd and /barnch will not change a thing about this. /onTrialEnd attributes are for executing logic (performing calculations, etc.) at the end of a trial. They are executed in the order given top to bottom. You cannot "return" a trial from /onTrialEnd, that is not what it's for. /branch is for dynamically deciding where to go next after the trial. Thanks, Dave! However, if I want to provide feedback _after_ participants have completed the <surveypage> AND customize the feedback according to the responses given by participants in the <surveypage>, I thought I would have to add that "logic" in the /onTrialEnd of the <surveypage>, which would not work either, no? I don't see how using /branch inside the <surveypage> could help... Could you provide an example where (1) responses are given to a <surveypage> , and (2) feedback is displayed on screen depending on the responses given in the <surveypage> (in my code, that is in effect the number of boxes that were clicked by the participant)? Thanks in advance! EN Why do you think that would not wokr? It's really not complicated. Of course you can have /onTrialEnd logic in a <surveyPage> that counts up how many boxes where check and then display that in a feedback trial after. <values> / feedBackMessage = null </values>
<block taskBlock> / trials = [1-4 = choiceTrial] </block>
<trial choiceTrial> / stimulusFrames = [1=clearScreen,doSomething, doNothing] / inputDevice = mouse / validResponse = (doSomething,doNothing) / branch = [ if (trial.choiceTrial.response == "doNothing") { values.feedBackMessage = "You did nothing."; return trial.feedBackTrial; } else { return surveyPage.checkSomeBoxes; } ] </trial>
<trial feedBackTrial> / stimulusFrames = [1=clearScreen, feedBackText] / validResponse = (0) / trialDuration = 2000 </trial>
<surveypage checkSomeBoxes> / questions = [1=checkMe] / showNextButton = false / showPageNumbers = false / showQuestionNumbers = false / timeout = 5000 / branch = [ values.feedBackMessage = concat("Number of boxes checked: ", checkBoxes.checkMe.selectedCount); return trial.feedBackTrial; ] </surveypage>
<checkBoxes checkMe> / options = ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10") / orientation = horizontalequal </checkboxes>
<text doSomething> / items = ("I want to check some boxes.") / position = (25%, 65%) </text>
<text doNothing> / items = ("I'd rather do nothing.") / position = (75%, 65%) </text>
<text feedBackText> / items = ("<%values.feedBackMessage%>") </text>
|
|
|
EN
|
|
Group: Forum Members
Posts: 42,
Visits: 211
|
+x+x+x+x+xHello: I wanted to provide feedback to participants immediately after a <trial> that has a /branch section within it. The /branch will--depending on the participant's response--call a <surveypage> using 'return' (I copied the current code below in case it's helpful -- the <trial> in case is BoxClick_Trial). To display the feedback after each <trial>, I thought about using additional 'return' commands inside the /onTrialEnd section. The idea was to use 'return' to call another <trial> (after updating some global variables) whose only job is to display a customized message on the screen. However, using 'return' inside the /onTrialEnd section does not seem to be allowed. After some fiddling, I decided to move portions of the code that were originally inside /onTrialEnd to inside the /branch, right after the conditional call to <surveypage>. However, and somehow expectedly in hindsight, because the flow of the program returns directly to /onTrialEnd after it is deviated by the /branch, I still have not found a way to display the feedback if the <surveypage> is called (if <surveypage> is _not called_, feedbacks are properly displayed by the code following the 'return' command in the /branch). I guess this is a fairly common case but I wonder what would be the best way to handle it? Any help would be greatly appreciated! With very best wishes, EN -- // Global variables -- some of these variables should be re-defined in emot_induction.iqx <values> //Thresholds specified by the procedure defined in calibration_time_boxcount.iqx // Here defined only for testing purposes / easyThresh50 = 8 //The number of boxes at the 50% level / mediumThresh65 = 10 //The number of boxes at the 65% level / mediumThresh80 = 13 //The number of boxes at the 80% level / hardThresh95 = 15 //The number of boxes at the 95% level // From here -- may have to be specified globally to be used in other places // Total number of boxes clicked in box_clicking / box_clicking_boxesChecked = -1 / YOU_reward = 0 / OTHER_reward = 0 / choice_made = 0 / choice_not_made = 0 / obtained_reward = 0 // From here -- specific to social_effort_box_click_task.iqx //Color of trial type -- in fact, red (YOU) or blue (OTHER) / c_colorname = black //Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward / eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST // Position of the two choices / effortX = 0% / restX = 0% // Trial type / trialType = null // Strings to be displayed at every trial / centerLabel = null // will be either YOU or OTHER / effortCredits = 0 / effortBoxes = 0 </values> <parameters> // //These are the rewards (fixed for all participants) / low_pay = 2 //Low reward / medium_pay = 6 //Medium reward / high_pay = 10 //High reward / num_trials = 24 // total number of trials </parameters> // data to be saved in summary file -- CONSIDER ADDING ITEMS in the future <summarydata> /columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.YOU_reward, values.OTHER_reward, values.choice_made, values.choice_not_made) </summarydata> // data to be saved in raw data file <data> /columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode, pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked, values.effortBoxes, values.effortCredits, values.obtained_reward, values.effortX) </data> // These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring! <checkboxes row1> / caption=" " / options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") / optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row2> / caption=" " / options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20") / optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row3> / caption=" " / options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30") / optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row4> / caption=" " / options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40") / optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row5> / caption=" " / options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50") / optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50") / required = true / orientation = horizontalequal </checkboxes> <surveypage box_clicking> / onTrialBegin = [ values.box_clicking_boxesChecked = -1 ] / onTrialEnd = [ values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount; ] /caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes" /questions = [1-5=sequence(row1, row2, row3, row4, row5)] / itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1) / itemspacing = 0.0% / showpagenumbers = false / showbackbutton = false / showquestionnumbers = false / responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1) / timeout = 10000 // 10 seconds / showNextButton = false </surveypage> <block SocialEffort_Block> / onBlockBegin = [ // Randomized trial type order -- 24 trials list.trialTypeList.appendItem(list.trialType.nextValue); //1 list.trialTypeList.appendItem(list.trialType.nextValue); //2 list.trialTypeList.appendItem(list.trialType.nextValue); //3 list.trialTypeList.appendItem(list.trialType.nextValue); //4 list.trialTypeList.appendItem(list.trialType.nextValue); //5 list.trialTypeList.appendItem(list.trialType.nextValue); //6 list.trialTypeList.appendItem(list.trialType.nextValue); //7 list.trialTypeList.appendItem(list.trialType.nextValue); //8 list.trialTypeList.appendItem(list.trialType.nextValue); //9 list.trialTypeList.appendItem(list.trialType.nextValue); //10 list.trialTypeList.appendItem(list.trialType.nextValue); //11 list.trialTypeList.appendItem(list.trialType.nextValue); //12 list.trialTypeList.appendItem(list.trialType.nextValue); //13 list.trialTypeList.appendItem(list.trialType.nextValue); //14 list.trialTypeList.appendItem(list.trialType.nextValue); //15 list.trialTypeList.appendItem(list.trialType.nextValue); //16 list.trialTypeList.appendItem(list.trialType.nextValue); //17 list.trialTypeList.appendItem(list.trialType.nextValue); //18 list.trialTypeList.appendItem(list.trialType.nextValue); //19 list.trialTypeList.appendItem(list.trialType.nextValue); //20 list.trialTypeList.appendItem(list.trialType.nextValue); //21 list.trialTypeList.appendItem(list.trialType.nextValue); //22 list.trialTypeList.appendItem(list.trialType.nextValue); //23 list.trialTypeList.appendItem(list.trialType.nextValue); //24 // Randomized YOU effort-reward 12 pairs list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12 // Randomized OTHER effort-reward 12 pairs list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12 ] // trials = [1-parameters.num_trials = BoxClick_Trial] / trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually.... // trials = [1-24 = Full_Trial] // ATTENTION: defining the number of trials manually.... </block> <trial BoxClick_Trial> / onTrialBegin = [ // pick random postion for effort_option values.effortX = list.x.nextValue; // pick position for rest_option values.restX = list.x.nextValue; // set trial type values.trialType = list.trialTypeList.nextValue; // set center label according to trial type if (values.trialType == "YOU") { values.c_colorname = red; values.eff_rew = list.YOU_eff_rewList.nextValue; } else { // OTHER values.c_colorname = blue; values.eff_rew = list.OTHER_eff_rewList.nextValue; } // set winnings and effort according to the value in eff_rew if (values.eff_rew == "e1_r1") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e1_r2") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e1_r3") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e2_r1") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e2_r2") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e2_r3") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e3_r1") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e3_r2") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e3_r3") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e4_r1") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e4_r2") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e4_r3") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.high_pay; } // Reset the variable box_clicking_boxesChecked values.box_clicking_boxesChecked = -1; ] / stimulusframes = [1=effort_option, rest_option, center_label] / inputdevice = mouse / validresponse = (effort_option, rest_option) / timeout = 4000 // participant must make a choice in 4000 ms / branch = [ if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option // run the clicking box survey return surveyPage.box_clicking; // otherwise, update the rewards (rest option) --> display feedback } else if (trial.BoxClick_Trial.response=="rest_option"){ // chose the rest option -- assuming that rest option's reward is 1 values.choice_made = values.choice_made + 1; values.obtained_reward = 1; if (values.trialType == "YOU") { values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_YOU; } else { values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_OTHER; } } else { // or perhaps, participant did not make a choice in time --> display feedback values.choice_not_made = values.choice_not_made + 1; values.obtained_reward = 0; if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { return trial.show_box_clicking_feedback_OTHER; } } ] / onTrialend = [ // update the rewards after surveypage.box_clicking (e.g., if participant chose the effortful option) if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option values.choice_made = values.choice_made + 1; if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task values.obtained_reward = values.effortCredits; if (values.trialType == "YOU") { // add the reward to YOU_reward values.YOU_reward = values.YOU_reward + values.effortCredits; //return trial.show_box_clicking_feedback_YOU; } else { // add the reward to OTHER_reward values.OTHER_reward = values.OTHER_reward + values.effortCredits; //return trial.show_box_clicking_feedback_OTHER; } } else { values.obtained_reward = 0; //if (values.trialType == "YOU") { //return trial.show_box_clicking_feedback_YOU; //} else { //return trial.show_box_clicking_feedback_OTHER; //} } } ] </trial> // show the obtained number of credits after each trial // CURRENTLY NOT USED <trial Show_Feedback> /timeout = 2000 /branch = [ if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { // "OTHER" return trial.show_box_clicking_feedback_OTHER; } ] </trial> <text box_clicking_feedback_YOU> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = red//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_YOU> /stimulusTimes = [0=box_clicking_feedback_YOU] /timeout = 2000 // displays the message for 2 seconds </trial> <text box_clicking_feedback_OTHER> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = blue//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_OTHER> /stimulusTimes = [0=box_clicking_feedback_OTHER] /timeout = 2000 // displays the message for 2 seconds </trial> // Block containing one full trial -- BoxClick_Trial --> Show_Feedback //<block Full_Trial> /// trials = [1=BoxClick_Trial; 2=Show_Feedback] //</block> //<page feedback> //^<%values.trialType%> //^<%values.obtained_reward%> //</page> // Stores the order of the 24 trial types -- YOU or OTHER <list trialTypeList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials <list YOU_eff_rewList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials <list OTHER_eff_rewList> / selectionMode = sequence </list> <text effort_option> / items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes") / hPosition = values.effortX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text rest_option> / items = ("1 credit for Rest") / hPosition = values.restX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text center_label> / items = ("<%values.trialType%>") // this is the label that should be used in the exp! // items = ("<%values.eff_rew%>") // testing the list selection! / position = (50%, 30%) / txColor = values.c_colorname / fontStyle = ("arial", 16pt, true) </text> <list trialType> / items = ("YOU", "OTHER") / poolsize = parameters.num_trials / selectionmode = random / selectionrate = always </list> // This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials // It will be used to to sample --once-- all the 12 combinations <list eff_rew_YOU> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> // Likewise for the OTHER trials <list eff_rew_OTHER> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> <list x> / items = (35%, 65%) / selectionrate = always </list> The /branch obviously ought to be in the <surveyPage>. Once the <trial> has /branches to the <surveypage>, the <trial> is over. It cannot then somehow /branch to yet another thing after the <surveypage>. The <surveypage> has to /branch. Moving things around between /onTrialEnd and /barnch will not change a thing about this. /onTrialEnd attributes are for executing logic (performing calculations, etc.) at the end of a trial. They are executed in the order given top to bottom. You cannot "return" a trial from /onTrialEnd, that is not what it's for. /branch is for dynamically deciding where to go next after the trial. Thanks, Dave! However, if I want to provide feedback _after_ participants have completed the <surveypage> AND customize the feedback according to the responses given by participants in the <surveypage>, I thought I would have to add that "logic" in the /onTrialEnd of the <surveypage>, which would not work either, no? I don't see how using /branch inside the <surveypage> could help... Could you provide an example where (1) responses are given to a <surveypage> , and (2) feedback is displayed on screen depending on the responses given in the <surveypage> (in my code, that is in effect the number of boxes that were clicked by the participant)? Thanks in advance! EN Why do you think that would not wokr? It's really not complicated. Of course you can have /onTrialEnd logic in a <surveyPage> that counts up how many boxes where check and then display that in a feedback trial after. <values> / feedBackMessage = null </values>
<block taskBlock> / trials = [1-4 = choiceTrial] </block>
<trial choiceTrial> / stimulusFrames = [1=clearScreen,doSomething, doNothing] / inputDevice = mouse / validResponse = (doSomething,doNothing) / branch = [ if (trial.choiceTrial.response == "doNothing") { values.feedBackMessage = "You did nothing."; return trial.feedBackTrial; } else { return surveyPage.checkSomeBoxes; } ] </trial>
<trial feedBackTrial> / stimulusFrames = [1=clearScreen, feedBackText] / validResponse = (0) / trialDuration = 2000 </trial>
<surveypage checkSomeBoxes> / questions = [1=checkMe] / showNextButton = false / showPageNumbers = false / showQuestionNumbers = false / timeout = 5000 / branch = [ values.feedBackMessage = concat("Number of boxes checked: ", checkBoxes.checkMe.selectedCount); return trial.feedBackTrial; ] </surveypage>
<checkBoxes checkMe> / options = ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10") / orientation = horizontalequal </checkboxes>
<text doSomething> / items = ("I want to check some boxes.") / position = (25%, 65%) </text>
<text doNothing> / items = ("I'd rather do nothing.") / position = (75%, 65%) </text>
<text feedBackText> / items = ("<%values.feedBackMessage%>") </text>
Thanks, Dave! It is now very clear. One last question on this topic: am I correct to assume that /onTrialEnd is not executed if a 'return' inside a /branch is called? Best, EN
|
|
|
Dave
|
|
Group: Administrators
Posts: 13K,
Visits: 108K
|
+x+x+x+x+x+xHello: I wanted to provide feedback to participants immediately after a <trial> that has a /branch section within it. The /branch will--depending on the participant's response--call a <surveypage> using 'return' (I copied the current code below in case it's helpful -- the <trial> in case is BoxClick_Trial). To display the feedback after each <trial>, I thought about using additional 'return' commands inside the /onTrialEnd section. The idea was to use 'return' to call another <trial> (after updating some global variables) whose only job is to display a customized message on the screen. However, using 'return' inside the /onTrialEnd section does not seem to be allowed. After some fiddling, I decided to move portions of the code that were originally inside /onTrialEnd to inside the /branch, right after the conditional call to <surveypage>. However, and somehow expectedly in hindsight, because the flow of the program returns directly to /onTrialEnd after it is deviated by the /branch, I still have not found a way to display the feedback if the <surveypage> is called (if <surveypage> is _not called_, feedbacks are properly displayed by the code following the 'return' command in the /branch). I guess this is a fairly common case but I wonder what would be the best way to handle it? Any help would be greatly appreciated! With very best wishes, EN -- // Global variables -- some of these variables should be re-defined in emot_induction.iqx <values> //Thresholds specified by the procedure defined in calibration_time_boxcount.iqx // Here defined only for testing purposes / easyThresh50 = 8 //The number of boxes at the 50% level / mediumThresh65 = 10 //The number of boxes at the 65% level / mediumThresh80 = 13 //The number of boxes at the 80% level / hardThresh95 = 15 //The number of boxes at the 95% level // From here -- may have to be specified globally to be used in other places // Total number of boxes clicked in box_clicking / box_clicking_boxesChecked = -1 / YOU_reward = 0 / OTHER_reward = 0 / choice_made = 0 / choice_not_made = 0 / obtained_reward = 0 // From here -- specific to social_effort_box_click_task.iqx //Color of trial type -- in fact, red (YOU) or blue (OTHER) / c_colorname = black //Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward / eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST // Position of the two choices / effortX = 0% / restX = 0% // Trial type / trialType = null // Strings to be displayed at every trial / centerLabel = null // will be either YOU or OTHER / effortCredits = 0 / effortBoxes = 0 </values> <parameters> // //These are the rewards (fixed for all participants) / low_pay = 2 //Low reward / medium_pay = 6 //Medium reward / high_pay = 10 //High reward / num_trials = 24 // total number of trials </parameters> // data to be saved in summary file -- CONSIDER ADDING ITEMS in the future <summarydata> /columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.YOU_reward, values.OTHER_reward, values.choice_made, values.choice_not_made) </summarydata> // data to be saved in raw data file <data> /columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode, pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked, values.effortBoxes, values.effortCredits, values.obtained_reward, values.effortX) </data> // These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring! <checkboxes row1> / caption=" " / options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") / optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row2> / caption=" " / options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20") / optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row3> / caption=" " / options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30") / optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row4> / caption=" " / options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40") / optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row5> / caption=" " / options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50") / optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50") / required = true / orientation = horizontalequal </checkboxes> <surveypage box_clicking> / onTrialBegin = [ values.box_clicking_boxesChecked = -1 ] / onTrialEnd = [ values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount; ] /caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes" /questions = [1-5=sequence(row1, row2, row3, row4, row5)] / itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1) / itemspacing = 0.0% / showpagenumbers = false / showbackbutton = false / showquestionnumbers = false / responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1) / timeout = 10000 // 10 seconds / showNextButton = false </surveypage> <block SocialEffort_Block> / onBlockBegin = [ // Randomized trial type order -- 24 trials list.trialTypeList.appendItem(list.trialType.nextValue); //1 list.trialTypeList.appendItem(list.trialType.nextValue); //2 list.trialTypeList.appendItem(list.trialType.nextValue); //3 list.trialTypeList.appendItem(list.trialType.nextValue); //4 list.trialTypeList.appendItem(list.trialType.nextValue); //5 list.trialTypeList.appendItem(list.trialType.nextValue); //6 list.trialTypeList.appendItem(list.trialType.nextValue); //7 list.trialTypeList.appendItem(list.trialType.nextValue); //8 list.trialTypeList.appendItem(list.trialType.nextValue); //9 list.trialTypeList.appendItem(list.trialType.nextValue); //10 list.trialTypeList.appendItem(list.trialType.nextValue); //11 list.trialTypeList.appendItem(list.trialType.nextValue); //12 list.trialTypeList.appendItem(list.trialType.nextValue); //13 list.trialTypeList.appendItem(list.trialType.nextValue); //14 list.trialTypeList.appendItem(list.trialType.nextValue); //15 list.trialTypeList.appendItem(list.trialType.nextValue); //16 list.trialTypeList.appendItem(list.trialType.nextValue); //17 list.trialTypeList.appendItem(list.trialType.nextValue); //18 list.trialTypeList.appendItem(list.trialType.nextValue); //19 list.trialTypeList.appendItem(list.trialType.nextValue); //20 list.trialTypeList.appendItem(list.trialType.nextValue); //21 list.trialTypeList.appendItem(list.trialType.nextValue); //22 list.trialTypeList.appendItem(list.trialType.nextValue); //23 list.trialTypeList.appendItem(list.trialType.nextValue); //24 // Randomized YOU effort-reward 12 pairs list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12 // Randomized OTHER effort-reward 12 pairs list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12 ] // trials = [1-parameters.num_trials = BoxClick_Trial] / trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually.... // trials = [1-24 = Full_Trial] // ATTENTION: defining the number of trials manually.... </block> <trial BoxClick_Trial> / onTrialBegin = [ // pick random postion for effort_option values.effortX = list.x.nextValue; // pick position for rest_option values.restX = list.x.nextValue; // set trial type values.trialType = list.trialTypeList.nextValue; // set center label according to trial type if (values.trialType == "YOU") { values.c_colorname = red; values.eff_rew = list.YOU_eff_rewList.nextValue; } else { // OTHER values.c_colorname = blue; values.eff_rew = list.OTHER_eff_rewList.nextValue; } // set winnings and effort according to the value in eff_rew if (values.eff_rew == "e1_r1") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e1_r2") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e1_r3") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e2_r1") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e2_r2") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e2_r3") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e3_r1") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e3_r2") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e3_r3") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e4_r1") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e4_r2") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e4_r3") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.high_pay; } // Reset the variable box_clicking_boxesChecked values.box_clicking_boxesChecked = -1; ] / stimulusframes = [1=effort_option, rest_option, center_label] / inputdevice = mouse / validresponse = (effort_option, rest_option) / timeout = 4000 // participant must make a choice in 4000 ms / branch = [ if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option // run the clicking box survey return surveyPage.box_clicking; // otherwise, update the rewards (rest option) --> display feedback } else if (trial.BoxClick_Trial.response=="rest_option"){ // chose the rest option -- assuming that rest option's reward is 1 values.choice_made = values.choice_made + 1; values.obtained_reward = 1; if (values.trialType == "YOU") { values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_YOU; } else { values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_OTHER; } } else { // or perhaps, participant did not make a choice in time --> display feedback values.choice_not_made = values.choice_not_made + 1; values.obtained_reward = 0; if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { return trial.show_box_clicking_feedback_OTHER; } } ] / onTrialend = [ // update the rewards after surveypage.box_clicking (e.g., if participant chose the effortful option) if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option values.choice_made = values.choice_made + 1; if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task values.obtained_reward = values.effortCredits; if (values.trialType == "YOU") { // add the reward to YOU_reward values.YOU_reward = values.YOU_reward + values.effortCredits; //return trial.show_box_clicking_feedback_YOU; } else { // add the reward to OTHER_reward values.OTHER_reward = values.OTHER_reward + values.effortCredits; //return trial.show_box_clicking_feedback_OTHER; } } else { values.obtained_reward = 0; //if (values.trialType == "YOU") { //return trial.show_box_clicking_feedback_YOU; //} else { //return trial.show_box_clicking_feedback_OTHER; //} } } ] </trial> // show the obtained number of credits after each trial // CURRENTLY NOT USED <trial Show_Feedback> /timeout = 2000 /branch = [ if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { // "OTHER" return trial.show_box_clicking_feedback_OTHER; } ] </trial> <text box_clicking_feedback_YOU> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = red//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_YOU> /stimulusTimes = [0=box_clicking_feedback_YOU] /timeout = 2000 // displays the message for 2 seconds </trial> <text box_clicking_feedback_OTHER> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = blue//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_OTHER> /stimulusTimes = [0=box_clicking_feedback_OTHER] /timeout = 2000 // displays the message for 2 seconds </trial> // Block containing one full trial -- BoxClick_Trial --> Show_Feedback //<block Full_Trial> /// trials = [1=BoxClick_Trial; 2=Show_Feedback] //</block> //<page feedback> //^<%values.trialType%> //^<%values.obtained_reward%> //</page> // Stores the order of the 24 trial types -- YOU or OTHER <list trialTypeList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials <list YOU_eff_rewList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials <list OTHER_eff_rewList> / selectionMode = sequence </list> <text effort_option> / items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes") / hPosition = values.effortX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text rest_option> / items = ("1 credit for Rest") / hPosition = values.restX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text center_label> / items = ("<%values.trialType%>") // this is the label that should be used in the exp! // items = ("<%values.eff_rew%>") // testing the list selection! / position = (50%, 30%) / txColor = values.c_colorname / fontStyle = ("arial", 16pt, true) </text> <list trialType> / items = ("YOU", "OTHER") / poolsize = parameters.num_trials / selectionmode = random / selectionrate = always </list> // This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials // It will be used to to sample --once-- all the 12 combinations <list eff_rew_YOU> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> // Likewise for the OTHER trials <list eff_rew_OTHER> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> <list x> / items = (35%, 65%) / selectionrate = always </list> The /branch obviously ought to be in the <surveyPage>. Once the <trial> has /branches to the <surveypage>, the <trial> is over. It cannot then somehow /branch to yet another thing after the <surveypage>. The <surveypage> has to /branch. Moving things around between /onTrialEnd and /barnch will not change a thing about this. /onTrialEnd attributes are for executing logic (performing calculations, etc.) at the end of a trial. They are executed in the order given top to bottom. You cannot "return" a trial from /onTrialEnd, that is not what it's for. /branch is for dynamically deciding where to go next after the trial. Thanks, Dave! However, if I want to provide feedback _after_ participants have completed the <surveypage> AND customize the feedback according to the responses given by participants in the <surveypage>, I thought I would have to add that "logic" in the /onTrialEnd of the <surveypage>, which would not work either, no? I don't see how using /branch inside the <surveypage> could help... Could you provide an example where (1) responses are given to a <surveypage> , and (2) feedback is displayed on screen depending on the responses given in the <surveypage> (in my code, that is in effect the number of boxes that were clicked by the participant)? Thanks in advance! EN Why do you think that would not wokr? It's really not complicated. Of course you can have /onTrialEnd logic in a <surveyPage> that counts up how many boxes where check and then display that in a feedback trial after. <values> / feedBackMessage = null </values>
<block taskBlock> / trials = [1-4 = choiceTrial] </block>
<trial choiceTrial> / stimulusFrames = [1=clearScreen,doSomething, doNothing] / inputDevice = mouse / validResponse = (doSomething,doNothing) / branch = [ if (trial.choiceTrial.response == "doNothing") { values.feedBackMessage = "You did nothing."; return trial.feedBackTrial; } else { return surveyPage.checkSomeBoxes; } ] </trial>
<trial feedBackTrial> / stimulusFrames = [1=clearScreen, feedBackText] / validResponse = (0) / trialDuration = 2000 </trial>
<surveypage checkSomeBoxes> / questions = [1=checkMe] / showNextButton = false / showPageNumbers = false / showQuestionNumbers = false / timeout = 5000 / branch = [ values.feedBackMessage = concat("Number of boxes checked: ", checkBoxes.checkMe.selectedCount); return trial.feedBackTrial; ] </surveypage>
<checkBoxes checkMe> / options = ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10") / orientation = horizontalequal </checkboxes>
<text doSomething> / items = ("I want to check some boxes.") / position = (25%, 65%) </text>
<text doNothing> / items = ("I'd rather do nothing.") / position = (75%, 65%) </text>
<text feedBackText> / items = ("<%values.feedBackMessage%>") </text>
Thanks, Dave! It is now very clear. One last question on this topic: am I correct to assume that /onTrialEnd is not executed if a 'return' inside a /branch is called? Best, EN No, you are not correct. /onTrialEnd attributes are executed top to bottom in the order given. This happens before any /branch attributes are executed. They are different attributes serving different purposes.
|
|
|
EN
|
|
Group: Forum Members
Posts: 42,
Visits: 211
|
+x+x+x+x+x+x+xHello: I wanted to provide feedback to participants immediately after a <trial> that has a /branch section within it. The /branch will--depending on the participant's response--call a <surveypage> using 'return' (I copied the current code below in case it's helpful -- the <trial> in case is BoxClick_Trial). To display the feedback after each <trial>, I thought about using additional 'return' commands inside the /onTrialEnd section. The idea was to use 'return' to call another <trial> (after updating some global variables) whose only job is to display a customized message on the screen. However, using 'return' inside the /onTrialEnd section does not seem to be allowed. After some fiddling, I decided to move portions of the code that were originally inside /onTrialEnd to inside the /branch, right after the conditional call to <surveypage>. However, and somehow expectedly in hindsight, because the flow of the program returns directly to /onTrialEnd after it is deviated by the /branch, I still have not found a way to display the feedback if the <surveypage> is called (if <surveypage> is _not called_, feedbacks are properly displayed by the code following the 'return' command in the /branch). I guess this is a fairly common case but I wonder what would be the best way to handle it? Any help would be greatly appreciated! With very best wishes, EN -- // Global variables -- some of these variables should be re-defined in emot_induction.iqx <values> //Thresholds specified by the procedure defined in calibration_time_boxcount.iqx // Here defined only for testing purposes / easyThresh50 = 8 //The number of boxes at the 50% level / mediumThresh65 = 10 //The number of boxes at the 65% level / mediumThresh80 = 13 //The number of boxes at the 80% level / hardThresh95 = 15 //The number of boxes at the 95% level // From here -- may have to be specified globally to be used in other places // Total number of boxes clicked in box_clicking / box_clicking_boxesChecked = -1 / YOU_reward = 0 / OTHER_reward = 0 / choice_made = 0 / choice_not_made = 0 / obtained_reward = 0 // From here -- specific to social_effort_box_click_task.iqx //Color of trial type -- in fact, red (YOU) or blue (OTHER) / c_colorname = black //Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward / eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST // Position of the two choices / effortX = 0% / restX = 0% // Trial type / trialType = null // Strings to be displayed at every trial / centerLabel = null // will be either YOU or OTHER / effortCredits = 0 / effortBoxes = 0 </values> <parameters> // //These are the rewards (fixed for all participants) / low_pay = 2 //Low reward / medium_pay = 6 //Medium reward / high_pay = 10 //High reward / num_trials = 24 // total number of trials </parameters> // data to be saved in summary file -- CONSIDER ADDING ITEMS in the future <summarydata> /columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.YOU_reward, values.OTHER_reward, values.choice_made, values.choice_not_made) </summarydata> // data to be saved in raw data file <data> /columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode, pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked, values.effortBoxes, values.effortCredits, values.obtained_reward, values.effortX) </data> // These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring! <checkboxes row1> / caption=" " / options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") / optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row2> / caption=" " / options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20") / optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row3> / caption=" " / options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30") / optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row4> / caption=" " / options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40") / optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40") / required = true / orientation = horizontalequal </checkboxes> <checkboxes row5> / caption=" " / options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50") / optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50") / required = true / orientation = horizontalequal </checkboxes> <surveypage box_clicking> / onTrialBegin = [ values.box_clicking_boxesChecked = -1 ] / onTrialEnd = [ values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount; ] /caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes" /questions = [1-5=sequence(row1, row2, row3, row4, row5)] / itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1) / itemspacing = 0.0% / showpagenumbers = false / showbackbutton = false / showquestionnumbers = false / responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1) / timeout = 10000 // 10 seconds / showNextButton = false </surveypage> <block SocialEffort_Block> / onBlockBegin = [ // Randomized trial type order -- 24 trials list.trialTypeList.appendItem(list.trialType.nextValue); //1 list.trialTypeList.appendItem(list.trialType.nextValue); //2 list.trialTypeList.appendItem(list.trialType.nextValue); //3 list.trialTypeList.appendItem(list.trialType.nextValue); //4 list.trialTypeList.appendItem(list.trialType.nextValue); //5 list.trialTypeList.appendItem(list.trialType.nextValue); //6 list.trialTypeList.appendItem(list.trialType.nextValue); //7 list.trialTypeList.appendItem(list.trialType.nextValue); //8 list.trialTypeList.appendItem(list.trialType.nextValue); //9 list.trialTypeList.appendItem(list.trialType.nextValue); //10 list.trialTypeList.appendItem(list.trialType.nextValue); //11 list.trialTypeList.appendItem(list.trialType.nextValue); //12 list.trialTypeList.appendItem(list.trialType.nextValue); //13 list.trialTypeList.appendItem(list.trialType.nextValue); //14 list.trialTypeList.appendItem(list.trialType.nextValue); //15 list.trialTypeList.appendItem(list.trialType.nextValue); //16 list.trialTypeList.appendItem(list.trialType.nextValue); //17 list.trialTypeList.appendItem(list.trialType.nextValue); //18 list.trialTypeList.appendItem(list.trialType.nextValue); //19 list.trialTypeList.appendItem(list.trialType.nextValue); //20 list.trialTypeList.appendItem(list.trialType.nextValue); //21 list.trialTypeList.appendItem(list.trialType.nextValue); //22 list.trialTypeList.appendItem(list.trialType.nextValue); //23 list.trialTypeList.appendItem(list.trialType.nextValue); //24 // Randomized YOU effort-reward 12 pairs list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11 list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12 // Randomized OTHER effort-reward 12 pairs list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11 list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12 ] // trials = [1-parameters.num_trials = BoxClick_Trial] / trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually.... // trials = [1-24 = Full_Trial] // ATTENTION: defining the number of trials manually.... </block> <trial BoxClick_Trial> / onTrialBegin = [ // pick random postion for effort_option values.effortX = list.x.nextValue; // pick position for rest_option values.restX = list.x.nextValue; // set trial type values.trialType = list.trialTypeList.nextValue; // set center label according to trial type if (values.trialType == "YOU") { values.c_colorname = red; values.eff_rew = list.YOU_eff_rewList.nextValue; } else { // OTHER values.c_colorname = blue; values.eff_rew = list.OTHER_eff_rewList.nextValue; } // set winnings and effort according to the value in eff_rew if (values.eff_rew == "e1_r1") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e1_r2") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e1_r3") { values.effortBoxes = values.easyThresh50; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e2_r1") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e2_r2") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e2_r3") { values.effortBoxes = values.mediumThresh65; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e3_r1") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e3_r2") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e3_r3") { values.effortBoxes = values.mediumThresh80; values.effortCredits = parameters.high_pay; } else if (values.eff_rew == "e4_r1") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.low_pay; } else if (values.eff_rew == "e4_r2") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.medium_pay; } else if (values.eff_rew == "e4_r3") { values.effortBoxes = values.hardThresh95; values.effortCredits = parameters.high_pay; } // Reset the variable box_clicking_boxesChecked values.box_clicking_boxesChecked = -1; ] / stimulusframes = [1=effort_option, rest_option, center_label] / inputdevice = mouse / validresponse = (effort_option, rest_option) / timeout = 4000 // participant must make a choice in 4000 ms / branch = [ if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option // run the clicking box survey return surveyPage.box_clicking; // otherwise, update the rewards (rest option) --> display feedback } else if (trial.BoxClick_Trial.response=="rest_option"){ // chose the rest option -- assuming that rest option's reward is 1 values.choice_made = values.choice_made + 1; values.obtained_reward = 1; if (values.trialType == "YOU") { values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_YOU; } else { values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1 return trial.show_box_clicking_feedback_OTHER; } } else { // or perhaps, participant did not make a choice in time --> display feedback values.choice_not_made = values.choice_not_made + 1; values.obtained_reward = 0; if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { return trial.show_box_clicking_feedback_OTHER; } } ] / onTrialend = [ // update the rewards after surveypage.box_clicking (e.g., if participant chose the effortful option) if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option values.choice_made = values.choice_made + 1; if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task values.obtained_reward = values.effortCredits; if (values.trialType == "YOU") { // add the reward to YOU_reward values.YOU_reward = values.YOU_reward + values.effortCredits; //return trial.show_box_clicking_feedback_YOU; } else { // add the reward to OTHER_reward values.OTHER_reward = values.OTHER_reward + values.effortCredits; //return trial.show_box_clicking_feedback_OTHER; } } else { values.obtained_reward = 0; //if (values.trialType == "YOU") { //return trial.show_box_clicking_feedback_YOU; //} else { //return trial.show_box_clicking_feedback_OTHER; //} } } ] </trial> // show the obtained number of credits after each trial // CURRENTLY NOT USED <trial Show_Feedback> /timeout = 2000 /branch = [ if (values.trialType == "YOU") { return trial.show_box_clicking_feedback_YOU; } else { // "OTHER" return trial.show_box_clicking_feedback_OTHER; } ] </trial> <text box_clicking_feedback_YOU> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = red//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_YOU> /stimulusTimes = [0=box_clicking_feedback_YOU] /timeout = 2000 // displays the message for 2 seconds </trial> <text box_clicking_feedback_OTHER> /items = ("<%values.trialType%> earned <%values.obtained_reward%> credits") /txcolor = blue//(0, 0, 0) /fontstyle = ("Arial", 2%, false, false, false, false, 5, 0) /position = (50%, 40%) </text> <trial show_box_clicking_feedback_OTHER> /stimulusTimes = [0=box_clicking_feedback_OTHER] /timeout = 2000 // displays the message for 2 seconds </trial> // Block containing one full trial -- BoxClick_Trial --> Show_Feedback //<block Full_Trial> /// trials = [1=BoxClick_Trial; 2=Show_Feedback] //</block> //<page feedback> //^<%values.trialType%> //^<%values.obtained_reward%> //</page> // Stores the order of the 24 trial types -- YOU or OTHER <list trialTypeList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials <list YOU_eff_rewList> / selectionMode = sequence </list> // Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials <list OTHER_eff_rewList> / selectionMode = sequence </list> <text effort_option> / items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes") / hPosition = values.effortX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text rest_option> / items = ("1 credit for Rest") / hPosition = values.restX / vPosition = 40% / fontStyle = ("arial", 12pt) / size = (15%, 10%) / vJustify = center / txBGColor = lightGray </text> <text center_label> / items = ("<%values.trialType%>") // this is the label that should be used in the exp! // items = ("<%values.eff_rew%>") // testing the list selection! / position = (50%, 30%) / txColor = values.c_colorname / fontStyle = ("arial", 16pt, true) </text> <list trialType> / items = ("YOU", "OTHER") / poolsize = parameters.num_trials / selectionmode = random / selectionrate = always </list> // This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials // It will be used to to sample --once-- all the 12 combinations <list eff_rew_YOU> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> // Likewise for the OTHER trials <list eff_rew_OTHER> / items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3") / poolsize = parameters.num_trials/2 / replace = false / selectionmode = random / selectionrate = always </list> <list x> / items = (35%, 65%) / selectionrate = always </list> The /branch obviously ought to be in the <surveyPage>. Once the <trial> has /branches to the <surveypage>, the <trial> is over. It cannot then somehow /branch to yet another thing after the <surveypage>. The <surveypage> has to /branch. Moving things around between /onTrialEnd and /barnch will not change a thing about this. /onTrialEnd attributes are for executing logic (performing calculations, etc.) at the end of a trial. They are executed in the order given top to bottom. You cannot "return" a trial from /onTrialEnd, that is not what it's for. /branch is for dynamically deciding where to go next after the trial. Thanks, Dave! However, if I want to provide feedback _after_ participants have completed the <surveypage> AND customize the feedback according to the responses given by participants in the <surveypage>, I thought I would have to add that "logic" in the /onTrialEnd of the <surveypage>, which would not work either, no? I don't see how using /branch inside the <surveypage> could help... Could you provide an example where (1) responses are given to a <surveypage> , and (2) feedback is displayed on screen depending on the responses given in the <surveypage> (in my code, that is in effect the number of boxes that were clicked by the participant)? Thanks in advance! EN Why do you think that would not wokr? It's really not complicated. Of course you can have /onTrialEnd logic in a <surveyPage> that counts up how many boxes where check and then display that in a feedback trial after. <values> / feedBackMessage = null </values>
<block taskBlock> / trials = [1-4 = choiceTrial] </block>
<trial choiceTrial> / stimulusFrames = [1=clearScreen,doSomething, doNothing] / inputDevice = mouse / validResponse = (doSomething,doNothing) / branch = [ if (trial.choiceTrial.response == "doNothing") { values.feedBackMessage = "You did nothing."; return trial.feedBackTrial; } else { return surveyPage.checkSomeBoxes; } ] </trial>
<trial feedBackTrial> / stimulusFrames = [1=clearScreen, feedBackText] / validResponse = (0) / trialDuration = 2000 </trial>
<surveypage checkSomeBoxes> / questions = [1=checkMe] / showNextButton = false / showPageNumbers = false / showQuestionNumbers = false / timeout = 5000 / branch = [ values.feedBackMessage = concat("Number of boxes checked: ", checkBoxes.checkMe.selectedCount); return trial.feedBackTrial; ] </surveypage>
<checkBoxes checkMe> / options = ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10") / orientation = horizontalequal </checkboxes>
<text doSomething> / items = ("I want to check some boxes.") / position = (25%, 65%) </text>
<text doNothing> / items = ("I'd rather do nothing.") / position = (75%, 65%) </text>
<text feedBackText> / items = ("<%values.feedBackMessage%>") </text>
Thanks, Dave! It is now very clear. One last question on this topic: am I correct to assume that /onTrialEnd is not executed if a 'return' inside a /branch is called? Best, EN No, you are not correct. /onTrialEnd attributes are executed top to bottom in the order given. This happens before any /branch attributes are executed. They are different attributes serving different purposes. Thanks, Dave! I'm glad I asked, now it is very clear. Best wishes, EN
|
|
|