Skip to content

Commit

Permalink
Merge pull request #101 from kdk1616/master
Browse files Browse the repository at this point in the history
Update macOS scripts and support multiple types of GPA (new)
  • Loading branch information
psvenk authored Mar 18, 2020
2 parents 76d7aa8 + 3288939 commit daf1ffc
Show file tree
Hide file tree
Showing 8 changed files with 438 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
package-lock.json
db/*.rdb
usage_log.txt
.DS_Store
3 changes: 0 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install git
brew install node
brew install redis

git clone https://github.com/Aspine/aspine.git
cd aspine
npm install
2 changes: 1 addition & 1 deletion public/css/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ button {
}


.tab button#logout {
.tab .tablinks-right {
float: right;
}

Expand Down
10 changes: 7 additions & 3 deletions public/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,23 @@ <h4 id="title">
<button class="tablinks" onclick="openTab(event, 'recent')">Recent Activity</button>
<button class="tablinks" onclick="openTab(event, 'schedule')">Schedule</button>
<button class="tablinks" onclick="openTab(event, 'clock')">Clock</button>

<!--<button class="tablinks" onclick="openTab(event, 'calendar-tab')">Calendar</button>-->
<!--<button class="tablinks" onclick="openTab(event, 'reports')">Reports</button>-->
<button class="tablinks" onclick="location.href='/logout'" id="logout">Logout</button>
<button class="tablinks tablinks-right" onclick="location.href='/logout'">Logout</button>
<div class="GPA custom-select" style="width:270px;">
<select id="gpa_select">
<select id="gpa_select">
<option id="init_gpa" value="0">Current Quarter GPA: </option>
<option id="current_gpa" value="1">Current Quarter GPA: </option>
<option id="current_gpa" value="0">Current Quarter GPA: </option>
<option id="q1_gpa" value="1">Q1 GPA:</option>
<option id="q2_gpa" value="2">Q2 GPA:</option>
<option id="q3_gpa" value="3">Q3 GPA:</option>
<option id="q4_gpa" value="4">Q4 GPA:</option>
<option id="cum_gpa"></option>
</select>
</div>
<button class="tablinks tablinks-right" onclick="GPAType();">GPA Type</button>

</div>

<!--<div id="loader" class="modal" style="background-color: rgba(0,0,0,0.0); padding-top: 300px; display: inline-block;">-->
Expand Down
81 changes: 45 additions & 36 deletions public/home.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -615,21 +615,17 @@ let termsReset = {};

}

// Calculate GPA for current term
tableData.terms.current.GPA = computeGPA(tableData.terms.current.classes);

tableData.overview = response.overview;

tableData.cumGPA = cumGPA(tableData.overview);
document.getElementById("cum_gpa").innerHTML = "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2);

// Calculate GPA for each quarter
for (let i = 1; i <= 4; i++) {
let sum = 0;
let count = 0;
for (let j = 0; j < tableData.overview.length; j++) {
if (tableData.overview[j]["q" + i] != "") {
if (parseFloat(tableData.overview[j]["q" + i]) > 100 ) {
sum += 100;
} else {
sum += parseFloat(tableData.overview[j]["q" + i]);
}
count++;
}
}
tableData.terms["q" + i].GPA = Math.round(sum / count * 100) / 100;
tableData.terms["q" + i].GPA = computeGPAQuarter(tableData.overview,i);
}

//Stuff to do now that tableData is initialized
Expand All @@ -640,25 +636,27 @@ let termsReset = {};
initialize_quarter_dropdown();
termsReset[currentTerm] = JSON.parse(JSON.stringify(tableData.terms[currentTerm]));

$(".select-selected").html("Current Quarter GPA: " + tableData.currentTermData.GPA);
$("#current").html("Current Quarter GPA: " + tableData.currentTermData.GPA);
document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA;
document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA;
$(".select-selected").html("Current Quarter GPA: " + tableData.currentTermData.GPA.percent);
$("#current").html("Current Quarter GPA: " + tableData.currentTermData.GPA.percent);
document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA.percent;
document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA.percent;

$(".select-items").children().each(function(i, elem) {
if (i == 0) {
$(this).html("Current Quarter GPA: " + tableData.terms["current"].GPA);
document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + tableData.terms["current"].GPA;
document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + tableData.terms["current"].GPA;
if(i < 5) {//Don't try to get quarter data for the 5th element in the list because that's not a quarter...
if (i == 0) {
$(this).html("Current Quarter GPA: " + tableData.terms["current"].GPA.percent);
document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + tableData.terms["current"].GPA.percent;
document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + tableData.terms["current"].GPA.percent;
} else {
if (!isNaN(tableData.terms["q" + i].GPA)) {
$(this).html("Q" + i + " GPA: " + tableData.terms["q" + i].GPA);
document.getElementById('gpa_select').options[i + 1].innerHTML ="Q" + i + " GPA: " + tableData.terms["q" + i].GPA;
if (!isNaN(tableData.terms["q" + i].GPA.percent)) {
$(this).html("Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent);
document.getElementById('gpa_select').options[i + 1].innerHTML ="Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent;
} else {
$(this).html("Q" + i + " GPA: None");
document.getElementById('gpa_select').options[i + 1].innerHTML ="Q" + i + " GPA: None";
}
}
}
});
// scheduleTable.setData(tableData.schedule.black);
recentActivity.setData(tableData.recent.recentActivityArray);
Expand All @@ -676,32 +674,37 @@ let termsReset = {};
}

function responseCallbackPartial(response) {

$("#loader").hide();

tableData.currentTermData = parseTableData(response.classes);

tableData.terms[currentTerm] = parseTableData(response.classes);
tableData.currentTermData = tableData.terms[currentTerm];

let temp_term_data = parseTableData(response.classes);
tableData.terms[currentTerm].classes = temp_term_data.classes;
tableData.terms[currentTerm].GPA = temp_term_data.GPA;
tableData.terms[currentTerm].calcGPA = temp_term_data.calcGPA;


/*
if (currentTerm == 'current') {
$(".select-selected").html("Current Quarter GPA: " + tableData.currentTermData.GPA);
$("#current").html("Current Quarter GPA: " + tableData.currentTermData.GPA);
document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA;
document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA;

$(".select-selected").html("Current Quarter GPA: " + tableData.currentTermData.GPA.percent);
$("#current").html("Current Quarter GPA: " + tableData.currentTermData.GPA.percent);
document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA.percent;
document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA.percent;
} else {
$(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + tableData.currentTermData.GPA);
$("#q" + termConverter.indexOf(currentTerm)).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + tableData.currentTermData.GPA);
document.getElementById('gpa_select').options[termConverter.indexOf(currentTerm) + 1].innerHTML ="Q" + termConverter.indexOf(currentTerm) + " GPA: " + tableData.currentTermData.GPA;
$(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + tableData.currentTermData.GPA.percent);
$("#q" + termConverter.indexOf(currentTerm)).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + tableData.currentTermData.GPA.percent);
document.getElementById('gpa_select').options[termConverter.indexOf(currentTerm) + 1].innerHTML ="Q" + termConverter.indexOf(currentTerm) + " GPA: " + tableData.currentTermData.GPA.percent;
}
*/


scheduleTable.setData(tableData.schedule.black);

$("#classesTable").show();

classesTable.setData(response.classes); //set data of classes table to the tableData property of the response json object
classesTable.redraw();

termsReset[currentTerm] = JSON.parse(JSON.stringify(tableData.terms[currentTerm]));

Expand All @@ -723,6 +726,7 @@ function responseCallbackPartial(response) {
let timesCounter = 0;
let times = []


for (let i = 0; i < periods.length; i++) {

if (!isNaN(parseFloat(periods[i])) || periods[i] === "CM") {
Expand All @@ -740,6 +744,7 @@ function responseCallbackPartial(response) {
let colors = ["#63C082", "#72C68E", "#82CC9B", "#91D2A7", "#A1D9B4", "#B1DFC0", "#C0E5CD", "#D0ECD9"];

for (let i = 0; i < periods.length; i++) {

if (tableData.schedule.black[i]) {
tableData.schedule.black[i].period = periods[i] ? periods[i] + "<br>" + times[i] : "Extra";
tableData.schedule.black[i].class = tableData.schedule.black[i].name + "<br>" + tableData.schedule.black[i].teacher;
Expand Down Expand Up @@ -869,3 +874,7 @@ if (tab_name == "reports") {
recentAttendance.redraw();
}
document.getElementById("default_open").click();




Loading

0 comments on commit daf1ffc

Please sign in to comment.