[solved] AttributeError: 'instancemethod' object has no attribute 'ongezond_SRHI_item1'
In an inline scripted form I have Ratingscales named, e.g.
ratingScale1 = widgets.rating_scale(form, var='gezond_SRHI_item1',
nodes=['1', '2', '3', '4', '5', '6', '7'])
Then I want to write these variables away as exp.set.nameofvariable.
Also, I need to make the string into an int, like:
exp.set.ongezond_SRHI_item1 = int(exp.ongezond_SRHI_item1)
I get this error though. what does it mean?
traceback:
AttributeError: 'instancemethod' object has no attribute 'ongezond_SRHI_item1'
Full traceback in debug window
Comments
Hi Natalie,
To set variables in an inline_script for future use in the graphical interface (for example, the logger item), you should indeed use the built-in experiment function
exp.set().This function takes two parameters, namely the name of the to-be-set variable (for example, "my_var") and its current value (e.g. 1).
So, in your case, you set this variable like so:
Does this solve the problem?
Best,
Lotje
Did you like my answer? Feel free to

Dear Lotje,
I tried it, but i can't make it work. I get this error:
Nameerror: NameError: name ongezond_SRHI_item1 is not defined.
I tried:
exp.set("ongezond_SRHI_item1", int(ongezond_SRHI_item1))
and
exp.set(self.get("ongezond_SRHI_item1"), int(ongezond_SRHI_item1))
I also wonder WHERE I can state these lines. I have tried many different places, see my code below. I have an inline_scripted form with "run if never" + a inline_script with "run always" after that that checks if everything is filled in before continutation:
************ this inline script run if never:
**********this inline script: run if always:
Hi Natalie,
In the first post of this thread, you wrote:
I'm wondering what you mean exactly by this. Do you mean you want to write the variables away so that they will appear in your output file? In this case, I think everything is quite simple. You can just append a logger item after your inline_script items:
and the variables "ongezond_SRHI_item1" etc. appear as column headers in your .csv file. The columns contain the counter of the ticked box. Note that Python starts counting at zero, so if participants ticked the first box, the column (e.g. "ongezond_SRHI_item4") contains the value 0, if participants ticked the second box, the column contains the value 1. etc.
Maybe this is all you need to know? In this case you don't have to worry about setting the variables yourself using exp.set().
Still, to answer your question about where to do this, if you wanted to do it:
We made a while loop that keeps showing the form until all questions are answered. Thus, you are only certain that all your response variables contain the counter of a ticked box after the variable 'incomplete' is equal to
False.As a consequence, you are sure that, on a given trial, the response variables contain their 'final' value:
Does this make sense?
Best,
Lotje
Did you like my answer? Feel free to

Dear Lotje,
thank you for your answers. I need to use the 'names'of the items later in the experiment to set a reward the participant will receive (a certain picture). That is why the 'number' is not enough. (Also, at first I didn't know a Ratingscale sets the answers as numbers. I thought they would be the names you give the nodes... ).
I also understand the place now where to put it.. (I was so tired yesterday that I couldn;t see it anymore ;-)
Thank you again!!
Natalie
Hi Natalie,
Ahh, okay, I see what you mean.
Maybe something like this?
Did you like my answer? Feel free to

Can somebody put this discussion on [solved]? It seems I can not edit the title of the discussion..
Thank you