-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep1.html
255 lines (233 loc) · 11.5 KB
/
step1.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
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Tutorial Task</title>
<link rel="stylesheet" href="{{url_for('static',filename='dist/css/style.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='dist/css/main.css')}}">
</head>
<body class="bg-white" onpaste="return false">
<script src="{{url_for('static',filename='dist/js/bundle.js')}}"></script>
<p class="text-gray-800 text-sm absolute top-0 right-0 p-1">
Prolific PID: {{prolific_pid}}
</p>
<div class="border-b-2 border-gray-100 py-6 text-center bg-gray-50 text-gray-800" id="header">
<h1 class="text-5xl font-bold m-0">Tutorial Task</h1>
</div>
{% if error_text %}
<P class="md:max-w-3xl mx-auto text-red-700 text-4xl font-bold text-center pt-8">
{{ error_text }}
</P>
{% else %}
<div class="md:max-w-3xl mx-auto mt-8 text-justify">
<p>
In this study, you will read a short passage of text, and come up with questions that can be answered from
the passage. You will then highlight the answers for your questions in the passage. In addition, you will
write questions and highlight answers that <i>look like</i> they could be correct, but are in fact wrong.
</p>
<p>
This tutorial will guide you through the task and the interface. During the tutorial, you will have to enter
some questions and mark some answer spans.
</p>
<h1 class="text-3xl font-normal leading-normal mt-0 mb-2">
Your task
</h1>
<p>
You are given several text passages. For each passage complete the following:
</p>
<ol class="list-decimal list-outside space-y-1 pl-8 text-left">
<li class="pl-3">
Read through the passage carefully.
</li>
<li class="pl-3">
Think of <b>three answerable questions</b> for which the answer is in the passage. Each question should
be answered by a <b>different</b> part of the passage.
</li>
<li class="pl-3">
Write down the answerable questions and for each, highlight the <b>shortest text</b> in the passage that
answers the question.
</li>
<li class="pl-3">
Think of <b>two unanswerable</b> questions for the passage. The passage should contain text that could
be an answer to your question, but in fact it's not.
</li>
<li class="pl-3">
Write down the unanswerable questions and, for each, mark the <b>could-be answer</b> text.
</li>
</ol>
<p>
So, in total, you will create five questions for each passage (three answerable and two unanswerable).
</p>
<p>
Now, try it yourself. The passage is the text with the orange background, and we already wrote down a
question for you.
</p>
<ol class="list-decimal list-outside space-y-1 pl-8 text-left">
<li class="pl-3">
Click on the button below that looks like
<span
style="border-left: 4px solid #008000; background-color: #00800026; padding: 4px 8px; border-radius: 3px;">
Answer 1
</span> <i> (if it's not visible, scroll down)</i>
</li>
<li class="pl-3">
Select the correct answer text by highlighting the words with your mouse.
<i>
(To do that, move your mouse to the text passage, click in front of the first word of the answer and
drag to the last word of the answer)
</i>
</li>
<li class="pl-3">
Click "Submit"
</li>
</ol>
<p class="mb-0">
If you want to remove the highlight, click the<svg class="h-5 w-5 ml-2 inline-flex"
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 15L3 9m0 0l6-6M3 9h12a6 6 0 010 12h-3" />
</svg> undo button, or click on the highlight and press the "Delete" button that appears on the
right.
</p>
</div>
<div class="py-4 bg-gray-50 border border-gray-300 border-y-2 mt-8">
<div id="label-studio"></div>
</div>
<div class="flex flex-col items-center pt-8 pb-12">
<button disabled="true" id="nextPageButton" type="submit" onclick="nextPage()" style="visibility: hidden;"
class="rounded-lg border border-gray-300 bg-gray-100 text-gray-600 block font-bold py-4 px-6 ml-2 flex items-center">
Next Page
<svg class="h-5 w-5 ml-2 fill-current" clasversion="1.1" viewBox="-49 141 512 512"
style="enable-background:new -49 141 512 512;">
<path id="XMLID_11_" d="M-24,422h401.645l-72.822,72.822c-9.763,9.763-9.763,25.592,0,35.355c9.763,9.764,25.593,9.762,35.355,0
l115.5-115.5C460.366,409.989,463,403.63,463,397s-2.634-12.989-7.322-17.678l-115.5-115.5c-9.763-9.762-25.593-9.763-35.355,0
c-9.763,9.763-9.763,25.592,0,35.355l72.822,72.822H-24c-13.808,0-25,11.193-25,25S-37.808,422-24,422z" />
</svg>
</button>
</div>
{% endif %}
<script>
const urlParameter = new URLSearchParams(window.location.search);
const study_id = urlParameter.get("STUDY_ID");
const session_id = urlParameter.get("SESSION_ID");
const prolific_pid = urlParameter.get("PROLIFIC_PID");
const language = urlParameter.get("language");
const paragraph_text = "The biggest city on the river Rhine is Cologne, Germany with a population of more than 1,050,000 people. ";
var data = { "text": paragraph_text };
var config = `
<View classname="p-4">
<View classname="px-6 bg-orange-100">
<Text name="text" value="$text" granularity="word"/>
</View>
<View classname="mt-12 bg-lime-200 bg-opacity-25 p-6">
` + generateQuestion(1, "#008000") + `
</View>
</View>
`;
function generateQuestion(questionNumber, label_color) {
return `
<View style="display: flex;">
<View>
<Header value="Question ` + questionNumber + `:" size="5"/>
</View>
<View style="flex-grow: 1; margin-left: 1em">
<TextArea name="question-` + questionNumber + `" toName="text" showSubmitButton="false" maxSubmissions="1" editable="true" required="true" requiredMessage="Missing input for Question ` + questionNumber + `" />
</View>
</View>
<View style="margin-top: -1.5em; margin-bottom: 1.5em;">
<Labels name="answer-` + questionNumber + `" toName="text" maxUsages="1">
<Label value="Answer ` + questionNumber + `" background="` + label_color + `"/>
</Labels>
</View>
`;
}
// For documentation see: https://labelstud.io/guide/frontend_reference.html
var labelStudio = new LabelStudio('label-studio', {
config: config,
interfaces: [
"update", // Show a button to update the current task after submitting.
"submit", // Show a button to submit or update the current annotation.
"controls", // Enable panel with controls (submit, update, skip).
"topbar", // A labeling interface that lists the top-level items in the Label Studio UI.
"side-column", // Show a column on the right side of the Label Studio UI.
"edit-history", // Show edit history.
],
user: {
id: 1,
firstName: prolific_pid,
lastName: prolific_pid,
},
task: {
id: 0,
"data": data,
annotations: [{
"id": 1,
"result": [
{
"value": {
"text": [
"What is the largest city the Rhine runs through?"
]
},
"id": "GDZGi35YPT",
"from_name": "question-1",
"to_name": "text",
"type": "textarea",
"origin": "manual"
},
],
}],
predictions: [],
},
});
labelStudio.on('labelStudioLoad', (LS) => {
var c = LS.annotationStore.addAnnotation({
userGenerate: true
});
LS.annotationStore.selectAnnotation(c.id);
});
labelStudio.on('submitAnnotation', (LS, annotation) => {
submit(annotation)
});
labelStudio.on('updateAnnotation', (LS, annotation) => {
submit(annotation)
});
function submit(annotation) {
let serializedAnnotation = annotation.serializeAnnotation();
let answer_start = 0;
let answer_end = 0;
let answer_exists = false;
for (var i = 0; i < serializedAnnotation.length; i++) {
if (serializedAnnotation[i]["from_name"] == "answer-1") {
answer_exists = true;
answer_start = serializedAnnotation[i]["value"]["start"];
answer_end = serializedAnnotation[i]["value"]["end"];
}
}
if (!answer_exists) {
window.alert("You did not select a answer. Click on the \"Answer 1\" button, move your mouse to the text passage and highlight the answer by clicking and dragging with your mouse.")
} else if (answer_start == 39 && (answer_end == 46 || answer_end == 47 || answer_end == 55)) { // answer_end == 47 is needed for firefox since it automatically marks the comma too
let nextPageButton = document.getElementById('nextPageButton');
nextPageButton.classList.remove("border-gray-300", "bg-gray-100");
nextPageButton.classList.add("border-orange-400", "bg-orange-100", "hover:bg-orange-200");
nextPageButton.style.visibility = "visible"
nextPageButton.disabled = false;
window.alert("You marked the correct answer! Please click on the \"Next Page\" button below. If you can't see it, scroll down.")
} else {
window.alert("You did not select the correct answer. The correct answer is: \"Cologne\"")
}
}
function nextPage() {
window.open("step2.html?" + urlParam("PROLIFIC_PID", prolific_pid) + urlParam("STUDY_ID", study_id) + urlParam("SESSION_ID", session_id) + urlParam("language", language), "_self")
}
function urlParam(identifier, value) {
if (value !== null) {
return identifier + "=" + value + "&";
} else {
return "";
}
}
</script>
</body>