I created and experiment where the participant hears a sentence and has to click on the exact sentence heard by the participant which is displayed on the screen.
i have added code to display if the responses are correct or incorrect.but what I need is,I want to display the total score after a specific block.
following is the code provided to display the total score.somehow after the last stimuli the result is displayed and it is stuck there.
total score is not displayed.
please help
# Assume key_resp_corr is defined and holds the correctness of the response
if key_resp.corr == 1:
score += 1
else:
score += 0
# Update the text stimulus with the new score
score_text.text = f'Score: {score}'
# Draw the score text on the window
score_text.draw()
win.flip()
# Wait for a key press to proceed to the next trial
keys = event.getKeys()
if 'escape' in keys:
break
Close the window at the end of the experiment
win.close()
core.quit()
code ended.
i created a routine score_text and corresponding to text I have typed {score} to display the correct score.
you have to count the total score in feedbackout, not total_score.
Why you do include
from psychopy import visual, core, event
# Set up the window
win = visual.Window(size=(800, 600), fullscr=False)
# Create a text stimulus for displaying the score
score_text = visual.TextStim(win, text='Score: 0', pos=(0, 0))
# Initialize the score
score = 0
# Main experiment loop
while True:
# Run your experiment code here
# Assume key_resp_corr is defined and holds the correctness of the response
if key_resp.corr == 1:
score += 1
else:
score += 0
# Update the text stimulus with the new score
score_text.text = f'Score: {score}'
# Draw the score text on the window
score_text.draw()
win.flip()
# Wait for a key press to proceed to the next trial
keys = event.getKeys()
if 'escape' in keys:
break
# Close the window at the end of the experiment
win.close()
core.quit()
The Builder will write this code for you. You only need to write the code to calculate the total score and assign it to a variable.
Thank you so much for your help.Its working perfect.
Also, I would like to know if it is possible to add the following procedure to the current experiment.
I present 10 stimuli in a set and if the score is below 8 the experiment has to move to next set of 10 stimuli automatically. Can I add all the 10 sets of stimuli in a single excel sheet by leaving one row empty after each set? Is that how I should give the stimuli in conditions file? And if this is possible how can I do this
Please help!
Thank you