SHARE
TWEET

Untitled

a guest May 24th, 2013 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Generated by OpenSesame 0.27.2 (Frisky Freud)
  2. # Fri May 24 13:55:34 2013 (posix)
  3. # <http://www.cogsci.nl/opensesame>
  4.  
  5. set mouse_backend "legacy"
  6. set subject_parity "even"
  7. set response2 ""
  8. set height "768"
  9. set sound_buf_size "512"
  10. set font_italic "no"
  11. set custom_cursor "yes"
  12. set synth_backend "legacy"
  13. set title "Example for Sylvia"
  14. set coordinates "relative"
  15. set start "experiment"
  16. set sampler_backend "legacy"
  17. set font_family "mono"
  18. set foreground "white"
  19. set font_bold "no"
  20. set description "In this example it is checked whether the text input is an integer between 0 and 100."
  21. set background "black"
  22. set font_size "18"
  23. set keyboard_backend "legacy"
  24. set canvas_backend "legacy"
  25. set compensation "0"
  26. set subject_nr "0"
  27. set width "1024"
  28.  
  29. define inline_script create_form
  30.         ___run__
  31.         from libopensesame import widgets
  32.        
  33.         form = widgets.form(self.experiment, cols=[3,2], rows=[1,1,1,1,1,1,1,1], spacing = 10)
  34.         titel = widgets.label(form,  text='Ongezond snacken is iets...', center=False)
  35.         vraag1 = widgets.label(form,  text='1. dat ik regelmatig doe', center=False)
  36.         vraag2 = widgets.label(form,  text='2. dat ik automatisch doe', center=False)
  37.         vraag3 = widgets.label(form,  text='3. dat ik doe zonder het me bewust te herinneren', center=False)
  38.         vraag4 = widgets.label(form,  text='4. dat me een vreemd gevoel geeft als ik het niet doe', center=False)
  39.         vraag5 = widgets.label(form,  text='5. dat ik doe zonder er bij na te denken', center=False)
  40.         vraag6 = widgets.label(form,  text='6. dat moeite kost om niet te doen', center=False)
  41.         instructie= widgets.label(form, text='1 = helemaal oneens, 7 = helemaal eens')
  42.        
  43.         ratingScale1 = widgets.rating_scale(form, var='ongezond_SRHI_item1',nodes=['1', '2', '3', '4', '5', '6', '7'])
  44.         ratingScale2 = widgets.rating_scale(form, var='ongezond_SRHI_item2',nodes=['1', '2', '3', '4', '5', '6', '7'])
  45.         ratingScale3 = widgets.rating_scale(form, var='ongezond_SRHI_item3',nodes=['1', '2', '3', '4', '5', '6', '7'])
  46.         ratingScale4 = widgets.rating_scale(form, var='ongezond_SRHI_item4',nodes=['1', '2', '3', '4', '5', '6', '7'])
  47.         ratingScale5 = widgets.rating_scale(form, var='ongezond_SRHI_item5',nodes=['1', '2', '3', '4', '5', '6', '7'])
  48.         ratingScale6 = widgets.rating_scale(form, var='ongezond_SRHI_item6',nodes=['1', '2', '3', '4', '5', '6', '7'])
  49.         nextButton = widgets.button(form, text='Verder')
  50.        
  51.         form.set_widget(titel, (0,0), colspan=1)
  52.         form.set_widget(vraag1, (0,1))
  53.         form.set_widget(vraag2, (0,2))
  54.         form.set_widget(vraag3, (0,3))
  55.         form.set_widget(vraag4, (0,4))
  56.         form.set_widget(vraag5, (0,5))
  57.         form.set_widget(vraag6, (0,6))
  58.         form.set_widget(instructie, (1,0))
  59.         form.set_widget(ratingScale1, (1,1))
  60.         form.set_widget(ratingScale2, (1,2))
  61.         form.set_widget(ratingScale3, (1,3))
  62.         form.set_widget(ratingScale4, (1,4))
  63.         form.set_widget(ratingScale5, (1,5))
  64.         form.set_widget(ratingScale6, (1,6))    
  65.         form.set_widget(nextButton, (0,7), colspan=2)
  66.         form._exec()
  67.         __end__
  68.         set _prepare ""
  69.         set description "Executes Python code"
  70.  
  71. define sequence experiment
  72.         run warning_message "never"
  73.         run create_form "never"
  74.         run inline_script "always"
  75.  
  76. define inline_script inline_script
  77.         ___run__
  78.         while True:
  79.                 # Make a variable storing whether the form is completely filled
  80.                 # in on or not. The starting value is False. If one of the
  81.                 # 'checks' below is not met, its set to True:
  82.                 incomplete = False
  83.        
  84.                 # Execute the prepared inline_script item:
  85.                 # (If you placed all the Python script in the Run phase tab, only
  86.                 # executing the run phase of your item is enough here)
  87.                 exp.items["create_form"].run()
  88.                
  89.                 # Check whether your criteria are met:
  90.                
  91.                 # The easiests way to do that here is to see whether none of your response
  92.                 # variables are set to 'None'. 'None' indicates that no box was ticked, whereas
  93.                 # any other variable indicates that the question was not left unanswered.
  94.                 # That's all you need to know, right?
  95.                 if (self.get("ongezond_SRHI_item1") == "None" or self.get("ongezond_SRHI_item2") == "None" or \
  96.                         self.get("ongezond_SRHI_item3") == "None" or self.get("ongezond_SRHI_item4") == "None" or \
  97.                         self.get("ongezond_SRHI_item4") == "None" or self.get("ongezond_SRHI_item6") == "None"):
  98.                         incomplete = True
  99.        
  100.                 # If incomplete is still False, break out of this while loop
  101.                 # and continue with the experiment.
  102.                 if not incomplete:
  103.                                 break
  104.        
  105.                 # If the form turns out to be incomplete, show a warning.
  106.                 else:
  107.                         exp.items["warning_message"].prepare()
  108.                         exp.items["warning_message"].run()
  109.        
  110.                         # Next, the form_base will be executed again.
  111.                         # This continues as long as the form is incomplete.
  112.         __end__
  113.         set _prepare ""
  114.         set description "Executes Python code"
  115.  
  116. define sketchpad warning_message
  117.         set duration "1000"
  118.         set description "Displays stimuli"
  119.         draw textline 0.0 0.0 "You didn't answer all the questions..." center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top