Skip to content

Commit

Permalink
Display selected courses
Browse files Browse the repository at this point in the history
- The courses selected in the AIMS page checkboxes are displayed
  in lexicographic order of course code.
  • Loading branch information
govindbalaji-s committed Dec 12, 2019
1 parent bf7b057 commit 9b5ad9c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
8 changes: 6 additions & 2 deletions activateGPA.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Source: https://github.com/IITH/aims-gpa-calculator
*/

var exclude_list = [
'Minor core',
'Honors core',
'Honours project',
'Honours coursework',
'FCC',
Expand Down Expand Up @@ -61,7 +63,9 @@ show_total_gpa = function(){
return;

var course = new Object();
course.id = $(this).children(".col1").html().trim();
course.code = $(this).children(".col1").contents().filter(function(){
return this.nodeType == Node.TEXT_NODE;
}).text().trim();
course.name = $(this).children(".col2").html().trim();
course.type = $(this).children(".col5").html().trim().slice(6);
course.grade = $(this).children(".col8").html().trim().slice(6);
Expand Down Expand Up @@ -89,7 +93,7 @@ show_total_gpa = function(){
branch: $(".studentInfoDiv>.flexDiv:nth-child(5)").find("div:nth-child(1)").find("span").text().trim(),
student_type: $(".studentInfoDiv>.flexDiv:nth-child(5)").find("div:nth-child(2)").find("span").text().trim(),
type_credits_map: JSON.stringify(Array.from(type_credits_map)),
//courses: courses,
courses: JSON.stringify(courses),
gpa: gpa
};
}
Expand Down
26 changes: 22 additions & 4 deletions gpa_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@
src: url('Roboto-Regular.ttf');
}
body{
text-align: center;
font-family: Roboto;
font-size: 13px;
}
.report{
display: inline-block;
text-align: left;
margin-top: 30px;
margin-left: 20px;
}
.personal, .summary{
margin-left: 50px;
width: 400px;
width: 600px;
margin-top: 20px;
}
.courses{
margin-left: 50px;
width: 600px;
margin-top: 20px;
}
ul{
Expand All @@ -35,7 +43,7 @@
width: 120px;
margin-bottom: 5px;
}
.summary, .summary th, .summary td{
.courses, .summary, .courses th, .summary th, .courses td, .summary td{
border: 2px solid #ff6600;
border-collapse: collapse;
padding: 3px 10px;
Expand All @@ -60,7 +68,7 @@
padding-bottom: 0.5%;
border-radius: 3px;
margin-top: 30px;
margin-left: 190px;
margin-left: 50px;
transition: 0.25s all;
}
button:hover {
Expand Down Expand Up @@ -95,14 +103,24 @@ <h1>Details</h1>
<td><span class="value cgpa"></span></td>
</tr>
</table>
<h1> Summary</h1>
<h1>Summary</h1>
<table class="summary">
<tr>
<th>Category</th>
<th class="credits">Credits</th>
</tr>
</table>
<h1>Selected Courses</h1>
<table class="courses">
<tr>
<th>Code</th>
<th>Name</th>
<th>Credits</th>
<th>Grade</th>
</tr>
</table>
</div>
<br/>
<button class="download-pdf">Download PDF</button>
<script src="html2pdf.bundle.min.js"></script>
<script src="gpa_report.js"></script>
Expand Down
22 changes: 21 additions & 1 deletion gpa_report.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
data = JSON.parse(localStorage.getItem("courseGPA"));
var data = JSON.parse(localStorage.getItem("courseGPA"));



Expand Down Expand Up @@ -26,6 +26,26 @@ total_row.innerHTML = `<td>Total</td><td class="credits">${total_credits}</td>`;
summary_table.appendChild(total_row);
console.log(data);


var courses_table = document.getElementsByClassName("courses")[0];
var courses_array = JSON.parse(data.courses);
courses_array.sort(function(a, b){
if (a.code < b.code)
return -1;
if (a.code > b.code)
return 1;
else return 0;
});
for (var course of courses_array) {
var row = document.createElement("tr");
row.innerHTML = `<td>${course.code}</td>
<td>${course.name}</td>
<td class="credits">${course.credits}</td>
<td class="credits">${course.grade}</td>`;
courses_table.appendChild(row);
}


document.addEventListener('DOMContentLoaded', function() {
document.getElementsByClassName("download-pdf")[0].addEventListener('click', function() {
var element = document.getElementsByClassName('report')[0];
Expand Down

0 comments on commit 9b5ad9c

Please sign in to comment.