Skip to content

Instantly share code, notes, and snippets.

@nmanumr
Created January 22, 2020 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmanumr/247b74ebbf378d9b9104bc68d344afc7 to your computer and use it in GitHub Desktop.
Save nmanumr/247b74ebbf378d9b9104bc68d344afc7 to your computer and use it in GitHub Desktop.
CUONLINE scripts
if(window.location.pathname == '/Feedback'){
(function (){
$(".quiz_listing tr").each((i, el)=>{
if($(el).attr("onclick") && $(el).attr("onclick").toString().match(/window/) && !$(el).text().match(/UnAvailable/i)){
$(el).click();
return;
}
})
})()
}
else if(window.location.pathname.match(/Survey/)){
$("[value=1]").click();
$("#txtcomments").val('WowCoolPostThanksForSharing<3');
$('#SubmitBtn').click();
}
"use strict";
class GpaService {
constructor() {
this.s1Weight = 10;
this.s2Weight = 15;
this.finalWeight = 50;
this.quizWeight = 15;
this.assignWeight = 10;
}
calcTotal(entity) {
return entity.reduce((totalMarks, crntMarks) => [
parseInt(totalMarks[0]) + parseInt(crntMarks[0]),
parseInt(totalMarks[1]) + parseInt(crntMarks[1])
]);
}
percent(marks) {
if (marks[1] <= 0)
return 0;
return marks[0] / marks[1];
}
getWeight(weight, entity) {
return (entity[1] > 0) ? weight : 0;
}
calcPerc(assignments, quizzes, s1, s2, final) {
var assignMarks = this.calcTotal(assignments);
var quizMarks = this.calcTotal(quizzes);
var asignPercent = this.percent(assignMarks);
var quizzPercent = this.percent(quizMarks);
var s1Percent = this.percent(s1);
var s2Percent = this.percent(s2);
var finalPercent = this.percent(final);
return Math.round(((asignPercent ? asignPercent * this.assignWeight : 0) +
(quizzPercent ? quizzPercent * this.quizWeight : 0) +
(s1Percent ? s1Percent * this.s1Weight : 0) +
(s2Percent ? s2Percent * this.s2Weight : 0) +
(finalPercent ? finalPercent * this.finalWeight : 0)) / (this.getWeight(this.assignWeight, assignMarks) +
this.getWeight(this.quizWeight, quizMarks) +
this.getWeight(this.s1Weight, s1) +
this.getWeight(this.s2Weight, s2) +
this.getWeight(this.finalWeight, final)) * 100) / 100;
}
gradePoint(percent) {
var gradePoints = [
['A', 0.9],
['A-', 0.85],
['B+', 0.8],
['B', 0.75],
['B-', 0.7],
['C+', 0.65],
['C', 0.6],
['C-', 0.55],
['D', 0.5]
];
for (var point of gradePoints) {
if (percent >= point[1])
return [point[0].toString(), this.calcGradePoint(percent)];
}
return ['F', this.calcGradePoint(percent)];
}
calcGradePoint(percent) {
if (percent < .5)
return 0;
if (percent > .9)
return 4;
else
return Math.round(((percent - .5) * (4 - 1.3) / (.9 - .5) + 1.3) * 10) / 10;
}
calcSemesterGPA(semester) {
var percent = 0, ch = 0;
for (var subject of semester.subjects) {
percent += subject.percent ? subject.percent * subject.creditHours : 0;
ch += subject.percent ? subject.creditHours : 0;
}
percent /= ch;
var gradePoint = this.gradePoint(percent / 100);
return [Math.round(percent * 100) / 100, gradePoint[0], gradePoint[1]];
}
}
cpga = 0;
n =0;
$(".single_result_container").each((i, el)=>{
let weightSum = 0;
let x = 0;
$(el).find(".tbl_two [bordercolor]").each((i, d)=> {
let e = $(d).find("td:last-of-type");
if($(e).text().trim().length < 4 && parseFloat($(e).text().trim()) != NaN){
weightSum += parseFloat($(e).text().trim()) * parseFloat($(d).find("td:nth-of-type(3)").text().trim());
x += parseFloat($(d).find("td:nth-of-type(3)").text().trim());
}
});
console.log(`Semster ${n+1} GPA: ${(weightSum/x).toFixed(2)}`);
cpga += weightSum/x;
n++;
});
console.log("CGPA: " + (cpga/n).toFixed(2));
let id = parseInt(new URLSearchParams(window.location.search).get('programId')) + 1;
var campus = parseInt(new URLSearchParams(window.location.search).get('campusId'));
if (!$("#merittable>tbody").text().match("No students")) {
localStorage["ids"] += `${id}, `;
String.prototype.capitalize = function(lower) {
return (lower ? this.toLowerCase() : this).replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
};
var students = [];
var program = document.querySelector(".maincontent>h1>strong:nth-of-type(1)").innerText;
var campusName = document.querySelector(".maincontent>h1>strong:nth-of-type(2)").innerText;
$("#merittable>tbody tr").each((i, e)=>{
students.push({
name: $(e).children("td:nth-of-type(2)").text().capitalize(true).trim(),
fname: $(e).children("td:nth-of-type(3)").text().capitalize(true).trim(),
cnic: $(e).children("td:nth-of-type(4)").text().trim(),
admissionId: $(e).children("td:nth-of-type(1)").text().trim(),
"program": program,
"campus": campusName
});
});
}
if(document.querySelector(".maincontent>h1>strong:first-of-type").innerText && $("#merittable>tbody").text().match("No students"))
window.location.assign(`http://admissions.comsats.edu.pk/Home/StudentsInMerit?campusId=${campus}&programId=`+id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment