Group: Forum Members
Posts: 41,
Visits: 207
|
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>
|