-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsent.js
198 lines (169 loc) · 5.02 KB
/
consent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// stores wheter or not consent is given.
let g_consent_given = null;
/* CSS style for the consent form */
const CONSENT_HTML_STYLE_UU = `<style>
body {
background: rgb(246, 246, 246);
font-family: "Open Sans","Frutiger",Helvetica,Arial,sans-serif;
color: rgb(33, 37, 41);
text-align: left;
}
p {
line-height: 1.4; /* Override paragraph for better readability */
}
label {
margin-bottom: 0;
}
h1, h2{
font-size: 2rem;
}
h6 {
font-size: 1.1rem;
}
/* Input styles */
form > table th {
padding-left: 10px;
vertical-align: middle;
}
input, textarea, select {
border-radius: 0;
border: 1px solid #d7d7d7;
padding: 5px 10px;
line-height: 20px;
font-size: 16px;
}
input[type=submit], input[type=button], button, .button, .jspsych-btn {
background: #000;
color: #fff;
border: none;
font-weight: bold;
font-size: 15px;
padding: 0 20px;
line-height: 42px;
width: auto;
min-width: auto;
cursor: pointer;
display: inline-block;
border-radius: 0;
}
input[type="checkbox"], input[type="radio"]
{
width: auto;
}
button[type=submit], input[type=submit], .button-colored {
background: #ffcd00;
color: #000000;
}
button[type=submit].button-black, input[type=submit].button-black {
background: #000;
color: #fff;
}
button a, .button a,
button a:hover, .button a:hover,
a.button, a.button:hover {
color: #fff;
text-decoration: none;
}
.button-colored a,
.button-colored a:hover,
a.button-colored,
a.button-colored:hover {
color: #000;
}
/* Table styles */
table thead th {
border-bottom: 1px solid #ccc;
}
table tfoot th {
border-top: 1px solid #ccc;
}
table tbody tr:nth-of-type(odd) {
background: #eee;
}
table tbody tr:hover {
background: #ddd;
}
table tbody tr.no-background:hover, table tbody tr.no-background {
background: transparent;
}
table tbody td, table thead th, table tfoot th {
padding: 6px 5px;
}
/* Link styles */
a {
color: rgb(33, 37, 41);
text-decoration: underline;
transition: 0.2s ease color;
}
a:hover {
transition: 0.2s ease color;
color: rgb(85, 85, 95);
}
</style>
`
const CONSENT_HTML = `
<p>Insert your information letter here; for more information, see the <a href="https://fetc-gw.wp.hum.uu.nl/en/" target="_blank">FEtC-H website</a></p>
`
const DEBRIEF_MESSAGE_NO_CONSENT = `
<h1>End of the experiment</h1><BR><BR>
<h2>Thank you for <i>not</i> participating!</h2>
`;
const DEBRIEF_MESSAGE_NO_CONSENT_DURATION = 3000;
const CONSENT_STATEMENT = `
Yes, I consent to the use of my answers for scientific research.
`;
const PROCEED_BUTTON_TEXT = "Continue";
const CONSENT_REFERENCE_NAME = 'consent';
const IF_REQUIRED_FEEDBACK_MESSAGE = `
You must check the box next to '${CONSENT_STATEMENT}' in order to proceed to the experiment.
`
let consent_block = {
type: jsPsychSurveyMultiSelect,
preamble: CONSENT_HTML_STYLE_UU + CONSENT_HTML,
required_message: IF_REQUIRED_FEEDBACK_MESSAGE,
questions: [
{
prompt: "",
options: [CONSENT_STATEMENT],
horizontal: true,
required: false,
button_label: PROCEED_BUTTON_TEXT,
name: CONSENT_REFERENCE_NAME
}
],
on_finish: function(data){
let consent_choices = data.response.consent;
let consent_statement = consent_choices.find(
element => {return element === CONSENT_STATEMENT}
);
g_consent_given = consent_statement === CONSENT_STATEMENT;
if (typeof data.rt === 'number') {
data.rt = Math.round(data.rt);
}
}
};
let no_consent_end_screen = {
type: jsPsychHtmlButtonResponse,
stimulus: DEBRIEF_MESSAGE_NO_CONSENT,
choices: [],
trial_duration: DEBRIEF_MESSAGE_NO_CONSENT_DURATION,
on_finish: function (data){
if (typeof data.rt === 'number') {
data.rt = Math.round(data.rt);
}
jsPsych.endExperiment()
}
};
let if_node_consent = {
timeline: [no_consent_end_screen],
conditional_function: function(data){
if (g_consent_given){
return false;
} else {
return true;
}
}
}
let consent_procedure = {
timeline: [consent_block, if_node_consent]
}