Skip to content

Commit bfbdd98

Browse files
committed
add initial screen
1 parent 0c3a5a3 commit bfbdd98

File tree

2 files changed

+71
-59
lines changed

2 files changed

+71
-59
lines changed

custom_startup.py

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,59 +28,69 @@ def _validate_code(exp):
2828

2929
@Subroutine
3030
def InputSubject(self):
31-
with Parallel():
32-
with Parallel(blocking=False):
33-
MouseCursor()
34-
recOut = Rectangle(width=s(INFO_WIDTH) + s(20),
35-
height=s(INFO_HEIGHT) + s(20),
36-
color=INFO_OUTLINE_COLOR)
37-
recin = Rectangle(width=s(INFO_WIDTH),
38-
height=s(INFO_HEIGHT),
39-
color=INFO_COLOR)
40-
lbl = Label(text=CogBatt_config.EXP_NAME, center_x=recin.center_x,
41-
top=recin.top - s(10),
42-
font_size=s(INFO_FONT_SIZE))
43-
idIn = TextInput(width=s(TEXT_INPUT_WIDTH),
44-
height=s(TEXT_INPUT_HEIGHT),
45-
font_size=s(INFO_FONT_SIZE),
46-
center_x=recin.center_x,
47-
top=lbl.bottom - s(20),
48-
multiline=False,
49-
text="",
50-
disabled=False,
51-
hint_text="Prolific Worker ID",
52-
write_tab=False)
53-
codeIn = TextInput(width=s(TEXT_INPUT_WIDTH),
54-
height=s(TEXT_INPUT_HEIGHT),
55-
font_size=s(INFO_FONT_SIZE),
56-
center_x=recin.center_x,
57-
top=lbl.bottom - s(80),
58-
multiline=False,
59-
text="",
60-
disabled=False,
61-
hint_text="4 digit task code",
62-
write_tab=False)
63-
bc = Button(text="Continue", font_size=s(INFO_FONT_SIZE),
64-
height=s(INFO_BUTTON_HEIGHT),
65-
width=s(INFO_BUTTON_WIDTH),
66-
right=recin.right - s(20),
67-
bottom=recin.bottom + s(20),
68-
name="C",
69-
background_normal="",
70-
background_color=INFO_OUTLINE_COLOR,
71-
disabled=True)
72-
with Serial():
73-
with While(
74-
(Ref.object(codeIn.text).__len__() < 4)
75-
or (Ref(str, idIn.text) == '')
76-
):
77-
Wait(0.1)
78-
bc.disabled = False
31+
with Serial():
32+
# Present initial CogBatt instructions.
33+
Label(text="Welcome to the Mood and Cognition Tasks!"
34+
"\n\nYou may press 'Shift' + 'Esc' to exit at any time. "
35+
"Though your progress will only be saved at the end of each task."
36+
"\n\nPress any button to continue.",
37+
font_size=s(CogBatt_config.INST_FONT),
38+
text_size=(s(700), None))
39+
with UntilDone():
40+
KeyPress()
41+
with Parallel():
42+
with Parallel(blocking=False):
43+
MouseCursor()
44+
recOut = Rectangle(width=s(INFO_WIDTH) + s(20),
45+
height=s(INFO_HEIGHT) + s(20),
46+
color=INFO_OUTLINE_COLOR)
47+
recin = Rectangle(width=s(INFO_WIDTH),
48+
height=s(INFO_HEIGHT),
49+
color=INFO_COLOR)
50+
lbl = Label(text="Mood and Cognition Tasks", center_x=recin.center_x,
51+
top=recin.top - s(10),
52+
font_size=s(INFO_FONT_SIZE))
53+
idIn = TextInput(width=s(TEXT_INPUT_WIDTH),
54+
height=s(TEXT_INPUT_HEIGHT),
55+
font_size=s(INFO_FONT_SIZE),
56+
center_x=recin.center_x,
57+
top=lbl.bottom - s(20),
58+
multiline=False,
59+
text="",
60+
disabled=False,
61+
hint_text="Prolific Worker ID",
62+
write_tab=False)
63+
codeIn = TextInput(width=s(TEXT_INPUT_WIDTH),
64+
height=s(TEXT_INPUT_HEIGHT),
65+
font_size=s(INFO_FONT_SIZE),
66+
center_x=recin.center_x,
67+
top=lbl.bottom - s(80),
68+
multiline=False,
69+
text="",
70+
disabled=False,
71+
hint_text="4 digit task code",
72+
write_tab=False)
73+
bc = Button(text="Continue", font_size=s(INFO_FONT_SIZE),
74+
height=s(INFO_BUTTON_HEIGHT),
75+
width=s(INFO_BUTTON_WIDTH),
76+
right=recin.right - s(20),
77+
bottom=recin.bottom + s(20),
78+
name="C",
79+
background_normal="",
80+
background_color=INFO_OUTLINE_COLOR,
81+
disabled=True)
82+
with Serial():
83+
with While(
84+
(Ref.object(codeIn.text).__len__() < 4)
85+
or (Ref(str, idIn.text) == '')
86+
):
87+
Wait(0.1)
88+
bc.disabled = False
7989

80-
bp = ButtonPress(buttons=[bc])
81-
with If(
82-
(bp.pressed == "C")
83-
):
84-
Func(self.exp._change_smile_subj, Ref.object(idIn.text).lower().strip())
85-
Func(self.exp.set_var, '_code', Ref.object(codeIn.text).lower().strip())
86-
Func(_validate_code, Ref.object(self.exp))
90+
bp = ButtonPress(buttons=[bc])
91+
with If(
92+
(bp.pressed == "C")
93+
):
94+
Func(self.exp._change_smile_subj, Ref.object(idIn.text).lower().strip())
95+
Func(self.exp.set_var, '_code', Ref.object(codeIn.text).lower().strip())
96+
Func(_validate_code, Ref.object(self.exp))

main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,27 +105,29 @@
105105
error_screen(error='Invalid task code: ' + Ref(str, exp._code),
106106
message='You entered an incorrect task code, please double check the code '
107107
'listed on the website and try again. If it still does not work '
108-
'please contact Dylan Nielson at [email protected].'
108+
'please contact Dylan Nielson through Prolific or at [email protected].'
109109
)
110110

111111
with If(CogBatt_config.RUNNING_FROM_EXECUTABLE and (CogBatt_config.WORKER_ID_SOURCE != 'USER')):
112112
# Handles case where retrieval of worker id fails
113113
with If(exp.worker_id_dict['status'] == 'error'):
114114
error_screen(error='Failed to Retrieve Identifier: ' + exp.worker_id_dict['content'],
115-
message='Contact Dylan Nielson')
115+
message='Contact Dylan Nielson through Prolific or at [email protected]')
116116
# Handles case where retrieval of worker id is default placeholder
117117
with Elif((exp.worker_id_dict['content'] == CogBatt_config.WORKER_ID_PLACEHOLDER_VALUE)
118118
and (CogBatt_config.API_BASE_URL != 'NOSERVER')):
119119
error_screen(error='Non-Unique Identifier',
120-
message='Contact Dylan Nielson')
120+
message='Contact Dylan Nielson through Prolific or at [email protected]')
121121
# Error screen for failed GET request to retrieve blocks
122122
with If(exp.tasks_from_api['status'] == 'error'):
123123
error_screen(error='Failed to retrieve tasks.',
124124
message=exp.tasks_from_api['content'])
125125
# Handles case where there are no more blocks to run
126126
with Elif(number_of_tasks == 0):
127127
error_screen(error='No tasks to run.',
128-
message='Press next in the browser or return to the website via the link from prolific if that window is no longer open.')
128+
message='Press the "I have completed the tasks" button in the browser'
129+
' or return to the website via the link from Prolific '
130+
'if that window is no longer open.')
129131

130132
# Present initial CogBatt instructions.
131133
Label(text=CogBatt_config.INST_TEXT,

0 commit comments

Comments
 (0)