Self-Assessment Manikin - SAM
Hi,
I created SAM rating form. It took much time, I benefited from the Forum. Thus I want to share it with you. I hope you can save time thanks to that form.
def kontrol():
return var.ratingscale1 != None and var.ratingscale2 != None and var.ratingscale3 != None and var.ratingscale4 != None and var.ratingscale5 != None and var.ratingscale6 != None and var.ratingscale8 != None and var.ratingscale9 != None
from libopensesame import widgets
pict = self.get("picture")
question1 = Label(text='Mutlu', center=True)
question2 = Label(text='Üzgün', center=True)
question3 = Label(text='Korkmuş', center=True)
question4 = Label(text='Öfkeli', center=True)
question5 = Label(text='Şaşırmış', center=True)
question6 = Label(text='Kızgın', center=True)
question8 = Label(text='Değerlik', center=True)
question9 = Label(text='Uyarılmışlık', center=True)
my_form = Form(validator=kontrol, rows=23, cols=3, margins=(5,20,15,20))
ratingScale1 = RatingScale(nodes=['1','2','3','4','5','6','7'],var="ratingscale1")
ratingScale2 = RatingScale(nodes=['','','','','','',''], var="ratingscale2")
ratingScale3 = RatingScale(nodes=['','','','','','',''], var="ratingscale3")
ratingScale4 = RatingScale(nodes=['','','','','','',''], var="ratingscale4")
ratingScale5 = RatingScale(nodes=['','','','','','',''], var="ratingscale5")
ratingScale6 = RatingScale(nodes=['','','','','','',''], var="ratingscale6")
ratingScale8 = RatingScale(nodes=['','','','','','','','',''],var="ratingscale8")
ratingScale9 = RatingScale(nodes=['','','','','','','','',''], var="ratingscale9")
image = widgets.image(my_form, path=self.experiment.get_file(pict), adjust=True, frame=True)
image1 = ImageWidget(path=pool['SAM-Valance.jpg'], adjust=False, frame=False)
image2 = ImageWidget(path=pool['SAM-Arousal.jpg'], adjust=False, frame=False)
nextButton = Button(text='Next')
my_form.set_widget(image, (0, 0), rowspan=4)
my_form.set_widget(question1, (0, 4))
my_form.set_widget(question2, (0, 5))
my_form.set_widget(question3, (0, 6))
my_form.set_widget(question4, (0, 7))
my_form.set_widget(question5, (0, 8))
my_form.set_widget(question6, (0, 9))
my_form.set_widget(question8, (0, 15))
my_form.set_widget(question9, (0, 20))
my_form.set_widget(ratingScale1, (1, 4), colspan=2)
my_form.set_widget(ratingScale2, (1, 5), colspan=2)
my_form.set_widget(ratingScale3, (1, 6), colspan=2)
my_form.set_widget(ratingScale4, (1, 7), colspan=2)
my_form.set_widget(ratingScale5, (1, 8), colspan=2)
my_form.set_widget(ratingScale6, (1, 9), colspan=2)
my_form.set_widget(image1, (1, 13), colspan=2)
my_form.set_widget(ratingScale8, (1, 15), colspan=2)
my_form.set_widget(image2, (1, 18), colspan=2)
my_form.set_widget(ratingScale9, (1, 20), colspan=2)
my_form.set_widget(nextButton, (2, 21), rowspan=2)
my_form._exec()

Comments
Thanks!
Check out SigmundAI.eu for our OpenSesame AI assistant!
??
Hello @sinem,
Thank you very much for sharing your code. I'm trying to do something similar and I would like to know what the first 4 lines of your code are for? Are they absolutely necessary?
Thanks in advance.
Hi Gio,
It is probably not necessary anymore to explicitly import widgets. It should automatically be available in the workspace, but best to try it out, and decide based on whether the experiment crashes whether you need it or not (it will crash, if it is necessary)
pict = self.get("picture")extracts the variable that is stored as part of
expThis is old syntax and also not necessary anymore. You can either usevar.pictureinstead of pict or do something likepict=var.pictureThis defines a validator than can be used to make sure that the form response is valid. See the documentation on validation.
Hope this helps,
Eduard