Professional Documents
Culture Documents
var exclude_list = [
'Minor Core',
'Honors Core',
'Honours project',
'Honours coursework',
'FCC',
'Additional',
'Audit',
];
var grade_values = {
'A+': 10,
'A': 10,
'A-': 9,
'B': 8,
'B-': 7,
'C': 6,
'C-': 5,
'D': 4,
'FR': 0,
'FS': 0
};
console.log(studentId);
append_checkbox = function (parent, is_checked) {
parent.append("<input class=\"cgpa_cal_check\" type=\"checkbox\" " +
(is_checked ? "checked" : "") + " />");
}
add_checkboxes = function () {
var courses_checked = new Set();
$(".cgpa_cal_check").remove();
elems = $(".hierarchyLi.dataLi").not(".hierarchyHdr, .hierarchySubHdr");
elems.each(function (i) {
var course_id = $(this).children(".col1").html().trim();
if (courses_checked.has(course_id)) {
append_checkbox($(this).children(".col1"), false);
return;
}
is_checked = true;
type = $(this).children(".col5").html().trim().slice(6);
grade = $(this).children(".col8").html().trim().slice(6);
console.log(grade, grade.length);
if (exclude_list.indexOf(type) > -1 || grade == "" || grade == "I")
is_checked = false;
if (is_checked)
courses_checked.add(course_id);
append_checkbox($(this).children(".col1"), is_checked);
});
}
show_total_gpa = function () {
$('#gpa_button').val('Calculating');
$('#gpa_bar').remove();
cg_total_grades = 0;
cg_total_credits = 0;
total_credits = 0;
basic_sc = 0;
basic_es = 0;
felec = 0;
dep_el = 0;
dep_core = 0;
laca = 0;
if ($(".cgpa_cal_check").length == 0)
add_checkboxes();
elems = $(".hierarchyLi.dataLi").not(".hierarchyHdr, .hierarchySubHdr");
elems.each(function (i) {
if ($(this).find(".cgpa_cal_check:checked").length == 0)
return;
grade = $(this).children(".col8").html().trim().slice(6);
credits = $(this).children(".col3").html().trim().slice(6);
type = $(this).children(".col5").html().trim().slice(6);
credits = Number(credits);
if (type == BASIC_SC) basic_sc += credits;
else if (type == BASIC_ES) basic_es += credits;
else if (type == DEPTT_ELEC) dep_el += credits;
else if (type == DEPTT_CORE) dep_core += credits;
else if (type == FREE_ELEC) felec += credits;
else if (type == TYPE_LA || type == TYPE_CA) laca += credits;
total_credits += credits;
if (!(grade in grade_values))
return;
grade = grade_values[grade];
cg_total_grades += credits * grade;
cg_total_credits += credits;
});
console.log(cg_total_grades, cg_total_credits);
console.log('Basic-sc: ');
console.log(basic_sc);
console.log('Basic-Engineering-Skills: ');
console.log(basic_es);