-
Notifications
You must be signed in to change notification settings - Fork 0
/
s1f.html
619 lines (554 loc) · 22.3 KB
/
s1f.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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
<html>
<title>PCS Semester 1 Final</title>
<head>
<style>
@import url(https://fonts.googleapis.com/css?family=Roboto);
body,
input,
select,
textarea,
body * {
font-family: 'Roboto', sans-serif;
box-sizing: border-box;
}
body::after, body::before,
input::after,
input::before,
select::after,
select::before,
textarea::after,
textarea::before,
body *::after,
body *::before {
box-sizing: border-box;
}
body {
padding: 50px;
background: url('polyBkgBlue.svg');
}
.formula {
display:inline-block;
padding:6px;
width:75%;
align:center;
border-radius:5px;
background: #ccc;
text-align:center;
}
.hdr {
display:inline-block;
padding:6px;
width:100%;
align:center;
border-radius:5px;
background: #555;
color:white;
text-align:center;
}
svg {
fill: white;
background: none;
}
table {
border-collapse: collapse;
}
.d-td {
padding: 3px 10px;
font-size: 12px;
text-align: center;
border: 1px dashed #ccc;
}
.gLabel {
fill: black;
font-family: sans-serif;
font-size: 10px;
}
.gLabelItalic {
font-style: italic;
}
.gLabelSub {
fill: black;
font-family: sans-serif;
font-size: 8px;
}
.forceArrow {
position: absolute;
cursor: move;
text-align: center;
height: 100px;
width: 15px;
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
.whitebkg {
background: white;
border-radius: 10px;
padding: 10px;
}
button {
background-color: #008CBA; /* Blue */
border: none;
border-radius:5px;
color: white;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 13px;
}
button:hover {
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var turnedIn = 0;
window.onbeforeunload = function(e) {
if(turnedIn >= 255) return;
else return "You are not finished, are you sure you want leave?";
}
</script>
</head>
<body>
<div class="whitebkg" style="overflow-y:scroll;height:150px;width:750px;" id="start">
<input type="text" id="lock"/>
<button onclick="if (document.getElementById('lock').value===btoa('per1!')||document.getElementById('lock').value===btoa('2per!')||document.getElementById('lock').value===btoa('p4er!')) {document.getElementById('start').style.display='none';document.getElementById('theTest').style.display='block';} else {document.getElementById('lock').value='';}">Go</button>
<script>console.log(btoa('p4er!'));</script>
</div>
<div class="whitebkg" style="overflow-y:scroll;height:550px;width:750px;display:none;" id="theTest";>
<div style="position:relative;">
<table><tr><td>First Name</td><td> Last Name</td></tr>
<tr><td><input type="text" id="firstname"></td><td> <input type="text" id="lastname"></td></tr></table>
<h1>Semester 1 Final - Units 1, 2, & 3</h1>
<span class="hdr">
<h4>Unit 1 - HS-PS2-1 Analyze data to support the claim that Newton’s second law of motion describes the mathematical relationship among the net force on a macroscopic object, its mass, and its acceleration.</h4>
<h5>Newton’s Second Law of Motion: Acceleration is produced when a net force acts on a mass. The greater the mass (of the object being accelerated) the greater the amount of force needed (to accelerate the object).</h5></span>
<hr>
<br>Graph the acceleration of the falling ball using the data listed in the data table below by clicking where each point should go.
<br>
</div>
<div style="position:relative;height:350px;">
<div style="top:10px;left:5px;position:absolute; ">
<table>
<tr>
<td class="d-td"><b>Time</b></td>
<td class="d-td"><b>Velocity</b></td>
</tr>
<tr>
<td class="d-td">0 s</td>
<td class="d-td">0 m/s</td>
</tr>
<tr>
<td class="d-td">0.5 s</td>
<td class="d-td">5 m/s</td>
</tr>
<tr>
<td class="d-td">1.0 s</td>
<td class="d-td">10 m/s</td>
</tr>
<tr>
<td class="d-td">1.5 s</td>
<td class="d-td">15 m/s</td>
</tr>
<tr>
<td class="d-td">2.0 s</td>
<td class="d-td">20 m/s</td>
</tr>
<tr>
<td class="d-td">2.5 s</td>
<td class="d-td">25 m/s</td>
</tr>
<tr>
<td class="d-td">3.0 s</td>
<td class="d-td">30 m/s</td>
</tr>
<tr>
<td class="d-td">3.5 s</td>
<td class="d-td">35 m/s</td>
</tr>
<tr>
<td class="d-td">4.0 s</td>
<td class="d-td">40 m/s</td>
</tr>
<tr>
<td class="d-td">4.5 s</td>
<td class="d-td">45 m/s</td>
</tr>
<tr>
<td class="d-td">5.0 s</td>
<td class="d-td">50 m/s</td>
</tr>
<tr>
<td class="d-td">5.5 s</td>
<td class="d-td">55 m/s</td>
</tr>
<tr>
<td class="d-td">6.0 s</td>
<td class="d-td">60 m/s</td>
</tr>
</table>
</div>
<div style="top:10px;left:150px;position:absolute; ">
<svg width="300" height="300" id="graphingBlock" onclick="setCoords(evt)">
<g>
<text x="0" y="116" class="gLabel gLabelItalic">Velocity</text>
<text x="10" y="125" class="gLabel gLabelItalic">(m/s)</text>
<text x="150" y="290" class="gLabel gLabelItalic">Time (s)</text>
<path d="
M40,20 40,260
M60,20 60,260
M80,20 80,260
M100,20 100,260
M120,20 120,260
M140,20 140,260
M160,20 160,260
M180,20 180,260
M200,20 200,260
M220,20 220,260
M240,20 240,260
M260,20 260,260
M280,20 280,260
M40,20 280,20
M40,40 280,40
M40,60 280,60
M40,80 280,80
M40,100 280,100
M40,120 280,120
M40,140 280,140
M40,160 280,160
M40,180 280,180
M40,200 280,200
M40,220 280,220
M40,240 280,240
M40,260 280,260
" stroke="#999" stroke-width="1" stroke-dasharray="1.5,3.5"/>
</g>
<g>
<circle fill="#0cc" cx="40" cy="260" r="4" id="circ40"/>
<circle fill="#0cc" cx="60" cy="260" r="4" id="circ60"/>
<circle fill="#0cc" cx="80" cy="260" r="4" id="circ80"/>
<circle fill="#0cc" cx="100" cy="260" r="4" id="circ100"/>
<circle fill="#0cc" cx="120" cy="260" r="4" id="circ120"/>
<circle fill="#0cc" cx="140" cy="260" r="4" id="circ140"/>
<circle fill="#0cc" cx="160" cy="260" r="4" id="circ160"/>
<circle fill="#0cc" cx="180" cy="260" r="4" id="circ180"/>
<circle fill="#0cc" cx="200" cy="260" r="4" id="circ200"/>
<circle fill="#0cc" cx="220" cy="260" r="4" id="circ220"/>
<circle fill="#0cc" cx="240" cy="260" r="4" id="circ240"/>
<circle fill="#0cc" cx="260" cy="260" r="4" id="circ260"/>
<circle fill="#0cc" cx="280" cy="260" r="4" id="circ280"/>
</g>
<path stroke="#0cc" stroke-width="2" d="M40,260 280,260" id="gLine" fill="none"/>
<text x="21" y="23" class="gLabel">60</text>
<text x="21" y="63" class="gLabel">50</text>
<text x="21" y="103" class="gLabel">40</text>
<text x="21" y="143" class="gLabel">30</text>
<text x="21" y="183" class="gLabel">20</text>
<text x="21" y="223" class="gLabel">10</text>
<text x="26" y="263" class="gLabel">0</text>
<text y="279" x="38" class="gLabel">0</text>
<text y="279" x="78" class="gLabel">1</text>
<text y="279" x="118" class="gLabel">2</text>
<text y="279" x="158" class="gLabel">3</text>
<text y="279" x="198" class="gLabel">4</text>
<text y="279" x="238" class="gLabel">5</text>
<text y="279" x="278" class="gLabel">6</text>
</svg>
</div>
</div>
<button onclick="sendResponse(0, this);">Submit</button>
<hr>
<br>
<div>
What is the acceleration according to the graph above? In other words: how much does the ball's velocity change each second?<br>
<br><span style="font-size:12px;">Enter your answer here:<br></span>
<input type="text" id="guessNumber" onBlur="q[2].value=this.value;" />
<select id="guessUnit" onChange="q[2].unit=this.value;this.value;">
<option value="none">--choose a unit--</option>
<option value="kg*m/s/s">kg*m/s² (Newtons)</option>
<option value="m/s">m/s</option>
<option value="kg">kg (kilograms)</option>
<option value="m">m (meters)</option>
<option value="s">s (seconds)</option>
<option value="m/s/s">m/s²</option>
</select>
<button onclick="sendResponse(2, this);">Submit</button>
<hr><br>
<span class="formula">Helpful formula:<br>
<b>Force = mass × acceleration (F = ma)</b></span>
<br><br>If the mass of the ball is <b>2 kg</b>, use the acceleration from the graph above to calculate the <b>Force</b> on the ball using Newton’s second law:<br><br><span style="font-size:12px;">Enter your answer here:<br></span>
<input type="text" id="guessNumber2" onBlur="q[3].value=this.value;" />
<select id="guessUnit" onChange="q[3].unit=this.value;">
<option value="none">--choose a unit--</option>
<option value="kg*m/s/s">kg*m/s² (Newtons)</option>
<option value="m/s">m/s</option>
<option value="kg">kg (kilograms)</option>
<option value="m">m (meters)</option>
<option value="s">s (seconds)</option>
<option value="m/s/s">m/s²</option>
</select>
<br><br>If the acceleration was only <b>5 m/s²</b> calculate the <b>Force</b> on the ball:<br><br><span style="font-size:12px;">Enter your answer here:<br></span>
<input type="text" id="guessNumber3" onBlur="q[3].value2=this.value;" />
<select id="guessUnit" onChange="q[3].unit2=this.value;">
<option value="none">--choose a unit--</option>
<option value="kg*m/s/s">kg*m/s² (Newtons)</option>
<option value="m/s">m/s</option>
<option value="kg">kg (kilograms)</option>
<option value="m">m (meters)</option>
<option value="s">s (seconds)</option>
<option value="m/s/s">m/s²</option>
</select>
<br><br>Explain how you were able to calculate the forces in your answers above:
<br>
<textarea onBlur="q[3].explain=this.value;"></textarea><br><br>
<button onclick="sendResponse(3, this);">Submit</button>
<hr><br><br>
Drag forces and objects from the grey boxes on the right into the empty box on the left to create a free-body diagram of a ball that has been dropped and is falling.<br><br><em>Hint: You do not have to use all of the objects or forces.</em>
</div>
<div style="position:relative;height:265px;overflow:hidden;">
<div style="position:absolute;top:10px;left:250px;">
<svg width="200" height="300">
<rect x="10" y="10" rx="10" ry="10" width="150" height="125" style="fill:#eee;stroke:black;stroke-width:2; "/>
<text x="15 " y="25" class="gLabel ">Forces</text>
<rect x="10" y="165" rx="10" ry="10" width="150" height="80" style="fill:#eee;stroke:black;stroke-width:2;"/>
<text x="15" y="180" class="gLabel">Objects (Ball, Table)</text>
</svg>
</div>
<div style="position:absolute;top:10px;left:20px;">
<svg width="250" height="350">
<rect x="10" y="10" rx="10" ry="10" width="200" height="235" style="fill:white;stroke:black;stroke-width:2; "/>
<text x="15" y="25" class="gLabel">Free-Body Diagram:</text>
</svg>
</div>
<div id="force-gravity" class="forceArrow" style="top:50px;left:270px; z-index: 9;position:absolute;">
<svg width="40" height="88">
<g>
<path stroke="black" stroke-width="2" fill="none" d="M4,4 4,65 1,60 7,60 4,65"/>
<text x="0" y="78" class="gLabel gLabelItalic ">F</text>
<text x="5" y="81" class="gLabelSub ">gravity</text>
</g></svg>
</div>
<div id="force-normal" class="forceArrow" style="top:50px;left:300px; z-index: 9;position:absolute; ">
<svg width="40" height="88">
<g>
<path stroke="black" stroke-width="2" fill="none" d="M4,78 4,18 1,22 7,22 4,18"/>
<text x="0" y="10" class="gLabel gLabelItalic ">F</text>
<text x="5" y="13" class="gLabelSub">normal</text>
</g>
</svg>
</div>
<div id="force-air" class="forceArrow" style="top:50px;left:360px; z-index: 9;position:absolute;">
<svg width="40" height="88">
<g>
<path stroke="black" stroke-width="2 " fill="none " d="M4,28 4,18 1,22 7,22 4,18 "/>
<text x="0" y="10" class="gLabel gLabelItalic">F</text>
<text x="5" y="13" class="gLabelSub">air</text>
</g>
</svg>
</div>
<div id="force-push" class="forceArrow" style="top:90px;left:320px; z-index: 9;position:absolute; ">
<svg width="88" height="40">
<g>
<path stroke="black" stroke-width="2" fill="none" d="M4,6 55,6 50,3 50,9 55,6"/>
<text x="60" y="8" class="gLabel gLabelItalic">F</text>
<text x="65" y="11" class="gLabelSub">push</text>
</g>
</svg>
</div>
<div id="force-friction" class="forceArrow" style="top:120px;left:340px; z-index: 9;position:absolute; ">
<svg width="45" height="20">
<g>
<path stroke="black" stroke-width="2" fill="none" d="M40,4 18,4 22,1 22,7 18,4"/>
<text x="1" y="12" class="gLabel gLabelItalic">F</text>
<text x="6" y="15" class="gLabelSub">friction</text>
</g>
</svg>
</div>
<div id="force-object" class="forceArrow" style="top:210px;left:280px; z-index:8;position:absolute; ">
<svg width="25" height="25">
<g>
<circle cx="12" cy="12" r="10" stroke="black" stroke-width="2" fill="#bbb"/>
</g>
</svg>
</div>
<div id="force-surface" class="forceArrow" style="top:220px;left:320px; z-index:6;position:absolute; ">
<svg width="82" height="10">
<g>
<path stroke="black" stroke-width="2" d="M1,1 80,1 80,8 1,8 1,1Z" fill="#bbb"/>
</g>
</svg>
</div>
<div style="position:absolute;top:225px;left:35px;z-index:30;">
<button onclick="sendResponse(1, this);">Submit</button>
</div>
</div>
<br><br><hr><span class="hdr">
<h4>Unit 2 - HS-PS2-3 Apply scientific and engineering ideas to design, evaluate, and refine a device that minimizes the forces on an object during a collision.</h4>
<h5>Momenum and Impulse - objects in motion have momentum, and in a collision the impulse during the collision is equal to the momentum right before the collision.</h5>
</span>
<br>
<br>Read the paragraph and then answer the question below:
<br><br>
<i style="font-size:10px;"><b>Excerpt from “How Airbags Work”</b><br>http://auto.howstuffworks.com/car-driving-safety/safety-regulatory-devices/airbag.htm</i><br><br>
<span style="font-size:12px;">
Before looking at specifics, let's review our knowledge of the laws of motion. First, we know that moving objects have momentum (the product of the mass and the velocity of an object). Unless an outside force acts on an object, the object will continue to move at its present speed and direction. Cars consist of several objects, including the vehicle itself, loose objects in the car and, of course, passengers. If these objects are not restrained, they will continue moving at whatever speed the car is traveling at, even if the car is stopped by a collision.<br><br>
Stopping an object's momentum requires force acting over a period of time. When a car crashes, the force required to stop an object is very great because the car's momentum has changed instantly while the passengers' has not -- there is not much time to work with. The goal of any supplemental restraint system is to help stop the passenger while doing as little damage to him or her as possible.<br><br>
What an airbag wants to do is to slow the passenger's speed to zero with little or no damage. The constraints that it has to work within are huge. The airbag has the space between the passenger and the steering wheel or dashboard and a fraction of a second to work with. Even that tiny amount of space and time is valuable, however, if the system can slow the passenger evenly rather than forcing an abrupt halt to his or her motion.</span>
<br><br>Using the words...<br>
<ul style="font-size:13px;" ><li>force</li><li>impulse</li><li>momentum</li><li>time</li></ul>
...explain how an airbag helps save lives in a crash:
<br>
<textarea style="width:75%;height:100px;" onBlur="q[4].explain=this.value;"></textarea><br><br>
<button onclick="sendResponse(4, this);">Submit</button>
<br>
<br><hr>
<span class="hdr">
<h4>Unit 3 - HS-PS3-3 Design, build, refine, and evaluate a device that works within given constraints to convert one form of energy into another form of energy.</h4>
<h5>Conservation of Energy: Energy is conserved - it cannot be created or destroyed - only transformed from one form to another.</h5>
<b>A Joule is a measure of energy: 1 J = 1 kg × m/s² × m</b></span><br>
<br>
<span class="formula">
Helpful Formulas:<br><br>
Kinetic Energy (KE) = ½m × v²<br>
Gravitational Potential Energy (GPE) = m × g × h where g = 9.8 m/s²</span><hr>
<br><br>
The beginning of the paper roller coaster is 0.5m high.<br>The end of the paper roller coaster is at ground level.<br>
The mass of the marble is 0.05 kg.<br><br>
Calculate the Gravitational Potential Energy (GPE) at the start of the paper roller coaster: <br><br>
<span style="font-size:12px;">Show your work here: (Show/explain your calculations to recieve full credit)<br>
<textarea style="width:50%;height:75px;" onBlur="q[5].explain=this.value;"></textarea><br><br>
Enter your answer here:<br></span>
GPE = <input type="text" id="guessNumber3" onBlur="q[5].value=this.value;" /> Joules
<button onclick="sendResponse(5, this);">Submit</button>
<hr>
<br><br>
How much Kinetic Energy does the marble have when it gets to the end of the roller coaster if 50% (0.5) of the marble's original energy was lost to friction?<br><br>
<span style="font-size:12px;">Enter your answer here:<br></span>
KE = <input type="text" id="guessNumber3" onBlur="q[6].value=this.value;" /> Joules
<button onclick="sendResponse(6, this);">Submit</button>
<hr>
<br><br>
Calculate the velocity of the marble at the end of the paper roller coaster.<br><br>
<span style="font-size:12px;">Show your work here: (Show/explain your calculations to recieve full credit)<br>
<textarea style="width:50%;height:75px;" onBlur="q[7].explain=this.value;"></textarea><br><br>
Enter your answer here:<br></span>
v = <input type="text" id="guessNumber3" onBlur="q[7].value=this.value;" /> m/s
<button onclick="sendResponse(7, this);">Submit</button>
<br><br><br>
<hr>
<span class="hdr">
That's it, you're finished!</span>
<br>
<span id="res"></span>
</div>
<script>
var svg = document.getElementById('graphingBlock');
var pt = svg.createSVGPoint(); // Created once for document
var q = [{}, {}, {}, {}, {}, {}, {}, {}];
function setCoords(evt) {
pt.x = evt.clientX;
pt.y = evt.clientY;
// The cursor point, translated into svg coordinates
var cursorpt = pt.matrixTransform(svg.getScreenCTM().inverse());
cursorpt.x = Math.round(cursorpt.x / 20) * 20;
cursorpt.y = Math.round(cursorpt.y / 5) * 5;
cursorpt.y = cursorpt.y < 0 ? 0 : cursorpt.y;
cursorpt.y = cursorpt.y > 260 ? 260 : cursorpt.y;
var thePt = document.getElementById('circ' + cursorpt.x);
thePt.setAttribute('cy', cursorpt.y);
var outStr = 'M';
for (var t = 40; t < 290; t += 20) {
thePt = document.getElementById('circ' + t);
outStr += thePt.getAttribute('cx') + ',' + thePt.getAttribute('cy') + ' ';
}
thePt = document.getElementById('gLine');
thePt.setAttribute('d', outStr);
q[0].line = outStr;
//console.log(outStr + "(" + cursorpt.x + ", " + cursorpt.y + ")");
}
// Make the DIV element draggable:
dragElement(document.getElementById("force-gravity"));
dragElement(document.getElementById("force-normal"));
dragElement(document.getElementById("force-air"));
dragElement(document.getElementById("force-push"));
dragElement(document.getElementById("force-friction"));
dragElement(document.getElementById("force-object"));
dragElement(document.getElementById("force-surface"));
function dragElement(elmnt) {
var pos1 = 0,
pos2 = 0,
pos3 = 0,
pos4 = 0;
if (document.getElementById(elmnt.id)) {
// if present, the header is where you move the DIV from:
document.getElementById(elmnt.id).onmousedown = dragMouseDown;
} else {
// otherwise, move the DIV from anywhere inside the DIV:
elmnt.onmousedown = dragMouseDown;
}
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
q[1][elmnt.id] = (elmnt.offsetTop - pos2) + "," + (elmnt.offsetLeft - pos1);
}
function closeDragElement() {
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
console.log(q);
//sendResponse(1);
}
}
function sendResponse(val, ob) {
studentName = document.getElementById('lock').value + ", " + document.getElementById("lastname").value + ", " + document.getElementById("firstname").value;
turnedIn += Math.round(Math.pow(2,val));
if (studentName.length < 14) {
alert('Enter your name at the top of the page before submitting any responses!');
} else {
ob.style.backgroundColor = '#4caf50'
//document.getElementById('sendit').name="response";
//document.getElementById('sendit').value=JSON.stringify(q[val]);
var ajaxSettings = {
"async": true,
"crossDomain": true,
"url": "https://pcssem1final-8616.restdb.io/rest/sem1final",
"method": "POST",
"headers": {
"x-apikey": '7cbc66150eef334530abbeb675b86357bc8a9',
"content-type": "application/json"
},
"data": '{"name": "' + studentName + '", "question": "' + val + '", "response": "' + btoa(JSON.stringify(q[val])) + '"}',
"processData": false
}
if(turnedIn >= 255) {
//$(window).off("beforeunload");
document.getElementById('res').innerHTML = '<span style="font-size:10px;">Encoded responses:<br><br>' + btoa(JSON.stringify({"resp":q})) + '</span>';
}
console.log(ajaxSettings);
$.ajax(ajaxSettings);
}
}
</script>
</body>
</html>