Can't set html items dynamically


Author
Message
AKrishna
AKrishna
Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)
Group: Forum Members
Posts: 119, Visits: 400
Hi all,

I'm currently working on an experiment which has a slightly challenging stimulus assignment rule for which I implemented a dynamic item selection. It's a little complicated, so bear with me briefly:

There is a block for older applicants and one for younger applicants consisting of four trial groups each, but with different assignment rules. We have 4 application forms for older applicants, each of which can be combined randomly with a picture of an attractive male/attractive female/unattractive male/unattractive female older applicant. We have 3 normal and 1 special application form for younger applicants, each of which can also be combined randomly with a picture of an attractive male/attractive female/unattractive male/unattractive female younger applicant, but of which the special form must always appear first in the block.

So far so good. For presentation reasons, the applications are split across two pages which are presented at the same time using <html> elements. So I have implemented a selection as follows (please ignore my weird element names, that's what I get for programming when tired):



## The items entered here are simply so that Inquisit doesn't throw an error when loading, they should be dynamically assigned later in the script (but aren't, which is the problem).
<html Lebenslauf>
/ items = ("JungHochattraktivWeiblich2.htm")
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = ("JungHochattraktivWeiblich2Anschreiben.htm")
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>

## This trial is silent and is only there to select the next stimuli to show.
## Depending on the runnig block, the script pulls the next condition from the relevant list without replacement.
## Then it writes a few values that code the current condition for use in the data element later on.
## Then it checks whether the running block is "old" or "young".
## If "old", it pulls a random application stimulus number from the "OldBewerbungen" list.
## If "young", it checks whether this is the first time the trial has run in the block; if so, it applies the special form, otherwise it pulls from the 3-element "YoungBewerbungen" list.
## It then concatenates the relevant elements to form the respective filenames for the html-files before passing on to the actual display trial.

<trial ShowMeJohnLaJoieprep>
/ trialduration = 0
/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialend = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

## This trial displays the htmls and allows participants to see them. In the experiment proper, it would then move onto likert elements that would ask questions about the stimuli.
<trial ShowMeJohnLaJoie>
/ stimulustimes = [0 = Lebenslauf, WriteyWriteyHaveABitey, PressSpace]
/ validresponse = (" ")
</trial>

<text PressSpace>
/ items = ("YoYo boyo, press dat space key")
/ position = (50,95)
/ fontstyle = ("Verdana", 2%, false, false, false, false, 5, 1)
</text>

<block Jung>
/ preinstructions = (young)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page young>
Sie beginnen nun mit Jung
</page>


<block Alt>
/ preinstructions = (old)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page OLD>
Sie beginnen nun mit Alt
</page>


<expt LaDeLa>
/ blocks = [1-2 = noreplace(Alt,Jung)]
</expt>

<list OLD>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<values>
/ Attractiveness = ""
/ Sex = ""
/ Condition = ""
/ CurrentLebenslauf = ""
/ CurrentAnschreiben = ""
</values>

<list OldBewerbungen>
/ items = (1,2,3,4)
</list>


<list YOUNG>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<list YoungBewerbungen>
/ items = (1,2,3)
</list>


So the code above should set the first (and only) item for each of the <html> elements to a specific filename before that element is loaded, thereby changing the displayed htm file each time. However, it doesn't - we only ever see the initial value.

Now, based on the concatenated strings that form the element names, I have tried the following to get the script to vary the htm files it displays:

1. Replacing the <html> elements as follows:

<html Lebenslauf>
/ items = ("<%values.CurrentLebenslauf%>")
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = ("<%values.CurrentAnschreiben%>")
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>


2. Using alternate code to replace the setitem lines above:

/ ontrialend = [html.Lebenslauf.item.1 = values.CurrentLebenslauf; html.WriteyWriteyHaveABitey.item.1 = values.CurrentAnschreiben]


Neither approach has worked. Approach 1 simply makes the html always show as the initial value of values.CurrentLebenslauf or values.CurrentAnschreiben respectively.

I checked and the current code does seem to change the item.1 property of the <html> elements, as if I have those displayed to me as a text, their values are as expected. It simply doesn't affect the file that is actually loaded.

So I don't know what's going on here, but I did some checking. If I access the item that is being set by my script in a text stimulus like so:

<trial ShowMeJohnLaJoieprep>
/ stimulusframes = [1 = debug]
/ validresponse = (" ")

/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ ontrialbegin = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

<text debug>
/ items = ("values.Condition = <%values.Condition%>
values.Attractiveness = <%values.Attractiveness%>
values.Sex = <%values.Sex%>
values.CurrentAnschreiben = <%values.CurrentAnschreiben%>
Lebenslauf = <%html.Lebenslauf.currentitem%>")
</text>


...then the current item of html.Lebenslauf is shown correctly. But if I access the same currentitem property in the actual htm file that is displayed (i.e. the wrong one), then it appears blank. I don't know what that means, but maybe it can help diagnose the problem? I have attached all the htm files so that the script can be run; they all point to pictures, so won't display anything, but I have marked the file that Inquisit keeps stubbornly and incorrectly displaying so that it's easy to tell if nothing is changing.

My workaround is currently to add all of the htm files to the /items property of the <html> elements and change my selection script to produce fitting numbers, but I would prefer to avoid that if possible, as it represents a fair bit of time investment for me (so is this, but at least I might learn something about Inquisit from this!).

Grateful for any help and sorry for the wall of text/code!

Attachments
htm files.zip (267 views, 13.00 KB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 107K
AKrishna - 8/29/2019
Hi all,

I'm currently working on an experiment which has a slightly challenging stimulus assignment rule for which I implemented a dynamic item selection. It's a little complicated, so bear with me briefly:

There is a block for older applicants and one for younger applicants consisting of four trial groups each, but with different assignment rules. We have 4 application forms for older applicants, each of which can be combined randomly with a picture of an attractive male/attractive female/unattractive male/unattractive female older applicant. We have 3 normal and 1 special application form for younger applicants, each of which can also be combined randomly with a picture of an attractive male/attractive female/unattractive male/unattractive female younger applicant, but of which the special form must always appear first in the block.

So far so good. For presentation reasons, the applications are split across two pages which are presented at the same time using <html> elements. So I have implemented a selection as follows (please ignore my weird element names, that's what I get for programming when tired):



## The items entered here are simply so that Inquisit doesn't throw an error when loading, they should be dynamically assigned later in the script (but aren't, which is the problem).
<html Lebenslauf>
/ items = ("JungHochattraktivWeiblich2.htm")
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = ("JungHochattraktivWeiblich2Anschreiben.htm")
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>

## This trial is silent and is only there to select the next stimuli to show.
## Depending on the runnig block, the script pulls the next condition from the relevant list without replacement.
## Then it writes a few values that code the current condition for use in the data element later on.
## Then it checks whether the running block is "old" or "young".
## If "old", it pulls a random application stimulus number from the "OldBewerbungen" list.
## If "young", it checks whether this is the first time the trial has run in the block; if so, it applies the special form, otherwise it pulls from the 3-element "YoungBewerbungen" list.
## It then concatenates the relevant elements to form the respective filenames for the html-files before passing on to the actual display trial.

<trial ShowMeJohnLaJoieprep>
/ trialduration = 0
/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialend = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

## This trial displays the htmls and allows participants to see them. In the experiment proper, it would then move onto likert elements that would ask questions about the stimuli.
<trial ShowMeJohnLaJoie>
/ stimulustimes = [0 = Lebenslauf, WriteyWriteyHaveABitey, PressSpace]
/ validresponse = (" ")
</trial>

<text PressSpace>
/ items = ("YoYo boyo, press dat space key")
/ position = (50,95)
/ fontstyle = ("Verdana", 2%, false, false, false, false, 5, 1)
</text>

<block Jung>
/ preinstructions = (young)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page young>
Sie beginnen nun mit Jung
</page>


<block Alt>
/ preinstructions = (old)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page OLD>
Sie beginnen nun mit Alt
</page>


<expt LaDeLa>
/ blocks = [1-2 = noreplace(Alt,Jung)]
</expt>

<list OLD>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<values>
/ Attractiveness = ""
/ Sex = ""
/ Condition = ""
/ CurrentLebenslauf = ""
/ CurrentAnschreiben = ""
</values>

<list OldBewerbungen>
/ items = (1,2,3,4)
</list>


<list YOUNG>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<list YoungBewerbungen>
/ items = (1,2,3)
</list>


So the code above should set the first (and only) item for each of the <html> elements to a specific filename before that element is loaded, thereby changing the displayed htm file each time. However, it doesn't - we only ever see the initial value.

Now, based on the concatenated strings that form the element names, I have tried the following to get the script to vary the htm files it displays:

1. Replacing the <html> elements as follows:

<html Lebenslauf>
/ items = ("<%values.CurrentLebenslauf%>")
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = ("<%values.CurrentAnschreiben%>")
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>


2. Using alternate code to replace the setitem lines above:

/ ontrialend = [html.Lebenslauf.item.1 = values.CurrentLebenslauf; html.WriteyWriteyHaveABitey.item.1 = values.CurrentAnschreiben]


Neither approach has worked. Approach 1 simply makes the html always show as the initial value of values.CurrentLebenslauf or values.CurrentAnschreiben respectively.

I checked and the current code does seem to change the item.1 property of the <html> elements, as if I have those displayed to me as a text, their values are as expected. It simply doesn't affect the file that is actually loaded.

So I don't know what's going on here, but I did some checking. If I access the item that is being set by my script in a text stimulus like so:

<trial ShowMeJohnLaJoieprep>
/ stimulusframes = [1 = debug]
/ validresponse = (" ")

/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ ontrialbegin = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

<text debug>
/ items = ("values.Condition = <%values.Condition%>
values.Attractiveness = <%values.Attractiveness%>
values.Sex = <%values.Sex%>
values.CurrentAnschreiben = <%values.CurrentAnschreiben%>
Lebenslauf = <%html.Lebenslauf.currentitem%>")
</text>


...then the current item of html.Lebenslauf is shown correctly. But if I access the same currentitem property in the actual htm file that is displayed (i.e. the wrong one), then it appears blank. I don't know what that means, but maybe it can help diagnose the problem? I have attached all the htm files so that the script can be run; they all point to pictures, so won't display anything, but I have marked the file that Inquisit keeps stubbornly and incorrectly displaying so that it's easy to tell if nothing is changing.

My workaround is currently to add all of the htm files to the /items property of the <html> elements and change my selection script to produce fitting numbers, but I would prefer to avoid that if possible, as it represents a fair bit of time investment for me (so is this, but at least I might learn something about Inquisit from this!).

Grateful for any help and sorry for the wall of text/code!

In essence, you need to make the script aware of all the HTML files that exist when it gets parsed. If you only construct file names at runtime, the script is unaware of the files' existence. If you do something like

<item allhtmlfiles>
/ 0 = "JungHochattraktivWeiblich2.htm"

/ 1 = "AltHochattraktivMaennlich1.htm"
/ 2 = "AltHochattraktivMaennlich1Anschreiben.htm"
/ 3 = "AltHochattraktivMaennlich2.htm"
/ 4 = "AltHochattraktivMaennlich2Anschreiben.htm"
/ 5 = "AltHochattraktivMaennlich3.htm"
/ 6 = "AltHochattraktivMaennlich3Anschreiben.htm"
/ 7 = "AltHochattraktivMaennlich4.htm"
/ 8 = "AltHochattraktivMaennlich4Anschreiben.htm"

/ 9 = "AltHochattraktivWeiblich1.htm"
/ 10 = "AltHochattraktivWeiblich1Anschreiben.htm"
/ 11 = "AltHochattraktivWeiblich2.htm"
/ 12 = "AltHochattraktivWeiblich2Anschreiben.htm"
/ 13 = "AltHochattraktivWeiblich3.htm"
/ 14 = "AltHochattraktivWeiblich3Anschreiben.htm"
/ 15 = "AltHochattraktivWeiblich4.htm"
/ 16 = "AltHochattraktivWeiblich4Anschreiben.htm"

/ 17 = "AltNiedrigattraktivMaennlich1.htm"
/ 18 = "AltNiedrigattraktivMaennlich1Anschreiben.htm"
/ 19 = "AltNiedrigattraktivMaennlich2.htm"
/ 20 = "AltNiedrigattraktivMaennlich2Anschreiben.htm"
/ 21 = "AltNiedrigattraktivMaennlich3.htm"
/ 22 = "AltNiedrigattraktivMaennlich3Anschreiben.htm"
/ 23 = "AltNiedrigattraktivMaennlich4.htm"
/ 24 = "AltNiedrigattraktivMaennlich4Anschreiben.htm"

/ 25 = "AltNiedrigattraktivWeiblich1.htm"
/ 26 = "AltNiedrigattraktivWeiblich1Anschreiben.htm"
/ 27 = "AltNiedrigattraktivWeiblich2.htm"
/ 28 = "AltNiedrigattraktivWeiblich2Anschreiben.htm"
/ 29 = "AltNiedrigattraktivWeiblich3.htm"
/ 30 = "AltNiedrigattraktivWeiblich3Anschreiben.htm"
/ 31 = "AltNiedrigattraktivWeiblich4.htm"
/ 32 = "AltNiedrigattraktivWeiblich4Anschreiben.htm"
...
</item>

(you still need to add the "Jung..." files)

with

<html Lebenslauf>
/ items = allhtmlfiles
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = allhtmlfiles
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>

then your assignment code in <trial ShowMeJohnLaJoieprep>

<trial ShowMeJohnLaJoieprep>
/ trialduration = 0
/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialend = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

should work as expected.

AKrishna
AKrishna
Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)
Group: Forum Members
Posts: 119, Visits: 400
Dave - 8/29/2019
AKrishna - 8/29/2019
Hi all,

I'm currently working on an experiment which has a slightly challenging stimulus assignment rule for which I implemented a dynamic item selection. It's a little complicated, so bear with me briefly:

There is a block for older applicants and one for younger applicants consisting of four trial groups each, but with different assignment rules. We have 4 application forms for older applicants, each of which can be combined randomly with a picture of an attractive male/attractive female/unattractive male/unattractive female older applicant. We have 3 normal and 1 special application form for younger applicants, each of which can also be combined randomly with a picture of an attractive male/attractive female/unattractive male/unattractive female younger applicant, but of which the special form must always appear first in the block.

So far so good. For presentation reasons, the applications are split across two pages which are presented at the same time using <html> elements. So I have implemented a selection as follows (please ignore my weird element names, that's what I get for programming when tired):



## The items entered here are simply so that Inquisit doesn't throw an error when loading, they should be dynamically assigned later in the script (but aren't, which is the problem).
<html Lebenslauf>
/ items = ("JungHochattraktivWeiblich2.htm")
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = ("JungHochattraktivWeiblich2Anschreiben.htm")
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>

## This trial is silent and is only there to select the next stimuli to show.
## Depending on the runnig block, the script pulls the next condition from the relevant list without replacement.
## Then it writes a few values that code the current condition for use in the data element later on.
## Then it checks whether the running block is "old" or "young".
## If "old", it pulls a random application stimulus number from the "OldBewerbungen" list.
## If "young", it checks whether this is the first time the trial has run in the block; if so, it applies the special form, otherwise it pulls from the 3-element "YoungBewerbungen" list.
## It then concatenates the relevant elements to form the respective filenames for the html-files before passing on to the actual display trial.

<trial ShowMeJohnLaJoieprep>
/ trialduration = 0
/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialend = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

## This trial displays the htmls and allows participants to see them. In the experiment proper, it would then move onto likert elements that would ask questions about the stimuli.
<trial ShowMeJohnLaJoie>
/ stimulustimes = [0 = Lebenslauf, WriteyWriteyHaveABitey, PressSpace]
/ validresponse = (" ")
</trial>

<text PressSpace>
/ items = ("YoYo boyo, press dat space key")
/ position = (50,95)
/ fontstyle = ("Verdana", 2%, false, false, false, false, 5, 1)
</text>

<block Jung>
/ preinstructions = (young)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page young>
Sie beginnen nun mit Jung
</page>


<block Alt>
/ preinstructions = (old)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page OLD>
Sie beginnen nun mit Alt
</page>


<expt LaDeLa>
/ blocks = [1-2 = noreplace(Alt,Jung)]
</expt>

<list OLD>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<values>
/ Attractiveness = ""
/ Sex = ""
/ Condition = ""
/ CurrentLebenslauf = ""
/ CurrentAnschreiben = ""
</values>

<list OldBewerbungen>
/ items = (1,2,3,4)
</list>


<list YOUNG>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<list YoungBewerbungen>
/ items = (1,2,3)
</list>


So the code above should set the first (and only) item for each of the <html> elements to a specific filename before that element is loaded, thereby changing the displayed htm file each time. However, it doesn't - we only ever see the initial value.

Now, based on the concatenated strings that form the element names, I have tried the following to get the script to vary the htm files it displays:

1. Replacing the <html> elements as follows:

<html Lebenslauf>
/ items = ("<%values.CurrentLebenslauf%>")
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = ("<%values.CurrentAnschreiben%>")
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>


2. Using alternate code to replace the setitem lines above:

/ ontrialend = [html.Lebenslauf.item.1 = values.CurrentLebenslauf; html.WriteyWriteyHaveABitey.item.1 = values.CurrentAnschreiben]


Neither approach has worked. Approach 1 simply makes the html always show as the initial value of values.CurrentLebenslauf or values.CurrentAnschreiben respectively.

I checked and the current code does seem to change the item.1 property of the <html> elements, as if I have those displayed to me as a text, their values are as expected. It simply doesn't affect the file that is actually loaded.

So I don't know what's going on here, but I did some checking. If I access the item that is being set by my script in a text stimulus like so:

<trial ShowMeJohnLaJoieprep>
/ stimulusframes = [1 = debug]
/ validresponse = (" ")

/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ ontrialbegin = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

<text debug>
/ items = ("values.Condition = <%values.Condition%>
values.Attractiveness = <%values.Attractiveness%>
values.Sex = <%values.Sex%>
values.CurrentAnschreiben = <%values.CurrentAnschreiben%>
Lebenslauf = <%html.Lebenslauf.currentitem%>")
</text>


...then the current item of html.Lebenslauf is shown correctly. But if I access the same currentitem property in the actual htm file that is displayed (i.e. the wrong one), then it appears blank. I don't know what that means, but maybe it can help diagnose the problem? I have attached all the htm files so that the script can be run; they all point to pictures, so won't display anything, but I have marked the file that Inquisit keeps stubbornly and incorrectly displaying so that it's easy to tell if nothing is changing.

My workaround is currently to add all of the htm files to the /items property of the <html> elements and change my selection script to produce fitting numbers, but I would prefer to avoid that if possible, as it represents a fair bit of time investment for me (so is this, but at least I might learn something about Inquisit from this!).

Grateful for any help and sorry for the wall of text/code!

In essence, you need to make the script aware of all the HTML files that exist when it gets parsed. If you only construct file names at runtime, the script is unaware of the files' existence. If you do something like

<item allhtmlfiles>
/ 0 = "JungHochattraktivWeiblich2.htm"

/ 1 = "AltHochattraktivMaennlich1.htm"
/ 2 = "AltHochattraktivMaennlich1Anschreiben.htm"
/ 3 = "AltHochattraktivMaennlich2.htm"
/ 4 = "AltHochattraktivMaennlich2Anschreiben.htm"
/ 5 = "AltHochattraktivMaennlich3.htm"
/ 6 = "AltHochattraktivMaennlich3Anschreiben.htm"
/ 7 = "AltHochattraktivMaennlich4.htm"
/ 8 = "AltHochattraktivMaennlich4Anschreiben.htm"

/ 9 = "AltHochattraktivWeiblich1.htm"
/ 10 = "AltHochattraktivWeiblich1Anschreiben.htm"
/ 11 = "AltHochattraktivWeiblich2.htm"
/ 12 = "AltHochattraktivWeiblich2Anschreiben.htm"
/ 13 = "AltHochattraktivWeiblich3.htm"
/ 14 = "AltHochattraktivWeiblich3Anschreiben.htm"
/ 15 = "AltHochattraktivWeiblich4.htm"
/ 16 = "AltHochattraktivWeiblich4Anschreiben.htm"

/ 17 = "AltNiedrigattraktivMaennlich1.htm"
/ 18 = "AltNiedrigattraktivMaennlich1Anschreiben.htm"
/ 19 = "AltNiedrigattraktivMaennlich2.htm"
/ 20 = "AltNiedrigattraktivMaennlich2Anschreiben.htm"
/ 21 = "AltNiedrigattraktivMaennlich3.htm"
/ 22 = "AltNiedrigattraktivMaennlich3Anschreiben.htm"
/ 23 = "AltNiedrigattraktivMaennlich4.htm"
/ 24 = "AltNiedrigattraktivMaennlich4Anschreiben.htm"

/ 25 = "AltNiedrigattraktivWeiblich1.htm"
/ 26 = "AltNiedrigattraktivWeiblich1Anschreiben.htm"
/ 27 = "AltNiedrigattraktivWeiblich2.htm"
/ 28 = "AltNiedrigattraktivWeiblich2Anschreiben.htm"
/ 29 = "AltNiedrigattraktivWeiblich3.htm"
/ 30 = "AltNiedrigattraktivWeiblich3Anschreiben.htm"
/ 31 = "AltNiedrigattraktivWeiblich4.htm"
/ 32 = "AltNiedrigattraktivWeiblich4Anschreiben.htm"
...
</item>

(you still need to add the "Jung..." files)

with

<html Lebenslauf>
/ items = allhtmlfiles
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = allhtmlfiles
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>

then your assignment code in <trial ShowMeJohnLaJoieprep>

<trial ShowMeJohnLaJoieprep>
/ trialduration = 0
/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialend = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

should work as expected.

Thanks for the response! Unfortunately, using the setitem code doesn't work here - even if I set the /select value of the <html>-elements to 1, the setitem doesn't have the desired effect. Again, currentitem returns the expected value, but it's not consistent with what the html-element actually shows.

I'll look further at this tomorrow, maybe I can find a working solution.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 107K
AKrishna - 8/29/2019
Dave - 8/29/2019
AKrishna - 8/29/2019
Hi all,

I'm currently working on an experiment which has a slightly challenging stimulus assignment rule for which I implemented a dynamic item selection. It's a little complicated, so bear with me briefly:

There is a block for older applicants and one for younger applicants consisting of four trial groups each, but with different assignment rules. We have 4 application forms for older applicants, each of which can be combined randomly with a picture of an attractive male/attractive female/unattractive male/unattractive female older applicant. We have 3 normal and 1 special application form for younger applicants, each of which can also be combined randomly with a picture of an attractive male/attractive female/unattractive male/unattractive female younger applicant, but of which the special form must always appear first in the block.

So far so good. For presentation reasons, the applications are split across two pages which are presented at the same time using <html> elements. So I have implemented a selection as follows (please ignore my weird element names, that's what I get for programming when tired):



## The items entered here are simply so that Inquisit doesn't throw an error when loading, they should be dynamically assigned later in the script (but aren't, which is the problem).
<html Lebenslauf>
/ items = ("JungHochattraktivWeiblich2.htm")
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = ("JungHochattraktivWeiblich2Anschreiben.htm")
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>

## This trial is silent and is only there to select the next stimuli to show.
## Depending on the runnig block, the script pulls the next condition from the relevant list without replacement.
## Then it writes a few values that code the current condition for use in the data element later on.
## Then it checks whether the running block is "old" or "young".
## If "old", it pulls a random application stimulus number from the "OldBewerbungen" list.
## If "young", it checks whether this is the first time the trial has run in the block; if so, it applies the special form, otherwise it pulls from the 3-element "YoungBewerbungen" list.
## It then concatenates the relevant elements to form the respective filenames for the html-files before passing on to the actual display trial.

<trial ShowMeJohnLaJoieprep>
/ trialduration = 0
/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialend = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

## This trial displays the htmls and allows participants to see them. In the experiment proper, it would then move onto likert elements that would ask questions about the stimuli.
<trial ShowMeJohnLaJoie>
/ stimulustimes = [0 = Lebenslauf, WriteyWriteyHaveABitey, PressSpace]
/ validresponse = (" ")
</trial>

<text PressSpace>
/ items = ("YoYo boyo, press dat space key")
/ position = (50,95)
/ fontstyle = ("Verdana", 2%, false, false, false, false, 5, 1)
</text>

<block Jung>
/ preinstructions = (young)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page young>
Sie beginnen nun mit Jung
</page>


<block Alt>
/ preinstructions = (old)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page OLD>
Sie beginnen nun mit Alt
</page>


<expt LaDeLa>
/ blocks = [1-2 = noreplace(Alt,Jung)]
</expt>

<list OLD>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<values>
/ Attractiveness = ""
/ Sex = ""
/ Condition = ""
/ CurrentLebenslauf = ""
/ CurrentAnschreiben = ""
</values>

<list OldBewerbungen>
/ items = (1,2,3,4)
</list>


<list YOUNG>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<list YoungBewerbungen>
/ items = (1,2,3)
</list>


So the code above should set the first (and only) item for each of the <html> elements to a specific filename before that element is loaded, thereby changing the displayed htm file each time. However, it doesn't - we only ever see the initial value.

Now, based on the concatenated strings that form the element names, I have tried the following to get the script to vary the htm files it displays:

1. Replacing the <html> elements as follows:

<html Lebenslauf>
/ items = ("<%values.CurrentLebenslauf%>")
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = ("<%values.CurrentAnschreiben%>")
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>


2. Using alternate code to replace the setitem lines above:

/ ontrialend = [html.Lebenslauf.item.1 = values.CurrentLebenslauf; html.WriteyWriteyHaveABitey.item.1 = values.CurrentAnschreiben]


Neither approach has worked. Approach 1 simply makes the html always show as the initial value of values.CurrentLebenslauf or values.CurrentAnschreiben respectively.

I checked and the current code does seem to change the item.1 property of the <html> elements, as if I have those displayed to me as a text, their values are as expected. It simply doesn't affect the file that is actually loaded.

So I don't know what's going on here, but I did some checking. If I access the item that is being set by my script in a text stimulus like so:

<trial ShowMeJohnLaJoieprep>
/ stimulusframes = [1 = debug]
/ validresponse = (" ")

/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ ontrialbegin = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

<text debug>
/ items = ("values.Condition = <%values.Condition%>
values.Attractiveness = <%values.Attractiveness%>
values.Sex = <%values.Sex%>
values.CurrentAnschreiben = <%values.CurrentAnschreiben%>
Lebenslauf = <%html.Lebenslauf.currentitem%>")
</text>


...then the current item of html.Lebenslauf is shown correctly. But if I access the same currentitem property in the actual htm file that is displayed (i.e. the wrong one), then it appears blank. I don't know what that means, but maybe it can help diagnose the problem? I have attached all the htm files so that the script can be run; they all point to pictures, so won't display anything, but I have marked the file that Inquisit keeps stubbornly and incorrectly displaying so that it's easy to tell if nothing is changing.

My workaround is currently to add all of the htm files to the /items property of the <html> elements and change my selection script to produce fitting numbers, but I would prefer to avoid that if possible, as it represents a fair bit of time investment for me (so is this, but at least I might learn something about Inquisit from this!).

Grateful for any help and sorry for the wall of text/code!

In essence, you need to make the script aware of all the HTML files that exist when it gets parsed. If you only construct file names at runtime, the script is unaware of the files' existence. If you do something like

<item allhtmlfiles>
/ 0 = "JungHochattraktivWeiblich2.htm"

/ 1 = "AltHochattraktivMaennlich1.htm"
/ 2 = "AltHochattraktivMaennlich1Anschreiben.htm"
/ 3 = "AltHochattraktivMaennlich2.htm"
/ 4 = "AltHochattraktivMaennlich2Anschreiben.htm"
/ 5 = "AltHochattraktivMaennlich3.htm"
/ 6 = "AltHochattraktivMaennlich3Anschreiben.htm"
/ 7 = "AltHochattraktivMaennlich4.htm"
/ 8 = "AltHochattraktivMaennlich4Anschreiben.htm"

/ 9 = "AltHochattraktivWeiblich1.htm"
/ 10 = "AltHochattraktivWeiblich1Anschreiben.htm"
/ 11 = "AltHochattraktivWeiblich2.htm"
/ 12 = "AltHochattraktivWeiblich2Anschreiben.htm"
/ 13 = "AltHochattraktivWeiblich3.htm"
/ 14 = "AltHochattraktivWeiblich3Anschreiben.htm"
/ 15 = "AltHochattraktivWeiblich4.htm"
/ 16 = "AltHochattraktivWeiblich4Anschreiben.htm"

/ 17 = "AltNiedrigattraktivMaennlich1.htm"
/ 18 = "AltNiedrigattraktivMaennlich1Anschreiben.htm"
/ 19 = "AltNiedrigattraktivMaennlich2.htm"
/ 20 = "AltNiedrigattraktivMaennlich2Anschreiben.htm"
/ 21 = "AltNiedrigattraktivMaennlich3.htm"
/ 22 = "AltNiedrigattraktivMaennlich3Anschreiben.htm"
/ 23 = "AltNiedrigattraktivMaennlich4.htm"
/ 24 = "AltNiedrigattraktivMaennlich4Anschreiben.htm"

/ 25 = "AltNiedrigattraktivWeiblich1.htm"
/ 26 = "AltNiedrigattraktivWeiblich1Anschreiben.htm"
/ 27 = "AltNiedrigattraktivWeiblich2.htm"
/ 28 = "AltNiedrigattraktivWeiblich2Anschreiben.htm"
/ 29 = "AltNiedrigattraktivWeiblich3.htm"
/ 30 = "AltNiedrigattraktivWeiblich3Anschreiben.htm"
/ 31 = "AltNiedrigattraktivWeiblich4.htm"
/ 32 = "AltNiedrigattraktivWeiblich4Anschreiben.htm"
...
</item>

(you still need to add the "Jung..." files)

with

<html Lebenslauf>
/ items = allhtmlfiles
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ items = allhtmlfiles
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>

then your assignment code in <trial ShowMeJohnLaJoieprep>

<trial ShowMeJohnLaJoieprep>
/ trialduration = 0
/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialend = [html.Lebenslauf.setitem(values.CurrentLebenslauf, 1); html.WriteyWriteyHaveABitey.setitem(values.CurrentAnschreiben,1)]
</trial>

should work as expected.

Thanks for the response! Unfortunately, using the setitem code doesn't work here - even if I set the /select value of the <html>-elements to 1, the setitem doesn't have the desired effect. Again, currentitem returns the expected value, but it's not consistent with what the html-element actually shows.

I'll look further at this tomorrow, maybe I can find a working solution.

You're right, I overlooked something. Thinking about this further, though, here's an approach that should work:

## The items entered here are simply so that Inquisit doesn't throw an error when loading, they should be dynamically assigned later in the script (but aren't, which is the problem).
<html Lebenslauf>
/ size = (48%,85%)
/ position = (23.5%,46%)
</html>

<html WriteyWriteyHaveABitey>
/ size = (48%,85%)
/ position = (76.5%,46%)
</html>

<html all>
/ items = allhtmlfiles
</html>

## This trial is silent and is only there to select the next stimuli to show.
## Depending on the runnig block, the script pulls the next condition from the relevant list without replacement.
## Then it writes a few values that code the current condition for use in the data element later on.
## Then it checks whether the running block is "old" or "young".
## If "old", it pulls a random application stimulus number from the "OldBewerbungen" list.
## If "young", it checks whether this is the first time the trial has run in the block; if so, it applies the special form, otherwise it pulls from the 3-element "YoungBewerbungen" list.
## It then concatenates the relevant elements to form the respective filenames for the html-files before passing on to the actual display trial.

<trial ShowMeJohnLaJoieprep>
/ trialduration = 0
/ ontrialbegin = [
html.Lebenslauf.clearitems();
html.WriteyWriteyHaveABitey.clearitems();
]
/ ontrialbegin = [if (script.currentblock == "Alt") values.Condition = list.OLD.nextvalue
else if (script.currentblock == "Jung") values.Condition = list.YOUNG.nextvalue]
/ ontrialbegin = [if (search(values.Condition,"Hoch") > -1) values.Attractiveness = "Hochattraktiv"
else values.Attractiveness = "Niedrigattraktiv"]
/ ontrialbegin = [if (search(values.Condition,"Weib") > -1) values.Sex = "Weiblich"
else values.Sex = "Maennlich"]
/ ontrialbegin = [if (script.currentblock == "Alt")
values.CurrentLebenslauf = Concat("Alt",Concat(values.Attractiveness,Concat(values.Sex,list.OldBewerbungen.nextvalue)))
else if (script.currentblock == "Jung" && trial.ShowMeJohnLaJoie.count < 1)
values.CurrentLebenslauf = Concat("MariaJung",Concat(values.Attractiveness,values.Sex))
else values.CurrentLebenslauf = Concat("Jung",Concat(values.Attractiveness,Concat(values.Sex,list.YoungBewerbungen.nextvalue)))]
/ ontrialbegin = [values.CurrentAnschreiben = Concat(values.CurrentLebenslauf,"Anschreiben")]
/ ontrialbegin = [values.CurrentLebenslauf = concat(values.CurrentLebenslauf,".htm");
values.CurrentAnschreiben = concat(values.CurrentAnschreiben,".htm")]
/ branch = [trial.ShowMeJohnLaJoie]
/ ontrialend = [html.Lebenslauf.appenditem(values.CurrentLebenslauf); html.WriteyWriteyHaveABitey.appenditem(values.CurrentAnschreiben)]
</trial>

## This trial displays the htmls and allows participants to see them. In the experiment proper, it would then move onto likert elements that would ask questions about the stimuli.
<trial ShowMeJohnLaJoie>
/ stimulustimes = [0 = Lebenslauf, WriteyWriteyHaveABitey, PressSpace]
/ validresponse = (" ")
</trial>

<text PressSpace>
/ items = ("YoYo boyo, press dat space key")
/ position = (50,95)
/ fontstyle = ("Verdana", 2%, false, false, false, false, 5, 1)
</text>

<block Jung>
/ preinstructions = (young)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page young>
Sie beginnen nun mit Jung
</page>


<block Alt>
/ preinstructions = (old)
/ trials = [1-4 = ShowMeJohnLaJoiePrep]
</block>

<page OLD>
Sie beginnen nun mit Alt
</page>

<expt LaDeLa>
/ blocks = [1 = Alt]
</expt>

<list OLD>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<values>
/ Attractiveness = ""
/ Sex = ""
/ Condition = ""
/ CurrentLebenslauf = ""
/ CurrentAnschreiben = ""
</values>

<list OldBewerbungen>
/ items = (1,2,3,4)
</list>


<list YOUNG>
/ items = ("HochAttraktiv/Maennlich","NiedrigAttraktiv/Maennlich","HochAttraktiv/Weiblich","NiedrigAttraktiv/Weiblich")
</list>

<list YoungBewerbungen>
/ items = (1,2,3)
</list>

<item allhtmlfiles>
/ 1 = "AltHochattraktivMaennlich1.htm"
/ 2 = "AltHochattraktivMaennlich1Anschreiben.htm"
/ 3 = "AltHochattraktivMaennlich2.htm"
/ 4 = "AltHochattraktivMaennlich2Anschreiben.htm"
/ 5 = "AltHochattraktivMaennlich3.htm"
/ 6 = "AltHochattraktivMaennlich3Anschreiben.htm"
/ 7 = "AltHochattraktivMaennlich4.htm"
/ 8 = "AltHochattraktivMaennlich4Anschreiben.htm"

/ 9 = "AltHochattraktivWeiblich1.htm"
/ 10 = "AltHochattraktivWeiblich1Anschreiben.htm"
/ 11 = "AltHochattraktivWeiblich2.htm"
/ 12 = "AltHochattraktivWeiblich2Anschreiben.htm"
/ 13 = "AltHochattraktivWeiblich3.htm"
/ 14 = "AltHochattraktivWeiblich3Anschreiben.htm"
/ 15 = "AltHochattraktivWeiblich4.htm"
/ 16 = "AltHochattraktivWeiblich4Anschreiben.htm"

/ 17 = "AltNiedrigattraktivMaennlich1.htm"
/ 18 = "AltNiedrigattraktivMaennlich1Anschreiben.htm"
/ 19 = "AltNiedrigattraktivMaennlich2.htm"
/ 20 = "AltNiedrigattraktivMaennlich2Anschreiben.htm"
/ 21 = "AltNiedrigattraktivMaennlich3.htm"
/ 22 = "AltNiedrigattraktivMaennlich3Anschreiben.htm"
/ 23 = "AltNiedrigattraktivMaennlich4.htm"
/ 24 = "AltNiedrigattraktivMaennlich4Anschreiben.htm"

/ 25 = "AltNiedrigattraktivWeiblich1.htm"
/ 26 = "AltNiedrigattraktivWeiblich1Anschreiben.htm"
/ 27 = "AltNiedrigattraktivWeiblich2.htm"
/ 28 = "AltNiedrigattraktivWeiblich2Anschreiben.htm"
/ 29 = "AltNiedrigattraktivWeiblich3.htm"
/ 30 = "AltNiedrigattraktivWeiblich3Anschreiben.htm"
/ 31 = "AltNiedrigattraktivWeiblich4.htm"
/ 32 = "AltNiedrigattraktivWeiblich4Anschreiben.htm"
</item>

Working example code is attached, including a simpler demo as well.


Attachments
working.zip (258 views, 10.00 KB)
AKrishna
AKrishna
Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)
Group: Forum Members
Posts: 119, Visits: 400
Many thanks, Dave! I just integrated the clear - append loop into my script and it looks like it's working.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search