forked from expfactory/v1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
holt_laury_survey.html
243 lines (219 loc) · 17 KB
/
holt_laury_survey.html
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
<!DOCTYPE html><html class=''>
<head>
<meta charset='UTF-8'>
<meta name="robots" content="noindex">
<title>The Experiment Factory: Survey</title>
<link rel='stylesheet' type='text/css' href='https://code.getmdl.io/1.1.1/material.blue-red.min.css'>
<link rel='stylesheet' type='text/css' href='static/css/surveys.css'>
<link rel='stylesheet' type='text/css' href='static/js/jquery/ui/smoothness/jquery-ui-1.10.4.custom.min.css'>
</head>
<body>
<script src='static/js/jquery/jquery-2.1.1.min.js'></script>
<script src='https://code.getmdl.io/1.1.1/material.min.js'></script>
<script src='static/js/jquery/ui/jquery-ui-1.10.4.custom.min.js'></script>
<script src='static/js/jquery/jquery.wizard.js'></script>
<script src='static/js/jquery/form/jquery.form-3.50.js'></script>
<script src='static/js/jquery/validate/jquery.validate-1.12.0.min.js'></script>
<div class="experiment-layout mdl-layout mdl-layout--fixed-header mdl-js-layout mdl-color--grey-100">
<div class="experiment-ribbon"></div>
<main class="experiment-main mdl-layout__content">
<div class="experiment-container mdl-grid">
<div class="mdl-cell mdl-cell--2-col mdl-cell--hide-tablet mdl-cell--hide-phone">
</div>
<div class="experiment-content mdl-color--white mdl-shadow--4dp content mdl-color-text--grey-800 mdl-cell mdl-cell--8-col">
<div id="questions">
<form name="questions" action="#", method="POST">
<div class="step">
<h3>Welcome to this survey. Press <strong>Next</strong> to begin.</h3><br><br><br><br></div>
<div class="step">
<h3>In this experiment you will be presented with a series of lottery choices. Your job is to indicate which option you would prefer for each of the ten paired lottery choices.</h3><br><br><br><br></div>
<div class="step">
<p id="holt_laury_survey_2_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_2_0">
<input type="radio" id="option-holt_laury_survey_2_0" class="mdl-radio__button required page3" name="holt_laury_survey_2_options" value="1" meta-options="10% chance of $100 <br> 90% chance of $80|10% chance of $190 <br> 90% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">10% chance of $100 <br> 90% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_2_1">
<input type="radio" id="option-holt_laury_survey_2_1" class="mdl-radio__button required page3" name="holt_laury_survey_2_options" value="2" meta-options="10% chance of $100 <br> 90% chance of $80|10% chance of $190 <br> 90% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">10% chance of $190 <br> 90% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_3_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_3_0">
<input type="radio" id="option-holt_laury_survey_3_0" class="mdl-radio__button required page3" name="holt_laury_survey_3_options" value="1" meta-options="20% chance of $100 <br> 80% chance of $80|20% chance of $190 <br> 80% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">20% chance of $100 <br> 80% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_3_1">
<input type="radio" id="option-holt_laury_survey_3_1" class="mdl-radio__button required page3" name="holt_laury_survey_3_options" value="2" meta-options="20% chance of $100 <br> 80% chance of $80|20% chance of $190 <br> 80% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">20% chance of $190 <br> 80% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_4_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_4_0">
<input type="radio" id="option-holt_laury_survey_4_0" class="mdl-radio__button required page3" name="holt_laury_survey_4_options" value="1" meta-options="30% chance of $100 <br> 70% chance of $80|30% chance of $190 <br> 70% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">30% chance of $100 <br> 70% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_4_1">
<input type="radio" id="option-holt_laury_survey_4_1" class="mdl-radio__button required page3" name="holt_laury_survey_4_options" value="2" meta-options="30% chance of $100 <br> 70% chance of $80|30% chance of $190 <br> 70% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">30% chance of $190 <br> 70% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_5_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_5_0">
<input type="radio" id="option-holt_laury_survey_5_0" class="mdl-radio__button required page3" name="holt_laury_survey_5_options" value="1" meta-options="40% chance of $100 <br> 60% chance of $80|40% chance of $190 <br> 60% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">40% chance of $100 <br> 60% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_5_1">
<input type="radio" id="option-holt_laury_survey_5_1" class="mdl-radio__button required page3" name="holt_laury_survey_5_options" value="2" meta-options="40% chance of $100 <br> 60% chance of $80|40% chance of $190 <br> 60% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">40% chance of $190 <br> 60% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_6_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_6_0">
<input type="radio" id="option-holt_laury_survey_6_0" class="mdl-radio__button required page3" name="holt_laury_survey_6_options" value="1" meta-options="50% chance of $100 <br> 50% chance of $80|50% chance of $190 <br> 50% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">50% chance of $100 <br> 50% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_6_1">
<input type="radio" id="option-holt_laury_survey_6_1" class="mdl-radio__button required page3" name="holt_laury_survey_6_options" value="2" meta-options="50% chance of $100 <br> 50% chance of $80|50% chance of $190 <br> 50% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">50% chance of $190 <br> 50% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_7_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_7_0">
<input type="radio" id="option-holt_laury_survey_7_0" class="mdl-radio__button required page3" name="holt_laury_survey_7_options" value="1" meta-options="60% chance of $100 <br> 40% chance of $80|60% chance of $190 <br> 40% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">60% chance of $100 <br> 40% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_7_1">
<input type="radio" id="option-holt_laury_survey_7_1" class="mdl-radio__button required page3" name="holt_laury_survey_7_options" value="2" meta-options="60% chance of $100 <br> 40% chance of $80|60% chance of $190 <br> 40% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">60% chance of $190 <br> 40% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_8_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_8_0">
<input type="radio" id="option-holt_laury_survey_8_0" class="mdl-radio__button required page3" name="holt_laury_survey_8_options" value="1" meta-options="70% chance of $100 <br> 30% chance of $80|70% chance of $190 <br> 30% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">70% chance of $100 <br> 30% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_8_1">
<input type="radio" id="option-holt_laury_survey_8_1" class="mdl-radio__button required page3" name="holt_laury_survey_8_options" value="2" meta-options="70% chance of $100 <br> 30% chance of $80|70% chance of $190 <br> 30% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">70% chance of $190 <br> 30% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_9_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_9_0">
<input type="radio" id="option-holt_laury_survey_9_0" class="mdl-radio__button required page3" name="holt_laury_survey_9_options" value="1" meta-options="80% chance of $100 <br> 20% chance of $80|80% chance of $190 <br> 20% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">80% chance of $100 <br> 20% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_9_1">
<input type="radio" id="option-holt_laury_survey_9_1" class="mdl-radio__button required page3" name="holt_laury_survey_9_options" value="2" meta-options="80% chance of $100 <br> 20% chance of $80|80% chance of $190 <br> 20% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">80% chance of $190 <br> 20% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_10_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_10_0">
<input type="radio" id="option-holt_laury_survey_10_0" class="mdl-radio__button required page3" name="holt_laury_survey_10_options" value="1" meta-options="90% chance of $100 <br> 10% chance of $80|90% chance of $190 <br> 10% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">90% chance of $100 <br> 10% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_10_1">
<input type="radio" id="option-holt_laury_survey_10_1" class="mdl-radio__button required page3" name="holt_laury_survey_10_options" value="2" meta-options="90% chance of $100 <br> 10% chance of $80|90% chance of $190 <br> 10% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">90% chance of $190 <br> 10% chance of $5</span>
</label><br><br><br><br>
<p id="holt_laury_survey_11_options">Please indicate your preference between each of the pairs of gambles.</p>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_11_0">
<input type="radio" id="option-holt_laury_survey_11_0" class="mdl-radio__button required page3" name="holt_laury_survey_11_options" value="1" meta-options="100% chance of $100 <br> 0% chance of $80|100% chance of $190 <br> 0% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">100% chance of $100 <br> 0% chance of $80</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-holt_laury_survey_11_1">
<input type="radio" id="option-holt_laury_survey_11_1" class="mdl-radio__button required page3" name="holt_laury_survey_11_options" value="2" meta-options="100% chance of $100 <br> 0% chance of $80|100% chance of $190 <br> 0% chance of $5" meta-text="Please indicate your preference between each of the pairs of gambles.">
<span class="mdl-radio__label">100% chance of $190 <br> 0% chance of $5</span>
</label><br><br><br><br></div>
<div class="step">
<h3>Congratulations for completing this survey! Press <strong>finish</strong> to continue.</h3><br><br><br><br></div>
<div class="navigation">
<ul class="clearfix">
<li><button type="button" name="backward" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent backward">Previous</button></li>
<li><button type="button" name="forward" class="forward mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Next</button></li>
<li><button type="submit" name="process" class="submit mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Finish</button></li>
</ul>
</div>
<div class="pad">
<div id="progressbar"></div>
</div>
</form>
</div>
<script>
$( document ).ready(function() {
expfactory_finished = false;
// Basic wizard with progress bar
$( "#progressbar" ).progressbar();
$( "#questions" ).wizard({
stepsWrapper: "#wrapped",
submit: ".submit",
beforeForward: function( event, state ) {
// Function to add message that answer is required
function is_required(elements){
var missing = false;
elements.each(function(index,element){
var pid = "#" + $(element).attr("name")
$(pid).css("color","red")
missing = true;
});
if (missing == true){
alert("Please answer all required questions in red.");
}
}
if ( state.stepIndex === 3 ) {
if (($.unique($(`.page3.required[type=number],.page3.required:text`).map(function(){return $(this).attr(`meta-text`)})).map(function() {return $(`[meta-text*="` + this + `"].required[type=number], [meta-text*="` + this + `"].required:text`).filter(function() { return $(this).val();}).length > 0}).get().indexOf(false) != -1) || ($.unique($(`.page3.required:not([type=number]):not(:text)`).map(function(){return $(this).attr(`meta-text`)})).map(function() {return $(`[meta-text*="` + this + `"].required:checked`).length > 0}).get().indexOf(false) != -1)){
is_required($(`.page3.required:not(checked)`));
return false;
} else {
expfactory_finished=true;
}}
return !!$( this ).wizard( "form" ).valid();
},
afterSelect: function( event, state ) {
$( "#progressbar" ).progressbar( "value", state.percentComplete );
if (expfactory_finished == true){
$(".submit").enable();
}
}
// Form submission
}).wizard( "form" ).submit(function( event ) {
event.preventDefault();
// Save data to browser
var $inputs = $("input:checked");
var $text = $("input:text")
var $number = $("input[type = number]")
var $elements = $inputs.add($text).add($number)
var results = []
$elements.each(function(index, element) {
var result = {}
if ($.inArray( $(element).attr("name"), [ "forward", "backward", "process"] ) == -1) {
result.name = $(element).attr("name");
if ($(element).attr("value") == undefined) {
result.value = $(element).val();
} else {
result.value = $(element).attr("value");
}
result.options = $(element).attr("meta-options");
result.text = $(element).attr("meta-text");
results.push(result);
}
})
var data = "text/json;charset=utf-8," + JSON.stringify(results);
var a = document.createElement('a');
a.title = "Download"
a.id = "download"
a.type = "button"
a.download = 'expfactory_result.json';
a.href = 'data:' + data;
$(".submit").html("Download")
$(".submit").click(function(){
$("body").append(a)
a.click()
})
// Validation
}).validate({
errorPlacement: function( error, element ) {
if ( element.is( ":radio" ) || element.is( ":checkbox" ) ) {
error.insertBefore( element.next() );
} else {
error.insertAfter( element );
}
}
});
});
</script>
</body>
</html>