Semester and KKI calc
This commit is contained in:
parent
ab505579b2
commit
9ecc707cfb
2 changed files with 52 additions and 0 deletions
24
spec.js
24
spec.js
|
@ -40,8 +40,10 @@ parseExcel = async function (file) {
|
|||
continue;
|
||||
grade = [, sign.startsWith("Aláírva") ? 5 : 1];
|
||||
}
|
||||
let semester = Semester.parse(row["Félév"]);
|
||||
subject.grade = +grade[1];
|
||||
subject.credit = +row["Kr."];
|
||||
subject.semester = semester;
|
||||
grades[id] = subject;
|
||||
}
|
||||
const specsSpan = document.getElementById("specs");
|
||||
|
@ -93,6 +95,28 @@ parseExcel = async function (file) {
|
|||
specsSpan.innerHTML += "Testnevelés: " + Object.values(grades).reduce((pv, cv) => cv.id.startsWith("XT") && cv.grade === 5 ? pv + 1 : pv, 0) + "/2 félév"; //TODO: Különböző félévben
|
||||
}
|
||||
}
|
||||
console.log("Current semester:");
|
||||
let semester = Semester.current();
|
||||
console.log(semester);
|
||||
let grds = [];
|
||||
for (const grade of Object.values(grades)) {
|
||||
console.log("gsfy: " + grade.semester.firstYear);
|
||||
console.log("gsn: " + grade.semester.num);
|
||||
console.log("sfy: " + semester.firstYear);
|
||||
console.log("sn: " + semester.num);
|
||||
if (grade.semester.firstYear === semester.firstYear && grade.semester.num === semester.num)
|
||||
grds.push(grade);
|
||||
}
|
||||
let totalCred = 0, passedCred = 0, totalNum = 0;
|
||||
for (const grade of grds) {
|
||||
if (grade.grade > 1) {
|
||||
passedCred += grade.credit;
|
||||
totalNum += grade.credit * grade.grade;
|
||||
}
|
||||
totalCred += grade.credit;
|
||||
}
|
||||
console.log("tc: " + totalCred + " pc: " + passedCred + " tn: " + totalNum);
|
||||
specsSpan.innerHTML += "<br />KKI (ösztöndijhoz): " + (totalNum / 30.0 * passedCred / totalCred);
|
||||
});
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
|
|
28
specdata.js
28
specdata.js
|
@ -5,6 +5,7 @@ class SubjectData {
|
|||
this.credit = credit;
|
||||
this.categories = categories;
|
||||
this.grade = 0;
|
||||
this.semester = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +29,33 @@ class Specialization {
|
|||
}
|
||||
}
|
||||
|
||||
class Semester {
|
||||
constructor(firstYear, num) {
|
||||
this.firstYear = firstYear;
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
static parse(str) {
|
||||
const regex = /(\d{4})\/\d{2}\/(\d)/g.exec(str);
|
||||
return new Semester(+regex[1], +regex[2]);
|
||||
}
|
||||
|
||||
static current() {
|
||||
const date = new Date();
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth();
|
||||
const s = new Semester(year, 1);
|
||||
console.log("Month: " + month);
|
||||
if (month === 0)
|
||||
s.firstYear--;
|
||||
else if (month < 8) {
|
||||
s.firstYear--;
|
||||
s.num++;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
const kotMatCat = new SubjectCategory("MK‑ALA", "Kötelező matekos tárgyak", 46);
|
||||
const kotInfCat = new SubjectCategory("MK‑SZT", "Kötelező infós tárgyak", 52);
|
||||
kotSpec = new Specialization("KOT", "Kötelező tárgyak", kotMatCat, kotInfCat);
|
||||
|
|
Loading…
Reference in a new issue