-
Notifications
You must be signed in to change notification settings - Fork 16
/
new_participant.jinja2
354 lines (336 loc) · 17 KB
/
new_participant.jinja2
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
{% extends "sitebase.jinja2" %}
{% set page_title = _("Consent") %}
{% set show_breadcrumbs = True %}
{% block head %}
<script type="text/javascript" src="/static/vendor/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/static/vendor/jquery-ui-1.12.1/jquery-ui.min.js"></script>
<script src="/static/vendor/js/jquery.validate.min.js"></script>
<script src="/static/vendor/bootstrap-4.4.1-dist/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript">
function min_validation(form) {
// needed because Safari does not honor required flag in inputs, or jquery validate
form = document.getElementById(form);
var valid = true;
if(form.participant_name.value.trim().length == 0) {
form.participant_name.className += " highlight";
valid = false;
}
return valid;
}
function validate18(form) {
var valid = min_validation(form);
form = document.getElementById(form);
if(!$("#age18_consent").is(":checked")) {
form.age18_consent.className += "highlight";
valid = false;
}
return valid;
}
function validate06(form) {
// needed because Safari does not honor required flag in inputs, or jquery validate
var valid = min_validation(form);
form = document.getElementById(form);
if(form.consent_parent.checked == false) {
form.consent_parent.className += " highlight";
valid = false;
}
if(form.parent_1_name.value.trim().length == 0) {
form.parent_1_name.className += " highlight";
valid = false;
}
return valid;
}
function validate712(form) {
// needed because Safari does not honor required flag in inputs, or jquery validate
var valid = min_validation(form);
form = document.getElementById(form);
if(form.consent_parent.checked == false) {
form.consent_parent.className += " highlight";
valid = false;
}
if(form.consent_child.checked == false) {
form.consent_child.className += " highlight";
valid = false;
}
if(form.consent_witness.checked == false) {
form.consent_witness.className += " highlight";
valid = false;
}
if(form.obtainer_name.value.trim().length == 0) {
form.obtainer_name.className += " highlight";
valid = false;
}
if(form.parent_1_name.value.trim().length == 0) {
form.parent_1_name.className += " highlight";
valid = false;
}
return valid;
}
function validate1317(form) {
// needed because Safari does not honor required flag in inputs, or jquery validate
var valid = min_validation(form);
form = document.getElementById(form);
if(form.consent_parent.checked == false) {
form.consent_parent.className += " highlight";
valid = false;
}
if(form.consent_child.checked == false) {
form.consent_child.className += " highlight";
valid = false;
}
if(form.parent_1_name.value.trim().length == 0) {
form.parent_1_name.className += " highlight";
valid = false;
}
return valid;
}
function change_consent_div(radio) {
$("#0-6-div").hide();
$("#7-12-div").hide();
$("#13-17-div").hide();
$("#18-plus-div").hide();
$("#"+ radio.value +"-div").show();
}
function relax_parents(box) {
var sec_parent = $("#" + box.form.id + "_parent_2_name");
if(box.checked) {
sec_parent.required = false;
} else {
sec_parent.required = true;
}
}
$(document).ready(function(e) {
$("#0-6-div").hide();
$("#7-12-div").hide();
$("#13-17-div").hide();
$("#18-plus-div").hide();
disableInputOnSubmit("#0-6-form", "#0-6-submit_button", "{{ _('Saving...') }}");
disableInputOnSubmit("#7-12-form", "#7-12-submit_button", "{{ _('Saving...') }}");
disableInputOnSubmit("#13-17-form", "#13-17-submit_button", "{{ _('Saving...') }}");
disableInputOnSubmit("#18-form", "#18-submit_button", "{{ _('Saving...') }}");
$("#home_page").click(function(){
window.open('{{home_url}}', '_self')
})
$("#create_source").click(function(){
//window.open('{{post_url}}', '_self')
//$("#source_modal").modal('hide');
$("#"+$(this).attr('form_id'))[0].submit();
})
$("#18-form, #0-6-form, #7-12-form, #13-17-form").submit(function(e){
e.preventDefault();
$form_id = $(this).attr('id');
if($form_id == "0-6-form"){
valid = validate06("0-6-form");
} else if ($form_id == "7-12-form") {
valid = validate712("7-12-form");
} else if ($form_id == "13-17-form") {
valid = validate1317("13-17-form")
} else if ($form_id == "18-form") {
valid = validate18("18-form")
}
var duplicate_source_check_msg = "{{ _('It looks like you are creating a new source that may be similar or the same as an existing source. If this is the same person as an existing source, please consider providing new samples or survey responses under that source') }}"
if(valid){
var name = $('#'+$form_id+'_participant_name').val();
$.ajax({
url: '{{ duplicate_email_check_url }}',
data:JSON.stringify({participant_name:name}),
contentType:"application/json",
type: 'POST',
success: function(response){
if(response.error !== undefined){
alert(response.error)
}
if(response.source_duplicate){
$("#source_msg").empty();
$("#source_msg").text(duplicate_source_check_msg);
$("#source_modal").modal('show');
$("#create_source").attr("form_id", $form_id);
$("#18-submit_button").attr("value", "I Accept")
$("#18-submit_button").prop("disabled", false)
} else if (response.error === undefined && !response.source_duplicate) {
$("#"+$form_id)[0].submit();
}
},
error: function(error){
console.log(error);
}
});
} else {
alert("fill all fields")
}
});
});
</script>
<style>
.scrolltext {
height: 400px;
overflow-x: hidden;
overflow-y: scroll;
width: 80%;
margin: 0 auto;
}
.required-field {
color: red;
display: inline-block;
}
</style>
{% endblock %}
{% block breadcrumb %}
<li class="breadcrumb-item active" aria-current="page">{{ _('Consent') }}</li>
{% endblock %}
{% block content%}
<h2>{{ tl['ADD_HUMAN_TITLE'] |e}}</h2>
{% if message %}
<h3 style="color: red">{{message |e}}</h3>
{% endif %}
{#
NOTE on 2022-08-30
We're intentionally hiding the under-18 consent options from all non-English users for the time being.
The only Spanish-speaking users who should be using this system are THDMI Spain participants, which is only open to adults.
As such, a conscious decision was made to not use the resources to translate and implement the under-18 consent/assent documents.
#}
<div id="age-ranges-div" style='text-align: left;padding: 10px'>
<h3>{{ tl['SEL_AGE_RANGE'] |e}}</h3>
{% if language_tag == "en_US" %}
<input type='radio' id='age-range-1' name='age-range' value='0-6' onchange="change_consent_div(this)"> <label for='age-range-1'>{{ tl['AGE_0_6'] |e}}</label><br />
<input type='radio' id='age-range-2' name='age-range' value='7-12' onchange="change_consent_div(this)"> <label for='age-range-2'>{{ tl['AGE_7_12'] |e}}</label><br />
<input type='radio' id='age-range-3' name='age-range' value='13-17' onchange="change_consent_div(this)"> <label for='age-range-3'>{{ tl['AGE_13_17'] |e}}</label><br />
{% endif %}
<input type='radio' id='age-range-4' name='age-range' value='18-plus' onchange="change_consent_div(this)"> <label for='age-range-4'>{{ tl['AGE_18'] |e}}</label>
<hr>
</div>
{% if language_tag == "en_US" %}
<div id="0-6-div" style='text-align: left;padding: 10px'>
<div class='scrolltext'>
{{ tl['CONSENT_YOUR_CHILD'] }}
{{ tl['PARTICIPATION_AGREEMENT'] }}
{{ tl['EXHIBIT_A'] }}
</div>
<div class="" id="consent">
<hr>
<a href="{{ _('https://oag.ca.gov/sites/all/files/agweb/pdfs/research/bill_of_rights.pdf') }}" target="_blank">{{ tl['BILL_OF_RIGHTS']|e}}</a><br/>
<form id="0-6-form" name="consent_info" action="{{ post_url }}" method="post">
<input type="hidden" name="age_range" value="0-6">
<p><input value="Yes" type="checkbox" name="consent_parent" id="consent_parent" required data-rule-required="true"> {{ tl['TEXT_I_HAVE_READ_PARENT'] |e}} <span class="required-field">*</span></p>
</div>
<table>
<tr><td><label for='participant_name'>{{ tl['PARTICIPANT_NAME'] |e}}</label></td><td><input tabindex="2" type="text" name="participant_name" id="0-6-form_participant_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
<tr><td>{{ tl['PARTICIPANT_PARENT_1'] |e}}</td><td><input tabindex="7" type="text" name="parent_1_name" id="0-6-form_parent_1_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
<tr><td>{{ tl['PARTICIPANT_PARENT_2'] |e}}</td><td><input tabindex="8" type="text" name="parent_2_name" id="0-6-form_parent_2_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
<tr><td>{{ tl['PARTICIPANT_DECEASED_PARENTS'] |e}}</td><td><input tabindex="9" type="checkbox" name="deceased_parent" id="deceased_parent" value="true" onclick="relax_parents(this)"></td></tr>
<tr><td><input type="submit" id="0-6-submit_button" value="{{ _('I Accept') }}"></td><td></td></tr>
</table>
</form>
</div>
<div id="7-12-div" style='text-align: left;padding: 10px'>
<div class='scrolltext'>
{{ tl['ASSENT_7_12'] }}
</div>
<div class="" id="consent">
<hr>
<form id="7-12-form" name="consent_info" action="{{ post_url }}" method="post">
<input type="hidden" name="age_range" value="7-12">
<p><input value="Yes" type="checkbox" name="consent_child" id="consent_child" required data-rule-required="true"> {{ tl['TEXT_I_HAVE_READ_SIMPLIFIED'] |e}} <span class="required-field">*</span></p>
</div>
<p><table>
<tr><td><label for='participant_name'>{{ tl['PARTICIPANT_NAME'] |e}}</label></td><td><input tabindex="2" type="text" name="participant_name" id="7-12-form_participant_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
</table></p>
<div>
<h4>{{ tl['PERSON_ATTAINING_ASSENT'] |e}}</h4>
<p><input value="Yes" type="checkbox" name="consent_witness" id="consent_witness" required data-rule-required="true"> {{ tl['TEXT_ASSENT_WITNESS'] |e}} <span class="required-field">*</span></p>
</div>
<p><table>
<tr><td><label for='obtainer_name'>{{ tl['OBTAINER_NAME'] |e}}</label></td><td><input tabindex="2" type="text" name="obtainer_name" id="obtainer_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
</table></p>
<hr>
<div class='scrolltext'>
{{ tl['CONSENT_YOUR_CHILD'] }}
{{ tl['PARTICIPATION_AGREEMENT'] }}
{{ tl['EXHIBIT_A'] }}
</div>
<div class="" id="consent">
<hr>
<a href="{{ _('https://oag.ca.gov/sites/all/files/agweb/pdfs/research/bill_of_rights.pdf') }}" target="_blank">{{ tl['BILL_OF_RIGHTS']|e}}</a><br/>
<p><input value="Yes" type="checkbox" name="consent_parent" id="consent_parent" required data-rule-required="true"> {{ tl['TEXT_I_HAVE_READ_PARENT'] |e}} <span class="required-field">*</span></p>
</div>
<table>
<tr><td>{{ tl['PARTICIPANT_PARENT_1'] |e}}: </td><td><input tabindex="7" type="text" name="parent_1_name" id="7-12-form_parent_1_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
<tr><td>{{ tl['PARTICIPANT_PARENT_2'] |e}}: </td><td><input tabindex="8" type="text" name="parent_2_name" id="7-12-form_parent_2_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
<tr><td>{{ tl['PARTICIPANT_DECEASED_PARENTS'] |e}}: </td><td><input tabindex="9" type="checkbox" name="deceased_parent" id="deceased_parent" value="true" onclick="relax_parents(this)"></td></tr>
<tr><td><input type="submit" id="7-12-submit_button" value="{{ _('I Accept') }}"></td><td></td></tr>
</table>
</form>
</div>
<div id="13-17-div" style='text-align: left;padding: 10px'>
<div class='scrolltext'>
{{ tl['ASSENT_13_17'] }}
</div>
<div class="" id="consent">
<hr>
<form id="13-17-form" name="consent_info" action="{{ post_url }}" method="post">
<input type="hidden" name="age_range" value="13-17">
<p><input value="Yes" type="checkbox" name="consent_child" id="consent_child" required data-rule-required="true"> {{ tl['TEXT_I_HAVE_READ_1'] |e}} <span class="required-field">*</span></p>
</div>
<p><table>
<tr><td><label for='participant_name'>{{ tl['PARTICIPANT_NAME'] |e}}: </label></td><td><input tabindex="2" type="text" name="participant_name" id="13-17-form_participant_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
</table></p>
<hr>
<div class='scrolltext'>
{{ tl['CONSENT_YOUR_CHILD'] }}
{{ tl['PARTICIPATION_AGREEMENT'] }}
{{ tl['EXHIBIT_A'] }}
</div>
<div class="" id="consent">
<hr>
<a href="{{ _('https://oag.ca.gov/sites/all/files/agweb/pdfs/research/bill_of_rights.pdf') }}" target="_blank">{{ tl['BILL_OF_RIGHTS']|e}}</a><br/>
<p><input value="Yes" type="checkbox" name="consent_parent" id="consent_parent" required data-rule-required="true"> {{ tl['TEXT_I_HAVE_READ_PARENT'] |e}} <span class="required-field">*</span></p>
</div>
<table>
<tr><td>{{ tl['PARTICIPANT_PARENT_1'] |e}}: </td><td><input tabindex="7" type="text" name="parent_1_name" id="13-17-form_parent_1_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
<tr><td>{{ tl['PARTICIPANT_PARENT_2'] |e}}: </td><td><input tabindex="7" type="text" name="parent_2_name" id="13-17-form_parent_2_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
<tr><td>{{ tl['PARTICIPANT_DECEASED_PARENTS'] |e}}: </td><td><input tabindex="9" type="checkbox" name="deceased_parent" id="deceased_parent" value="true" onclick="relax_parents(this)"></td></tr>
<tr><td><input type="submit" id="13-17-submit_button" value="{{ _('I Accept') }}"></td><td></td></tr>
</table>
</form>
</div>
{% endif %}
<div id="18-plus-div" style='text-align: left;padding: 10px'>
<div class='scrolltext'>
{{ tl['CONSENT_18'] }}
{{ tl['PARTICIPATION_AGREEMENT'] }}
{{ tl['EXHIBIT_A'] }}
</div>
<div class="" id="consent">
<hr>
<a href="{{ _('https://oag.ca.gov/sites/all/files/agweb/pdfs/research/bill_of_rights.pdf') }}" target="_blank">{{ tl['BILL_OF_RIGHTS']|e}}</a><br/>
<form id="18-form" name="consent_info" action="{{post_url}}" method="post">
<input type="hidden" name="age_range" value="18-plus">
<p><input value="Yes" type="checkbox" name="consent" id="age18_consent" required data-rule-required="true"> {{ tl['TEXT_I_HAVE_READ_1'] |e}} <span class="required-field">*</span></p>
</div>
<p><table>
<tr><td><label for='participant_name'>{{ tl['PARTICIPANT_NAME'] |e}}: </label></td><td><input tabindex="2" type="text" name="participant_name" id="18-form_participant_name" required data-rule-required="true"> <span class="required-field">*</span></td></tr>
<tr><td><input type="submit" id="18-submit_button" value="{{ _('I Accept') }}"></td><td></td></tr>
</table></p>
</form>
</div>
<!-- Modal -->
<div class="modal fade" id="source_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Warning</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p id="source_msg"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="home_page">Return to Home Page</button>
<button type="button" class="btn btn-primary" id="create_source">Proceed with Creating New Source</button>
</div>
</div>
</div>
</div>
{% endblock %}