Skip to content

Commit

Permalink
fixed and marks page and attendance 80% issue and updated to v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjay7178 committed Feb 6, 2023
1 parent 4c663f0 commit 1ec3fd8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 36 deletions.
12 changes: 6 additions & 6 deletions js/attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let view_attendance_page = () => {
//Working of the calculator
let table_line = document.querySelectorAll(".table-responsive")[0]
table_line.getElementsByTagName("span")[0].outerHTML += "<br><br><p style='color:red;'>*Note: This calculator doesn't calculate the attendace till the end of the sem, It only calculates the attendance to 75%</p>";
table_line.getElementsByTagName("span")[0].outerHTML += "<br><br><p style='color:red;'>*Note: This calculator doesn't calculate the attendace till the end of the sem, It only calculates the attendance to 80%</p>";

//Footer edited_head
let color_detail = document.createElement("div");
Expand All @@ -16,7 +16,7 @@ let view_attendance_page = () => {
//Head edit
var table_head = document.getElementsByTagName("thead");
var edited_head = table_head[0].innerHTML.split("\n");
edited_head.splice(19, 0, '<th style="vertical-align: middle; text-align: center; border-right: 1px solid #b2b2b2; padding: 5px;">75% Attendance Alert</th>');
edited_head.splice(19, 0, '<th style="vertical-align: middle; text-align: center; border-right: 1px solid #b2b2b2; padding: 5px;">80% Attendance Alert</th>');
table_head[0].innerHTML = edited_head.join("");

//Body Edit
Expand All @@ -28,12 +28,12 @@ let view_attendance_page = () => {
let attended_classes = parseFloat(new_Table_Content[23].split(">")[2].slice(0, 3));
let tot_classes = parseFloat(new_Table_Content[24].split(">")[2].slice(0, 3));
let course_type = new_Table_Content[8];
if (attended_classes / tot_classes < 0.7401) {
if (attended_classes / tot_classes < 0.80) {
//To maintain exact 75%
// let req_classes = Math.ceil((3 * (tot_classes)) - (4 * (attended_classes)));

//Calculates the attendace to 74.01% (as vit consider it as 75%)
let req_classes = Math.ceil(((0.7401 * tot_classes) - attended_classes) / 0.2599);
let req_classes = Math.ceil(((0.80 * tot_classes) - attended_classes) / 0.2599);

if (course_type.includes("Lab")) {
req_classes /= 2;
Expand All @@ -50,10 +50,10 @@ let view_attendance_page = () => {
// let bunk_classes = Math.floor(((4 / 3) * (attended_classes)) - tot_classes);

//For 74.01% which vit calculates it as 75%
let bunk_classes = Math.floor((attended_classes - (0.7401 * tot_classes)) / 0.7401);
let bunk_classes = Math.floor((attended_classes - (0.80 * tot_classes)) / 0.80);

let color = "rgb(170, 255, 0,0.7)";
if (0.7401 <= (attended_classes / tot_classes) && (attended_classes / tot_classes) <= 0.7499) {
if (0.7401 <= (attended_classes / tot_classes) && (attended_classes / tot_classes) <= 0.80) {
color = "rgb(255, 171, 16)";
}

Expand Down
82 changes: 53 additions & 29 deletions js/marks_page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
let modify_marks_page = () => {

let tables = document.querySelectorAll(".customTable-level1 > tbody"); // select all Tables
let subject_header = Array.from(document.querySelectorAll(".tableContent"));
let i = 0;
Expand All @@ -7,12 +8,15 @@ let modify_marks_page = () => {
// To get the subject code
let sub_header_row = subject_header[i].getElementsByTagName("td");
let sub_type = sub_header_row[4].innerHTML;
let sub_type1 = sub_header_row[2].innerHTML;
i += 2;
let tot_max_marks = 0,
tot_weightage_percent = 0,
tot_scored = 0,
tot_weightage_equi = 0,
tot_class_avg = 0;
tot_cat_fat = 0;
max_marks_cat_fat =0;

table_marks = table.querySelectorAll(".tableContent-level1"); // select rows excluding header
table_marks = Array.from(table_marks);
Expand All @@ -22,11 +26,29 @@ let modify_marks_page = () => {
let content = row.innerHTML.split("<td>");

//Removing the tabs and other tags
let cat_fat = content[2].replace('<output>', '').replace('</output></td>', '');
// console.log(cat_fat)
let max_marks = content[3].replace(/[^0-9.]+/g, "");
let weightage_percent = content[4].replace(/[^0-9.]+/g, "");
let scored = content[6].replace(/[^0-9.]+/g, "");
let weightage_equi = content[7].replace(/[^0-9.]+/g, "");
let class_avg = content[8].replace(/[^0-9.]+/g, "");
// console.log(cat_fat.match(/CAT/).includes("CAT"));
// console.log(scored);
// cat + fat
if(cat_fat.match(/CAT/) =='CAT'){
tot_cat_fat += parseFloat(scored)
max_marks_cat_fat +=parseFloat(max_marks)
}else if (cat_fat.match(/FAT/) =='FAT') {
tot_cat_fat += parseFloat(scored)
max_marks_cat_fat +=parseFloat(max_marks)
}else if (cat_fat.match(/CAT1/) =='CAT1'){
tot_cat_fat += parseFloat(scored)
max_marks_cat_fat +=parseFloat(max_marks)
}else if(cat_fat.match(/CAT2/) =='CAT2'){
tot_cat_fat += parseFloat(scored)
max_marks_cat_fat +=parseFloat(max_marks)
}

//converting string to float
tot_max_marks += parseFloat(max_marks);
Expand All @@ -35,10 +57,7 @@ let modify_marks_page = () => {
tot_weightage_equi += parseFloat(weightage_equi);
tot_class_avg += parseFloat(class_avg);

const MAX_MARKS_INDEX = 2;
let td = document.createElement("td");
td.innerHTML = `<b>${scored} / ${max_marks}</b>`;
row.insertBefore( td, row.children[MAX_MARKS_INDEX] );

});

//Add the row to display totals
Expand All @@ -61,47 +80,52 @@ let modify_marks_page = () => {
let pass_marks;

//Theorey Subjects
if (sub_type.includes("Theory") && tot_weightage_percent == 60) {
if (tot_weightage_equi >= 34) {
pass_marks = 40;
if (sub_type.includes("Theory") && tot_weightage_percent == 75 ) {
if (tot_cat_fat >= 44) {
pass_marks = 44;
table.innerHTML += `
<tr class="tableContent-level1" style='background: rgb(170, 255, 0,0.6);'>
<td colspan="10" style="text-align:center">You need only ${pass_marks} marks out of 100 in FAT to pass theory component 🥳</td>
</tr>
`;
}
else {
pass_marks = ((34 - tot_weightage_equi) * 2.5) + 40;
table.innerHTML += `
<tr class="tableContent-level1" style='background: rgb(255,0,0,0.6);'>
<td colspan="10" style="text-align:center"><b>Minimum marks required to clear this component is : ${pass_marks.toFixed(2)}<b></td>
<td colspan="10" style="text-align:center">You secured in CAT+FAT : ${tot_cat_fat}</td>
</tr>
`;
}
}

//Labs
else if ((sub_type.includes("Lab") || sub_type.includes("Online")) && tot_weightage_percent == 60) {
if (tot_weightage_equi >= 50) {
pass_marks = "You have fulfilled the criteria of passing the Lab Component 🥳"
table.innerHTML += `
<tr class="tableContent-level1" style='background: rgb(170, 255, 0,0.6);'>
<td colspan="10" style="text-align:center">${pass_marks}</td>
<td colspan="10" style="text-align:center">You need only ${pass_marks} marks out of ${max_marks_cat_fat} in CAT + FAT to pass theory component 🥳</td>
</tr>
`;
}
else {
pass_marks = 50 - tot_weightage_equi;
pass_marks = 45 - tot_cat_fat ;
max_pass_marks = max_marks_cat_fat -45 ;
table.innerHTML += `
<tr class="tableContent-level1" style='background: rgb(255,0,0,0.6);'>
<td colspan="10" style="text-align:center"><b>Minimum marks required to clear this component is : ${pass_marks.toFixed(2)}<b></td>
<td colspan="10" style="text-align:center"><b>Minimum marks required to clear this component is : ${pass_marks.toFixed(2)} and max marks are ${max_pass_marks}<b></td>
</tr>
`;
}
}

//Labs
// else if ((sub_type.includes("Lab") || sub_type.includes("Online")) ) {
// if (tot_weightage_equi >= 50) {
// pass_marks = "You have fulfilled the criteria of passing the Lab Component 🥳"
// table.innerHTML += `
// <tr class="tableContent-level1" style='background: rgb(170, 255, 0,0.6);'>
// <td colspan="10" style="text-align:center">${pass_marks}</td>
// </tr>
// `;
// }
// else {
// pass_marks = 50 - tot_weightage_equi;
// table.innerHTML += `
// <tr class="tableContent-level1" style='background: rgb(255,0,0,0.6);'>
// <td colspan="10" style="text-align:center"><b>Minimum marks required to clear this component is : ${pass_marks.toFixed(2)}<b></td>
// </tr>
// `;
// }
// }

//STS
else if (sub_type.includes("Soft") && tot_weightage_percent == 60) {
else if (sub_type1.includes("STS")) {
if (tot_weightage_equi >= 50) {
pass_marks = "You have fulfilled the criteria of passing the STS 🥳"
table.innerHTML += `
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"permissions": [ "webRequest", "downloads", "storage", "tabs", "identity", "alarms" ],
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "1.5",
"version": "2.0",
"web_accessible_resources": [ {
"matches": [ "*://*.vit.ac.in/*" , "*://*.vitap.ac.in/*" ],
"resources": [ "js/captcha/weights.json" ]
Expand Down

0 comments on commit 1ec3fd8

Please sign in to comment.