-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconsent.js
227 lines (194 loc) · 5.84 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
// Keeps track whether or not consent has been given.
let consent_given = false;
/*
* This fragment of html will be displayed in the beginning of you experiment.
* You should fillout the contents of your information letter here.
* It is displayed as html, the current html should be replace with
* your information letter.
*/
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>';
/*
* Debrieving given when the participant doesn't consent.
*/
const DEBRIEF_MESSAGE_NO_CONSENT =
"<h1>" +
"End of the experiment" +
"</h1>" +
"<h2>" +
"No consent has been given." +
"</h2>";
const CONSENT_STATEMENT =
'Yes, I consent to the use of my answers for scientific research.';
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.";
// Adds UU styling to the consent forms.
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>
`;
// displays the informed consent page
let consent_block = {
type: jsPsychSurveyMultiSelect,
data : {uil_save : true},
preamble: CONSENT_HTML_STYLE_UU + CONSENT_HTML,
required_message: IF_REQUIRED_FEEDBACK_MESSAGE,
button_label: CONTINUE_BUTTON_TEXT,
questions: [
{
prompt: "",
options: [CONSENT_STATEMENT],
horizontal: true,
required: false,
button_label: CONTINUE_BUTTON_TEXT,
name: CONSENT_REFERENCE_NAME
}
],
on_finish: function(data){
data.consent_choice_response = data.response.consent[0];
data.rt = Math.round(data.rt);
}
};
/**
* Obtains the consent of the participant.
*
* @returns {string}
*/
function getConsentData()
{
let data = jsPsych.data.get().select('consent_choice_response');
return data.values[0];
}
// Is displayed when no consent has been given.
let no_consent_end_screen = {
type: jsPsychHtmlButtonResponse,
stimulus: DEBRIEF_MESSAGE_NO_CONSENT,
choices: [],
trial_duration: FINISH_TEXT_DUR,
on_finish: function (data){
jsPsych.endExperiment()
data.rt = Math.round(data.rt);
}
};
// Tests wheter consent has been given.
// If no consent has been given It displays the
// no_consent_screen.
//
let if_node_consent = {
timeline: [no_consent_end_screen],
conditional_function: function(data) {
let mydata = getConsentData();
if (mydata == CONSENT_STATEMENT) {
consent_given = true;
return false;
} else {
return true;
}
}
}
let consent_procedure = {
timeline: [consent_block, if_node_consent]
}