Group: Administrators
Posts: 13K,
Visits: 105K
|
+x+xHi-- I'm trying to add a back button for an experiment (NOT a survey page) in order to go back to a previous trial. I generally know how to use conditional logic -- the only problem is that the trials are randomized, so it's not entirely clear which trial to display. The relevant part of the experiment is set up as follows: 3 randomized trials: <block similar> /trials = [1-3 = noreplace(6_by_2, 10_by_2, 12_by_2)] </block> I'd like to add conditional branching to each of these trials (6_by_2, 10_by_2, 12_by_2) if the back button is pressed, but I don't know how to do this given that *which* trial is the previous trial will depend on how randomization works. Thanks in advance for any help! Before anyone can propose any answer, you need to spell out what's supposed to happen after someone went back to the previous trial. Suppose the random order is 10_by_2 -> 6_by_2 -> 12_by_2 and then you go back from 12_by_2 to 6_by_2. What happens after that second instance of 6_by_2 then? Another instance of 12_by_2? Nothing? Another random trial? Meanwhile here's an example based on guesswork. Even if that's not how you want things to work, you may be able to adapt it. <values> / currenttrialnumber = 0 / nexttrialnumber = 0 / loopcount = 0 </values>
<block example> / stop = [ // stop once we've finished all trials values.nexttrialnumber > list.trialsequence.itemcount; ] / onblockbegin = [ // generate a random trial sequence while (values.loopcount < list.trials.itemcount) { list.trialsequence.appenditem(list.trials.nextvalue); values.loopcount += 1; }; values.nexttrialnumber = 1; ] / trials = [1=list.trialsequence] </block>
<list trials> / items = (trial.6_by_2, trial.10_by_2, trial.12_by_2) / selectionmode = random / selectionrate = always </list>
<list trialsequence> / select = values.nexttrialnumber </list>
<trial 6_by_2> / ontrialbegin = [ values.currenttrialnumber = values.nexttrialnumber; trial.6_by_2.resetstimulusframes(); // no back button in the 1st trial if (values.currenttrialnumber > 1){ trial.6_by_2.insertstimulusframe(button.backbutton, 1); }; ] / ontrialend = [ if (trial.6_by_2.response == "backbutton") { values.nexttrialnumber -= 1; } else { values.nexttrialnumber += 1; }; // can't go below trial number 1 values.nexttrialnumber = max(1, values.nexttrialnumber); ] / stimulusframes = [1=mytext, nextbutton] / inputdevice = mouse / validresponse = (nextbutton, backbutton) / branch = [ list.trialsequence.nextvalue; ] </trial>
<trial 10_by_2> / ontrialbegin = [ values.currenttrialnumber = values.nexttrialnumber; trial.10_by_2.resetstimulusframes(); // no back button in the 1st trial if (values.currenttrialnumber > 1){ trial.10_by_2.insertstimulusframe(button.backbutton, 1); }; ] / ontrialend = [ if (trial.10_by_2.response == "backbutton") { values.nexttrialnumber -= 1; } else { values.nexttrialnumber += 1; }; // can't go below trial number 1 values.nexttrialnumber = max(1, values.nexttrialnumber); ] / stimulusframes = [1=mytext, nextbutton] / inputdevice = mouse / validresponse = (nextbutton, backbutton) / branch = [ list.trialsequence.nextvalue; ] </trial>
<trial 12_by_2> / ontrialbegin = [ values.currenttrialnumber = values.nexttrialnumber; trial.12_by_2.resetstimulusframes(); // no back button in the 1st trial if (values.currenttrialnumber > 1){ trial.12_by_2.insertstimulusframe(button.backbutton, 1); }; ] / ontrialend = [ if (trial.12_by_2.response == "backbutton") { values.nexttrialnumber -= 1; } else { values.nexttrialnumber += 1; }; // can't go below trial number 1 values.nexttrialnumber = max(1, values.nexttrialnumber); ] / stimulusframes = [1=mytext, nextbutton] / inputdevice = mouse / validresponse = (nextbutton, backbutton) / branch = [ list.trialsequence.nextvalue; ] </trial>
<text mytext> / items = ("<%script.currenttrial%>") </text>
<button nextbutton> / caption = "Next >>" / size = (10%, 5%) / position = (90%, 90%) </button>
<button backbutton> / caption = "<< Back" / size = (10%, 5%) / position = (10%, 90%) </button>
|
Group: Administrators
Posts: 13K,
Visits: 105K
|
+xHi-- I'm trying to add a back button for an experiment (NOT a survey page) in order to go back to a previous trial. I generally know how to use conditional logic -- the only problem is that the trials are randomized, so it's not entirely clear which trial to display. The relevant part of the experiment is set up as follows: 3 randomized trials: <block similar> /trials = [1-3 = noreplace(6_by_2, 10_by_2, 12_by_2)] </block> I'd like to add conditional branching to each of these trials (6_by_2, 10_by_2, 12_by_2) if the back button is pressed, but I don't know how to do this given that *which* trial is the previous trial will depend on how randomization works. Thanks in advance for any help! Before anyone can propose any answer, you need to spell out what's supposed to happen after someone went back to the previous trial. Suppose the random order is 10_by_2 -> 6_by_2 -> 12_by_2 and then you go back from 12_by_2 to 6_by_2. What happens after that second instance of 6_by_2 then? Another instance of 12_by_2? Nothing? Another random trial?
|
Group: Forum Members
Posts: 39,
Visits: 108
|
Hi-- I'm trying to add a back button for an experiment (NOT a survey page) in order to go back to a previous trial. I generally know how to use conditional logic -- the only problem is that the trials are randomized, so it's not entirely clear which trial to display. The relevant part of the experiment is set up as follows:
3 randomized trials: <block similar> /trials = [1-3 = noreplace(6_by_2, 10_by_2, 12_by_2)] </block>
I'd like to add conditional branching to each of these trials (6_by_2, 10_by_2, 12_by_2) if the back button is pressed, but I don't know how to do this given that *which* trial is the previous trial will depend on how randomization works. Thanks in advance for any help!
|