1

I'm currently coding a psych experiment and have been experiencing difficulties referencing a variable within the inline script. Specifically, in the task you are presented with two cards, you select one, and you either win/lose points. Immediately after selecting a card, you are shown feedback of whether the card you selected was a winning/losing response, accompanied by a running total which is coded as the variable [running_reward]. Now what I'm trying and failing at doing is adding a running total at the end of each block. Because this new script I've created is outside the trial sequence but within the same block, it doesn't register block4_reward and therefore doesn't update the running total to the correct amount, it just shows 0. My question is, why does it not update?

  1. The reason why it shows 0 is that at the start of the experiment, we "exp.set(block4_reward, 0) as the starting value. Though, given the codes shown below, it should update when the participant has earned/lost points?

  2. At the end of the trial sequence, I have the code:

running_reward = exp.get("running_reward")

exp.set("block4_reward", running_reward)

block4_reward = exp.get("block4_reward")

print("block 4 reward: ", block4_reward)
  1. Immediately following this (2), outside the trial sequence but still within the same block, is the code:
print("new_inline_script_5:")

block4_reward = exp.get("block4_reward")

print("block 4 reward: ", block4_reward)
  1. This is the 'code' for the screen that will appear at the end of the block to show the final total that was earned.
draw textline center=1 color="#010101" font_bold=no font_family=Avenir font_italic=no font_size=27 html=yes show_if=always text="Your total winnings so far are: [block4_reward]" x=0 y=-100 z_index=0
Sobini M
  • 11
  • 3

0 Answers0