There are examples in the ExampleScripts folder under RatingScale\_GUI to see how to have the rating available. You can use different yield statements to trigger the rating GUI to show up.
Add this line to show a rating:
yieldsightlab.showRatings("What Is Your Answer?")
Can set Choice Text and adjust options
yieldsightlab.showRatings('What Is Your Answer?',ratingScale=["Yes","No","Unsure"])
importsightlab_utils.sightlabasslfromsightlab_utils.settingsimport*sightlab=sl.SightLab()scaleList=["Yes","No","Unsure"]defsightLabExperiment():whileTrue:yieldviztask.waitKeyDown(' ')yieldsightlab.startTrial()yieldviztask.waitKeyDown(' ')yieldsightlab.showRatings('What Is Your Answer?',ratingScale=scaleList,pauseTimer=True)yieldsightlab.endTrial()viztask.schedule(sightlab.runExperiment)viztask.schedule(sightLabExperiment)
For getting access to the rating value you can use this code:
chosen_rating=sightlab.ratingChoice
And for something to change based on the rating value:
ifchosen_rating>=8:print("Rating too high.")
There are many options available to trigger an event. Here are just a few examples:
Standard viztask commands, such as when a media file stops playing, an animation finishes or a button is pressed.
Using proximity sensors with vizproximity.waitEnter (if you have a proximity sensor already setup, for more on proximity sensors see here)
Using a grab event to be triggered when an object is grabbed.
A gaze event (i.e. when you view an object), see the example RatingScale_after_view for this scenario in the ExampleScripts folder
And much more
When you run the experiment now the rating will show up after the specified trigger.
Use the right hand trigger to proceed and the left and right trackpad or thumbstick to choose the answers. For the desktop use the left mouse button and arrow keys.
The chosen values will also be saved in the trial_data.csv file
scaleList=["Yes","No","Unsure"]showRatings(message,ratingScale=["0","1","2","3","4","5","6","7","8","9","10"],color=viz.WHITE,characterLimit=8,pauseTimer=False,)yieldsightlab.showRatings("What Is Your Answer?",ratingScale=scaleList,pauseTimer=True)
There is also the option for a startRating or endRating (note: If using this method with the GUI it is best to set the Start and End conditions to 'None' and use code to set the start and end conditions).
yieldsightlab.endTrial(endRatings={"message":"Which One Do You Prefer?","ratingScale":["Left","Right"]})
To add longer questions, you can use a combination of instructions and ratings, as in this example. This also shows using vizinput to collect demographics and save them to the data file.
importsightlab_utils.sightlabasslfromsightlab_utils.settingsimport*sightlab=sl.SightLab(gui=False,pid=False)env=vizfx.addChild("sightlab_resources/environments/DeckersOffice.OSGB")sightlab.setEnvironment(env)sightlab.setStartText(' ')#run sightlab experimentdefsightLabExperiment():yieldviztask.waitEvent(EXPERIMENT_START)foriinrange(0,sightlab.getTrialCount()):yieldsightlab.startTrial()importvizinput# Create an empty dictionary to store responsesresponses={}# Collect demographic dataresponses['Age']=vizinput.input("What is your age?")responses['Gender']=vizinput.choose("What is your gender?",["Male","Female","Other","Prefer not to answer"])responses['Ethnicity']=vizinput.choose("What is your ethnicity?",["White/Caucasian (non-Hispanic)","African American","Hispanic/Latino","Asian/Pacific Islander","Middle Eastern/West Asian","Other"])# Save responses to experiment summaryforkey,valueinresponses.items():sightlab.setExperimentSummaryData(key,value)vizinput.message("Please enter your name in the space provided.")responses['Name']=vizinput.input("Enter your name:")sightlab.setExperimentSummaryData("Name",responses['Name'])yieldvizinput.message("By clicking continue, you indicate you consent to participate in the study. Once you click forward, the simulation will begin.")yieldviztask.waitTime(2)# Survey Questionsyieldsightlab.showInstructions("Reflecting on your experience so far, \n\n please indicate your agreement with the following statements:",pauseTimer=True)yieldviztask.waitEvent('triggerPress')yieldsightlab.hideInstructions(endFade=False)yieldsightlab.setDataLoggingState(1)yieldsightlab.showRatings("I found the experience engaging.",ratingScale=["1","2","3","4","5"],endFade=False)responses['Experience_Engagement']=sightlab.ratingChoiceyieldsightlab.showRatings("The experience felt realistic.",ratingScale=["1","2","3","4","5"],endFade=False)responses['Experience_Realism']=sightlab.ratingChoiceyieldsightlab.showRatings("The purpose of the experience was clear.",ratingScale=["1","2","3","4","5"],endFade=False)responses['Experience_Clarity']=sightlab.ratingChoiceyieldsightlab.showRatings("I enjoyed participating in the experience.",ratingScale=["1","2","3","4","5"],endFade=False)responses['Experience_Enjoyment']=sightlab.ratingChoiceyieldsightlab.showInstructions("Please rate how well each of the following \n\n statements describes your thoughts, feelings, and behaviors:",pauseTimer=True)yieldviztask.waitEvent('triggerPress')yieldsightlab.hideInstructions(endFade=False)yieldsightlab.setDataLoggingState(1)yieldsightlab.showRatings("I enjoy social interactions.",ratingScale=["1","2","3","4","5"],endFade=False)responses['Personality_Social']=sightlab.ratingChoiceyieldsightlab.showRatings("I am naturally curious about new experiences.",ratingScale=["1","2","3","4","5"],endFade=False)responses['Personality_Curious']=sightlab.ratingChoiceyieldsightlab.showRatings("I adapt easily to new situations.",ratingScale=["1","2","3","4","5"],endFade=False)responses['Personality_Adaptability']=sightlab.ratingChoiceyieldsightlab.showRatings("I can focus on a task for extended periods.",ratingScale=["1","2","3","4","5"])responses['Personality_Focus']=sightlab.ratingChoice# Save responses to experiment summaryforkey,valueinresponses.items():sightlab.setExperimentSummaryData(key,value)yieldsightlab.endTrial(endExperimentText='Thank You for Participating')viztask.schedule(sightlab.runExperiment)viztask.schedule(sightLabExperiment)