-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
765 lines (759 loc) · 22.3 KB
/
index.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
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>分年細目視覺化</title>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"
></script>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css"
rel="stylesheet"
type="text/css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<!-- bootstrap -->
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
crossorigin="anonymous"
/>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"
integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"
crossorigin="anonymous"
></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"
integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"
crossorigin="anonymous"
></script>
<!-- filesaver -->
<script src="https://fastcdn.org/FileSaver.js/1.1.20151003/FileSaver.js"></script>
<!-- graph class -->
<script type="text/javascript" src="./GraphUtil.js"></script>
<script type="text/javascript" src="./GraphDataSource.js"></script>
<script type="text/javascript" src="./GraphView.js"></script>
<!-- handlebars -->
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.js"
></script>
<style type="text/css">
#cg_network_container {
position: relative;
width: 95vw;
height: 90vh;
border: 1px solid lightgray;
display: flex;
justify-content: center;
margin: auto;
}
#cg_network {
width: 80%;
position: absolute;
left: 0px;
bottom: 0px;
height: 90vh;
}
#show_pre_post_network {
/* z-index: 50; */
position: absolute;
right: 0px;
bottom: 0px;
background: rgba(200, 200, 200, 0.5);
width: 20%;
height: 90vh;
}
.dropdown,
input,
#editModeBtn {
display: inline-block;
margin: 10px;
}
.result-dropdown-container,
#red_edge {
display: inline-block;
}
#studentDropdownContainer,
#dateDropdownContainer {
max-height: 80vh;
overflow-y: scroll;
}
.radio-color-display {
width: 15px;
height: 15px;
display: inline-block;
margin-right: 5px;
margin-left: 5px;
border: 1px black solid;
vertical-align: middle;
}
.node-display {
width: 40px;
height: 40px;
line-height: 40px;
display: inline-block;
border-radius: 20px;
background: lightgray;
text-align: center;
vertical-align: middle;
}
.start-point-container {
float: right;
margin-right: 5vw;
}
.recommendBlock,
.recommendArrow {
display: flex;
justify-content: center;
height: 30px;
}
.recommendBlockContainer {
position: relative;
}
.recommendExercise {
border: 1px #ccc solid;
border-radius: 5px;
box-shadow: 2px 2px 1px rgba(20%, 20%, 40%, 0.5);
background-color: white;
padding: 10px;
position: absolute;
z-index: 50;
left: 50vw;
top: 20px;
display: none;
}
hr {
width: 100%;
background: #ccc;
}
h5 {
font-size: 18px;
display: flex;
justify-content: center;
}
.endPoint,
.endPoint a {
color: lightcoral;
}
</style>
<script>
function changeEdgeColor(student_result, edges_list) {
var ret_edges_list = jQuery.extend(true, [], edges_list);
var red_edge = 0;
for (var i = 0; i < edges_list.length; i++) {
edge = edges_list[i];
from = edge["from"];
to = edge["to"];
if (student_result[from] && student_result[to]) {
if (
student_result[from]["status"] === "X" &&
student_result[to]["status"] === "O"
) {
ret_edges_list[i]["color"] = { color: "red", highlight: "red" };
red_edge += 1;
} else {
ret_edges_list[i]["color"] = undefined;
}
} else {
ret_edges_list[i]["color"] = { color: "#CCC", highlight: "#CCC" };
}
}
$("#red_edge")[0].innerHTML = "有 " + red_edge + " 條錯誤連線";
return ret_edges_list;
}
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
alert("Query Variable " + variable + " not found");
}
</script>
<script>
var options = {
interaction: {
dragNodes: true,
},
nodes: {
color: {
background: "lightgray",
hover: "SILVER",
highlight: "SILVER",
},
borderWidth: 0,
},
edges: {
arrows: "to",
arrowStrikethrough: false,
smooth: false,
},
locales: {
jy: {
edit: "Edit",
del: "刪除所選",
back: "返回",
addNode: "新增節點",
addEdge: "新增連線",
editNode: "點擊上面狀態修改節點狀態",
editEdge: "編輯連線",
addDescription: "在空白處按下滑鼠,新增節點。",
edgeDescription: "按下一個節點,並拖拉到其他節點來新增連線。",
editEdgeDescription: "拖移控制點來修改連線。",
createEdgeError: "無法新增連線。",
deleteClusterError: "Clusters cannot be deleted.",
editClusterError: "Clusters cannot be edited.",
},
},
locale: "jy",
interaction: {
keyboard: true,
multiselect: true,
navigationButtons: true,
hover: true,
},
manipulation: {
enabled: false,
addNode: function (nodeData, callback) {
var name = prompt("請輸入節點名稱:", "");
var cg = prompt("請輸入所屬分年細目:", "");
if (name === null || name === "" || cg === null || cg === "") {
alert("沒有輸入名稱,新增節點失敗。");
return;
} else {
nodeData.id = name;
nodeData.cg = cg;
nodeData.name = name === cg ? cg : cg + "\n" + name;
nodeData.label = nodeData.name;
callback(nodeData);
}
},
editNode: function (nodeData, callback) {
var state_word = {
O: "學會",
T: "不確定",
X: "不會",
unknown: "無資料",
};
$("#editInfo")[0].innerText =
" 將狀態從 " +
state_word[nodeData.group] +
" 改變為 " +
state_word[curEditGroup];
nodeData.group = curEditGroup;
callback(nodeData);
},
},
layout: {
//randomSeed: 954201,
hierarchical: {
enabled: true,
direction: "UD",
edgeMinimization: true,
levelSeparation: 150,
nodeSpacing: 425,
blockShifting: true,
parentCentralization: true,
sortMethod: "directed", //'hubsize',
},
},
groups: {
O: {
color: {
background: "lightgreen",
hover: "LIMEGREEN",
highlight: "LIMEGREEN",
},
borderWidth: 3,
},
T: {
color: { background: "yellow", hover: "GOLD", highlight: "GOLD" },
borderWidth: 3,
},
X: {
color: {
background: "pink",
hover: "INDIANRED",
highlight: "INDIANRED",
},
borderWidth: 3,
},
guessO: {
color: {
background: "lawngreen",
hover: "LIMEGREEN",
highlight: "LIMEGREEN",
},
borderWidth: 0,
},
guessT: {
color: { background: "yellow", hover: "GOLD", highlight: "GOLD" },
borderWidth: 0,
},
guessX: {
color: {
background: "lightcoral",
hover: "INDIANRED",
highlight: "INDIANRED",
},
borderWidth: 0,
},
JY: { color: { background: "white" }, borderWidth: 3 },
under5: {
color: { background: "yellow", hover: "GOLD", highlight: "GOLD" },
borderWidth: 3,
},
fit: {
color: {
background: "lightgreen",
hover: "LIMEGREEN",
highlight: "LIMEGREEN",
},
borderWidth: 3,
},
easy: {
color: {
background: "lightgreen",
hover: "LIMEGREEN",
highlight: "LIMEGREEN",
},
borderWidth: 3,
},
not_fit: {
color: {
background: "pink",
hover: "INDIANRED",
highlight: "INDIANRED",
},
borderWidth: 3,
},
unknown: {
color: {
background: "lightgray",
hover: "SILVER",
highlight: "SILVER",
},
borderWidth: 0,
},
conflict: { color: { background: "orange" }, borderWidth: 3 },
},
physics: {
enabled: false,
stabilization: {
onlyDynamicEdges: true,
},
// hierarchicalRepulsion: {
// centralGravity: 0,
// springLength: 150,
// nodeDistance: 200
// },
// minVelocity: 0.75,
// solver: "hierarchicalRepulsion",
},
};
var editMode = false;
var curEditGroup = "unknown";
var graphDataSource = new GraphDataSource();
var graphView = new GraphView(options);
// load the relation we need to use
$(document).ready(function () {
graphView.setDataSource(graphDataSource);
graphView.init();
});
// edit mode
function changeEditMode() {
editMode = !editMode;
$("#editModeBtn")[0].innerText = editMode
? "離開編輯模式"
: "進入編輯模式";
$(".edit-mode").css("display", editMode ? "inline-block" : "none");
$(".result-dropdown-container").css(
"display",
!editMode ? "inline-block" : "none"
);
options["manipulation"]["enabled"] = editMode;
if (network) {
network.setOptions(options);
}
changeModeAndRedraw();
}
function changeEditGroup() {
choices = $.find('input[name="nodeGroup"]');
for (var i = 0; i < choices.length; i++) {
choice = choices[i];
if (choice.checked) {
curEditGroup = choice.value;
break;
}
}
}
function exportEditNetwork() {
var data = network.body.data;
var save_data = {
nodes: Object.values(data.nodes._data),
edges: Object.values(data.edges._data),
};
var save_txt = JSON.stringify(save_data);
var blob = new Blob([save_txt], { type: "text/plain;charset=utf-8" });
saveAs(blob, "graph.txt");
}
function importEditNetwork(event) {
var files = document.getElementById("customNetwork").files;
if (!files.length) {
alert("Please select a file!");
return;
}
var file = files[0];
var reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = function (e, callback) {
var data = reader.result;
data = data.replace("\n", "\\n");
customNetwork = jQuery.parseJSON(data);
curNodeList = customNetwork["nodes"];
curEdgeList = customNetwork["edges"];
setAndRedrawNetwork();
};
}
</script>
</head>
<body>
<div>
<div class="dropdown" style="display: none">
<button
class="btn btn-primary dropdown-toggle"
type="button"
id="dropdownNetworkButton"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
disabled
>
選擇分年細目關係圖(預設宜陞)
</button>
<div
id="networkDropdownContainer"
class="dropdown-menu"
aria-labelledby="dropdownNetworkButton"
>
<a class="dropdown-item" id="setRelationYisheng" value="yisheng"
>宜陞</a
>
<a class="dropdown-item" id="setRelationInchai" value="inchai"
>因材</a
>
</div>
</div>
<div style="display: none">
<input type="checkbox" id="isCgLevel" value="只顯示分年細目" />
<span for="isCgLevel">只顯示分年細目</span>
<input
type="checkbox"
id="displayJunyiResult"
value="顯示均一歷程"
checked
/>
<span for="displayJunyiResult">顯示均一歷程</span>
<input
type="checkbox"
id="displayPath"
value="顯示推薦路徑"
checked
/><span for="displayPath">顯示推薦路徑</span> <br />
</div>
<div class="dropdown" style="display: none">
<button
class="btn btn-primary dropdown-toggle"
type="button"
id="dropdownDataButton"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
選擇資料來源(預設屏東)
</button>
<div
id="dataDropdownContainer"
class="dropdown-menu"
aria-labelledby="dropdownDataButton"
>
<a
class="dropdown-item dataDropdown"
id="past_remedial"
value="past_remedial"
>歷屆補救教學</a
>
<a class="dropdown-item dataDropdown" id="pintong" value="pintong"
>屏東補救教學</a
>
<a class="dropdown-item dataDropdown" id="custom" value="custom"
>自行匯入</a
>
</div>
</div>
<span id="submitCustomData" style="display: none">
<input id="cg_result" type="text" name="paste the json content here" />
<input type="submit" value="送出補救結果" onclick="loadJson()" />
<input
class="submit_junyi"
id="junyi_result"
type="text"
style="display: none"
name="paste the json content here"
/>
<input
class="submit_junyi"
type="submit"
value="送出均一歷程"
style="display: none"
onclick="loadJunyiJson()"
/>
<span
>格式為 { 使用者email :{ 分年細目或知識點id: {"status": ... , "data":
... }, ... }, ... }</span
>
</span>
</div>
<!-- <button id="editModeBtn" class="btn btn-info" onclick="changeEditMode()" disabled>進入編輯模式</button> -->
<div class="edit-mode" style="display: none">
<button
id="exportBtn"
class="btn btn-success"
onclick="exportEditNetwork()"
>
匯出編輯的圖
</button>
<input
id="customNetwork"
type="file"
name="paste the network here"
onchange="importEditNetwork(event)"
/>
<span class="edit-node-radio">
<input
type="radio"
id="nodeGroup-unknown"
name="nodeGroup"
value="unknown"
onchange="changeEditGroup()"
checked
/><label for="nodeGroup-unknown"
><div
class="radio-color-display"
style="background-color: #ccc"
></div>
無資料</label
>
<input
type="radio"
id="nodeGroup-X"
name="nodeGroup"
value="X"
onchange="changeEditGroup()"
/><label for="nodeGroup-X"
><div
class="radio-color-display"
style="background-color: lightcoral"
></div>
不會</label
>
<input
type="radio"
id="nodeGroup-T"
name="nodeGroup"
value="T"
onchange="changeEditGroup()"
/><label for="nodeGroup-T"
><div
class="radio-color-display"
style="background-color: yellow"
></div>
不確定</label
>
<input
type="radio"
id="nodeGroup-O"
name="nodeGroup"
value="O"
onchange="changeEditGroup()"
/><label for="nodeGroup-O"
><div
class="radio-color-display"
style="background-color: lawnGreen"
></div>
學會</label
>
</span>
<span id="editInfo"></span>
</div>
<div class="result-dropdown-container">
<span class="dropdown">
<button
class="btn btn-success dropdown-toggle"
type="button"
id="dropdownStudentButton"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
disabled
>
選擇學生
</button>
<div
id="studentDropdownContainer"
class="dropdown-menu"
aria-labelledby="dropdownStudentButton"
></div>
</span>
<span class="dropdown">
<button
class="btn btn-success dropdown-toggle"
type="button"
id="dropdownThemeButton"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
disabled
>
選擇主題
</button>
<div
id="themeDropdownContainer"
class="dropdown-menu"
aria-labelledby="dropdownThemeButton"
></div>
</span>
<span class="dropdown" style="display: none">
<button
class="btn btn-success dropdown-toggle"
type="button"
id="dropdownDateButton"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
disabled
>
選擇時間
</button>
<div
id="dateDropdownContainer"
class="dropdown-menu"
aria-labelledby="dropdownDateButton"
>
<a
class="dropdown-item"
id="all"
value="all"
onclick="changeNodeGroup(this.id)"
>所有時間</a
>
</div>
</span>
<span
id="red_edge"
style="border: 1px solid red; margin-left: 10px; display: none"
></span>
<span id="guessNode" style="margin-left: 10px; display: none"></span>
</div>
<div id="recommend-panel-container">
<div id="guess-learned-text"></div>
<div id="recommend-container"></div>
</div>
<div class="start-point-container" style="display: none">
<span id="startPointText"></span>
</div>
<br />
<br />
<div style="position: relative">
<div style="padding-left: 20px; display: inline-block; width: 60%">
<span
>*我們將學生的補救教學成績以及均一的學習歷程呈現在下圖,老師可以參考看看唷!</span
><br />
<span
>*藍色框代表有均一歷程或補救教學成績,滑鼠移動到點上會顯示均一歷程以及補救教學結果</span
><br />
<span>*沒有藍色框代表是猜測學生會或不會</span>
</div>
<span style="right: 2.5vw; bottom: 0px; position: absolute">
<label
><div class="node-display">先備</div>
→
<div class="node-display">後續</div></label
>
<label
><div
class="radio-color-display"
style="background-color: lightgray"
></div>
無資料</label
>
<br />
<label
><div
class="radio-color-display"
style="background-color: lightcoral"
></div>
系統猜測不會</label
>
<label
><div
class="radio-color-display"
style="background-color: yellow"
></div>
系統無法猜測</label
>
<label
><div
class="radio-color-display"
style="background-color: lawnGreen"
></div>
系統猜測學會</label
>
<label
><div
class="radio-color-display"
style="background-color: orange"
></div>
歷程與補救資料結果不同</label
>
<br />
<label
><div
class="radio-color-display"
style="background-color: pink; border: rgb(0, 140, 255) solid 3px"
></div>
系統判斷不會</label
>
<label
><div
class="radio-color-display"
style="background-color: yellow; border: rgb(0, 140, 255) solid 3px"
></div>
系統無法判斷</label
>
<label
><div
class="radio-color-display"
style="
background-color: lightgreen;
border: rgb(0, 140, 255) solid 3px;
"
></div>
系統判斷學會</label
>
</span>
</div>
<br />
<div id="cg_network_container">
<div id="cg_network"></div>
<div id="show_pre_post_network"></div>
</div>
</body>
</html>