Shuffling a sentence frame, and then a word within that paragraph

I have an online study that presents participants with a sentence that they then respond to.

There is one key word within each sentence.

I have 10 sentences and 10 key words. I want to randomize which key word goes in which sentence, and then the order that the sentences appear in.

I thought I could do it like this:

  • At the start of the experiment, create a list containing the 10 key words.
  • Have an Excel file that has ten sentences.
  • Embed a variable reference to my list in the sentences.

So, for example, at the start of the experiment have a code that does this:

keywords = ["cat", "dog", "snake"]

Then, each sentence in the Excel file would be something like this:

Jim saw the $keywords[trials.thisN][0] on the hill.
Sally found a $keywords[trials.thisN][0] on the porch.

What I end up getting is that each trial presents trials.thisN.

Could someone explain what I’m doing wrong?

While I would probably search and replace a symbol in the sentence to add the keyword in a code component, the simplest solution would be to have two text columns in your spreadsheet, one for the pre keyword text and one for the post. Then you could put $PreKey + keywords[trials.thisN][0] + PostKey in the text component itself.