-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_setter.js
72 lines (64 loc) · 1.79 KB
/
test_setter.js
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
const table = document.querySelector("#case-table");
const body = table.querySelector("tbody");
const addCase = document.querySelector("#add-case-row");
const rowtypes = { start: "S", case: "C", end: "E" };
// only change here!!
// It's in this format
// [
// [[...file_names], points of the subtask] this is a subtask
// ]
const tests = [
[["subtask_1_01.in", "subtask_1_02.in"], 50],
[["subtask_2_01.in"], 50],
];
const getLastRow = () => {
return body.children[body.children.length - 1];
};
const getOptiontoSelect = (select, optionValue) => {
return Array.from(select.options).find(function (option) {
return option.value === optionValue;
});
};
const selectOption = (select, optionValue) => {
const option = getOptiontoSelect(select, optionValue);
option.selected = true;
const event = new Event("change");
select.dispatchEvent(event);
};
const addPoint = (input, points) => {
input.value = points;
const event = new Event("input", {
bubbles: true,
cancelable: true,
});
input.dispatchEvent(event);
};
const addStart = (points) => {
addCase.click();
const row = getLastRow();
const select = row.children[1].children[0];
selectOption(select, "S");
const input = row.querySelector('input[type="number"]');
addPoint(input, points);
};
const addEnd = () => {
addCase.click();
const row = getLastRow();
const select = row.children[1].children[0];
selectOption(select, "E");
};
const addTest = (file_name) => {
addCase.click();
const row = getLastRow();
const selectType = row.children[1].children[0];
selectOption(selectType, "C");
const selectfile = row.children[2].children[0];
selectOption(selectfile, file_name);
};
for (const batch of tests) {
addStart(batch[1]);
for (const test_case of batch[0]) {
addTest(test_case);
}
addEnd();
}