2020-08-29 20:01:41 +00:00
|
|
|
|
const szak = document.getElementById("szak");
|
|
|
|
|
const lk = document.getElementById("leckekonyv");
|
2021-01-04 15:35:17 +00:00
|
|
|
|
promiseOnLoad = async loadable => new Promise(((resolve, reject) => (loadable.onload = ev => resolve(ev)) && (loadable.onerror = ev => reject(ev))));
|
|
|
|
|
parseExcel = async function (file) {
|
|
|
|
|
try {
|
|
|
|
|
const reader = new FileReader();
|
|
|
|
|
const evpr = promiseOnLoad(reader);
|
|
|
|
|
reader.readAsBinaryString(file);
|
|
|
|
|
const ev = await evpr;
|
|
|
|
|
const data = ev.target.result;
|
2020-08-29 20:01:41 +00:00
|
|
|
|
|
|
|
|
|
const workbook = XLSX.read(data, {
|
|
|
|
|
type: 'binary'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
workbook.SheetNames.forEach(function (sheetName) {
|
2021-01-04 16:01:58 +00:00
|
|
|
|
const rows = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
|
|
|
|
|
console.log(rows);
|
|
|
|
|
console.log(rows[0]["Tárgykód"]);
|
|
|
|
|
for (const row of rows) {
|
|
|
|
|
//grades[rows[0]["Tárgykód"]] = new SubjectGrades(rows[0]["Tárgykód"], rows[0]["Tárgy címe, előadó neve"], "");
|
|
|
|
|
}
|
|
|
|
|
const specsSpan = document.getElementById("specs");
|
2021-01-04 15:35:17 +00:00
|
|
|
|
});
|
|
|
|
|
} catch
|
|
|
|
|
(ex) {
|
2020-08-29 20:01:41 +00:00
|
|
|
|
console.log(ex);
|
2021-01-04 15:35:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lk.onchange = async () => await parseExcel(lk.files[0]);
|
|
|
|
|
szak.onchange = async () => {
|
2020-08-29 20:01:41 +00:00
|
|
|
|
if (szak.value === "nope") return;
|
|
|
|
|
let response = await fetch(document.URL.substr(0, document.URL.lastIndexOf('/')) + '/data/' + szak.value + "_bsc.csv");
|
2021-01-03 23:20:56 +00:00
|
|
|
|
let data = await response.text();
|
|
|
|
|
let obj = Papa.parse(data);
|
2021-01-04 15:35:17 +00:00
|
|
|
|
const szakError = document.getElementById("szakError");
|
|
|
|
|
szakError.innerText = "";
|
|
|
|
|
if (obj.errors.length > 0) {
|
|
|
|
|
for (const error of obj.errors)
|
|
|
|
|
szakError.innerHTML += error.type + " - " + error.code + ": " + error.message + "<br />";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
console.log(obj.data);
|
|
|
|
|
let cat;
|
|
|
|
|
for (let i = 2; i < obj.data.length; i++) { //2: Skip header
|
|
|
|
|
const sdata = obj.data[i];
|
|
|
|
|
if (sdata.length < 10)
|
|
|
|
|
continue;
|
|
|
|
|
if (sdata[5].length === 0) { //Course type, only present at leaf nodes
|
|
|
|
|
let tempcat = tryGetCat(sdata[1]);
|
|
|
|
|
if (tempcat !== undefined)
|
|
|
|
|
cat = tempcat;
|
|
|
|
|
if (sdata[2].indexOf("specializáció") === -1)
|
|
|
|
|
continue;
|
|
|
|
|
const spec = new Specialization(sdata[1], sdata[2],
|
|
|
|
|
new SubjectCategory(sdata[1] + "‑MATSZT‑A", sdata[2] + " matekos tárgyak"),
|
|
|
|
|
new SubjectCategory(sdata[1] + "‑INF‑A", sdata[2] + " infós tárgyak"));
|
|
|
|
|
specs.push(spec);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (cat === undefined) {
|
|
|
|
|
console.warn("No category found!");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2021-01-04 16:01:58 +00:00
|
|
|
|
subjects[sdata[1]] = new SubjectData(sdata[1], sdata[2], sdata[8], cat);
|
2021-01-04 15:35:17 +00:00
|
|
|
|
}
|
|
|
|
|
for (const spec of specs) {
|
2021-01-04 16:01:58 +00:00
|
|
|
|
const count = Object.values(subjects).reduce((pv, cv) => cv.category.spec === spec ? pv + 1 : pv, 0);
|
|
|
|
|
console.log(spec.name + ": " + count);
|
2021-01-04 15:35:17 +00:00
|
|
|
|
}
|
2021-01-04 16:01:58 +00:00
|
|
|
|
const count = Object.values(subjects).reduce((pv, cv) => cv.category.spec === null ? pv + 1 : pv, 0);
|
|
|
|
|
console.log("Egyéb tárgyak: " + count);
|
2020-08-29 20:01:41 +00:00
|
|
|
|
};
|
2021-01-04 15:35:17 +00:00
|
|
|
|
|
|
|
|
|
function tryGetCat(categoryID) {
|
|
|
|
|
const spec = specs.find(spec => spec.matcat.id === categoryID || spec.infcat.id === categoryID)
|
|
|
|
|
return (spec && (spec.matcat.id === categoryID ? spec.matcat : spec.infcat)) || [
|
|
|
|
|
kotvalEgyebCat,
|
|
|
|
|
szakdogaCat,
|
|
|
|
|
szakmaiCat,
|
|
|
|
|
szabvalCat
|
|
|
|
|
].find(cat => cat.id === categoryID);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-04 16:01:58 +00:00
|
|
|
|
let subjects = {};
|
2021-01-04 15:35:17 +00:00
|
|
|
|
let specs = [
|
|
|
|
|
kotSpec,
|
|
|
|
|
kotvalSpec
|
|
|
|
|
];
|
2021-01-04 16:01:58 +00:00
|
|
|
|
let grades = {};
|
2021-01-04 15:35:17 +00:00
|
|
|
|
(async () => {
|
|
|
|
|
await szak.onchange(undefined);
|
|
|
|
|
await lk.onchange(undefined);
|
|
|
|
|
}
|
|
|
|
|
)();
|