Use map (object) for subjects
This commit is contained in:
parent
ab898d2344
commit
09ac822911
2 changed files with 15 additions and 10 deletions
24
spec.js
24
spec.js
|
@ -14,10 +14,13 @@ parseExcel = async function (file) {
|
||||||
});
|
});
|
||||||
|
|
||||||
workbook.SheetNames.forEach(function (sheetName) {
|
workbook.SheetNames.forEach(function (sheetName) {
|
||||||
const XL_row_object = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
|
const rows = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
|
||||||
const json_object = JSON.stringify(XL_row_object);
|
console.log(rows);
|
||||||
console.log(json_object);
|
console.log(rows[0]["Tárgykód"]);
|
||||||
console.log(XL_row_object[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");
|
||||||
});
|
});
|
||||||
} catch
|
} catch
|
||||||
(ex) {
|
(ex) {
|
||||||
|
@ -59,14 +62,14 @@ szak.onchange = async () => {
|
||||||
console.warn("No category found!");
|
console.warn("No category found!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
subjects.push(new SubjectData(sdata[1], sdata[2], sdata[8], cat));
|
subjects[sdata[1]] = new SubjectData(sdata[1], sdata[2], sdata[8], cat);
|
||||||
}
|
}
|
||||||
const specsSpan = document.getElementById("specs");
|
|
||||||
specsSpan.innerHTML = "";
|
|
||||||
for (const spec of specs) {
|
for (const spec of specs) {
|
||||||
const count = subjects.reduce((pv, cv) => cv.category.spec === spec ? pv + 1 : pv, 0);
|
const count = Object.values(subjects).reduce((pv, cv) => cv.category.spec === spec ? pv + 1 : pv, 0);
|
||||||
specsSpan.innerHTML += spec.name + ": " + count + "<br />";
|
console.log(spec.name + ": " + count);
|
||||||
}
|
}
|
||||||
|
const count = Object.values(subjects).reduce((pv, cv) => cv.category.spec === null ? pv + 1 : pv, 0);
|
||||||
|
console.log("Egyéb tárgyak: " + count);
|
||||||
};
|
};
|
||||||
|
|
||||||
function tryGetCat(categoryID) {
|
function tryGetCat(categoryID) {
|
||||||
|
@ -79,11 +82,12 @@ function tryGetCat(categoryID) {
|
||||||
].find(cat => cat.id === categoryID);
|
].find(cat => cat.id === categoryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
let subjects = [];
|
let subjects = {};
|
||||||
let specs = [
|
let specs = [
|
||||||
kotSpec,
|
kotSpec,
|
||||||
kotvalSpec
|
kotvalSpec
|
||||||
];
|
];
|
||||||
|
let grades = {};
|
||||||
(async () => {
|
(async () => {
|
||||||
await szak.onchange(undefined);
|
await szak.onchange(undefined);
|
||||||
await lk.onchange(undefined);
|
await lk.onchange(undefined);
|
||||||
|
|
|
@ -4,6 +4,7 @@ class SubjectData {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.credit = credit;
|
this.credit = credit;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
|
this.grade = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue