Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

defining a new variable and updating it

Hi,

I am trying to make my results analysis easier by defining a variable and updating it in each condition according to it. i.e. difficulty : hard/easy, correct answer: 1,2 etc. I tried using the 'prepare' part in the 'inline script' in each condition (i.e. var.correct answer = 1) and logging the variables but in the output, I see the first value that was assigned to the variable and it does not change along the experiment. what am I doing wrong?

Thanks
Amihai

Comments

  • eduardeduard Posts: 977

    Hi Amihai,

    A correct response is only updates after the response was given which happens in the run phase of your experiment (if you implemented your experiment in the standard way). If you define your variables there, does it still not update? If not, we need more detail on what you are actually doing. Maybe upload your experiment.

    Eduard

  • Dear Eduard,

    Thanks for answering. I ended up solving the problem by reading past posts in the forum and combining the answers from 3 different ones. This is the code I ended up using in the "prepeare" part of the inline script in the begining of the exp:

    exp.set("correct_answer",0)
    exp.set("irr_correct_answer",0)
    exp.set("main_dim",0)
    exp.set("irr_dim",0)

    This is the code I ended up using in the "Run" part of the inline script in the loops:

    correct_answer = '1' (the correct answer)
    irr_correct_answer = '2' (the correct answer according to the irrelevant dimension)
    main_dim = 'hard'
    irr_dim = 'easy'

    exp.set("correct_answer", correct_answer)
    exp.set("irr_correct_answer", irr_correct_answer)
    exp.set("main_dim", main_dim)
    exp.set("irr_dim", irr_dim)

    From what I understand (I do not know how to code), I define a global variable in the beginning of the exp that can be changed, but not directly in the loops. For managing to do this in the loops, I have to create "dummy" variables and assign their value to the global ones when needed. Is my explanation right?

    Anyway, I hope this helps whoever needs to define a new variable and update it. This change made my results analysis much easier.

    Amihai

    Thanked by 1eduard
Sign In or Register to comment.