From a1d051d4e54f5cf7f29cf5fa3166b24c8a38f9f9 Mon Sep 17 00:00:00 2001 From: kdk1616 <31357347+kdk1616@users.noreply.github.com> Date: Sun, 12 Jan 2020 17:09:17 -0500 Subject: [PATCH 01/33] Fixed mac install and start scripts (removed redis from start script). Made function for toggling between weighted, unweighted, and % GPA (only works for current quarter right now... Also, There is a bu where if you select another quarter you cannot return to the initial quarter and have it work properly...). --- README.md | 162 ++++++++++++++++++++++++++++++----------------- install.sh | 3 - public/.DS_Store | Bin 0 -> 8196 bytes public/home.html | 3 +- public/home.js | 130 +++++++++++++++++++++++++++++++++++-- start.sh | 3 +- 6 files changed, 230 insertions(+), 71 deletions(-) create mode 100644 public/.DS_Store diff --git a/README.md b/README.md index aa4a259c..e0cd54f0 100755 --- a/README.md +++ b/README.md @@ -1,29 +1,36 @@ -# Aspine +Aspine +====== -Who needs Aspen when you have Aspine. It serves as a one stop shop for everything Aspen related, and there are rainbows! +Who needs Aspen when you have Aspine. It serves as a one stop shop for +everything Aspen related, and there are rainbows! -## Getting Started +Getting Started +--------------- -Using Aspine is as easy as 1, 2, 3. Just visit aspine.us and login with your Aspen credentials. +Using Aspine is as easy as 1, 2, 3. Just visit aspine.us and login with your +Aspen credentials. -## Features +Features +-------- -* Aesthetic Grade Checking -* CRLS Clock +- Aesthetic Grade Checking + +- CRLS Clock ![CRLS Clock Image](images/crls_clock.png) -* Grade Comparison via boxplot +- Grade Comparison via boxplot ![Example Boxplot Image](images/boxplot.png) -* Calendar +- Calendar ![Example Calendar Image](images/calendar.png) -* Chat with your classmates (coming soon...) +- Chat with your classmates (coming soon...) -## FAQ +FAQ +--- ##### How are usernames and passwords handled? @@ -31,76 +38,113 @@ Aspine does not store any usernames or passwords. ##### How are calculated grades computed? -First, calculated category percentages are computed by dividing a student's total earned points within a category by the total available points for that category. Then, the category percentages are multiplied by their respective weights and summed in order to produce the calculated grade for a class. +First, calculated category percentages are computed by dividing a student's +total earned points within a category by the total available points for that +category. Then, the category percentages are multiplied by their respective +weights and summed in order to produce the calculated grade for a class. + +Note: \* Assignments scored with free text (i.e. "Missing", "Exempt") are +ignored during grade computation. (Improvements coming soon) \* Due to the +mysterious workings of Aspen, it is impossible to achieve 100% accuracy when +making grade prediction calculations. That being said, Aspine's cutting edge +grade calcuation algorithm is unmatched. + +Built With +---------- + +- [Tabulator](https://github.com/olifolkerd/tabulator) + +- [Plotly](https://plot.ly/javascript/) + +- [CRLS Clock](https://github.com/CRLSCSClub/CRLSTime) + +- [Full Calendar](https://fullcalendar.io/) -Note: -* Assignments scored with free text (i.e. "Missing", "Exempt") are ignored during grade computation. (Improvements coming soon) -* Due to the mysterious workings of Aspen, it is impossible to achieve 100% accuracy when making grade prediction calculations. That being said, Aspine's cutting edge grade calcuation algorithm is unmatched. +Contributing / Locally Running Aspine +------------------------------------- +Feel free to suggest an enhancement or post a bug issue either via github issues +or this [google form](https://goo.gl/forms/PYQDtzkp0vHJbFLz2)! -## Built With -* [Tabulator](https://github.com/olifolkerd/tabulator) -* [Plotly](https://plot.ly/javascript/) -* [CRLS Clock](https://github.com/CRLSCSClub/CRLSTime) -* [Full Calendar](https://fullcalendar.io/) +If you would like to directly contribute to Aspine, you can fork this repository +and clone your fork on your computer with a [git](https://git-scm.com/) client. -## Contributing / Locally Running Aspine +If you would just like to try out Aspine on your computer, you can click on +"Clone or download" above the file list and download and extract a ZIP file with +Aspine. -Feel free to suggest an enhancement or post a bug issue either via github issues or this [google form](https://goo.gl/forms/PYQDtzkp0vHJbFLz2)! +Right-click on the file "install1.bat" and click "Run as administrator" to begin +the process. If you have already done this, double-click on the file +"npminstall.bat". The ".bat" file extension may be invisible depending on your +system configuration. -If you would like to directly contribute to Aspine, you can fork this repository and clone your fork on your computer with a [git](https://git-scm.com/) client. +- Make sure that you have installed [node.js](https://nodejs.org/), npm, and + [redis](https://redis.io/). -If you would just like to try out Aspine on your computer, you can click on "Clone or download" above the file list and download and extract a ZIP file with Aspine. +- On GNU+Linux, you should be able to find both of these in your package + manager (e.g. `apt`/`dpkg`, `yum`/`dnf`, `zypper`, `pacman`). npm may be in + a separate package from node.js. -If you use Windows, you can just right-click on the file "install1.bat" and click "Run as administrator" to begin the process. If you have already done this, double-click on the file "npminstall.bat". The ".bat" file extension may be invisible depending on your system configuration. +- On macOS, node.js (including npm) and redis are available on + [Homebrew](https://brew.sh/), as + [node](https://formulae.brew.sh/formula/node) and + [redis](https://formulae.brew.sh/formula/redis) respectively. You can run + the script `install.sh` to install these dependencies. -* Make sure that you have installed [node.js](https://nodejs.org/), npm, and [redis](https://redis.io/). - * On GNU+Linux, you should be able to find both of these in your package manager (e.g. `apt`/`dpkg`, `yum`/`dnf`, `zypper`, `pacman`). npm may be in a separate package from node.js. - * On macOS, node.js (including npm) and redis are available on [Homebrew](https://brew.sh/), as [`node`](https://formulae.brew.sh/formula/node) and [`redis`](https://formulae.brew.sh/formula/redis) respectively. You can run the script `install.sh` to install these dependencies. - * Open a new terminal or command prompt, navigate to the directory in which you cloned the Aspine git repository, and run `npm install` to install the remaining dependencies. -* Open another terminal or command prompt, navigate to that same directory, and run `redis-server redis.conf`. -* In the other terminal or command prompt, run `node ./serve.js insecure`, or `node ./serve.js insecure fake` to use the `sample.json` file instead of pulling from Aspen (for faster testing). +- Open a new terminal or command prompt, navigate to the directory in which + you cloned the Aspine git repository, and run `npm install` to install the + remaining dependencies. -## Authors +- Open another terminal or command prompt, navigate to that same directory, + and run `redis-server redis.conf`. -* [**Max Katz-Christy**](https://github.com/maxtkc) -* [**Cole Killian**](https://github.com/ruborcalor) -* [**psvenk**](https://github.com/psvenk) +- In the other terminal or command prompt, run `node ./serve.js insecure`, or + `node ./serve.js insecure fake` to use the `sample.json` file instead of + pulling from Aspen (for faster testing). +Authors +------- -## [Color Scheme](http://paletton.com/#uid=12W0u0kw0e-n8nFrjj8Hz9QS55d) +- [Max Katz-Christy](https://github.com/maxtkc) + +- [Cole Killian](https://github.com/ruborcalor) + +- [psvenk](https://github.com/psvenk) + +[Color Scheme](http://paletton.com/#uid=12W0u0kw0e-n8nFrjj8Hz9QS55d) +-------------------------------------------------------------------- ![Color Palette](images/color_palette.png) -``` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Primary Color: #00551D Secondary Colors: - #268A48 - #107031 - #003913 - #001E0A -``` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #### Grade Lettering and Coloring -| Grade Range | Letter | Primary Color | Secondary Color | -| :----------- |:--------------|:------ |:------ | -| 96.5 - 100 | A+ |#1E8541 |#3d995c | -| 92.5 - 96.4 | A |#1E8541 |#3d995c | -| 89.5 - 92.4 | A- |#1E8541 |#3d995c | -| 86.5 - 89.4 | B+ |#6666FF |#a3a3f5 | -| 82.5 - 86.4 | B |#6666FF |#a3a3f5 | -| 79.5 - 82.4 | B- |#6666FF |#a3a3f5 | -| 76.5 - 79.4 | C+ |#ff9900 |#eba947 | -| 72.5 - 76.4 | C |#ff9900 |#eba947 | -| 69.5 - 72.4 | C- |#ff9900 |#eba947 | -| 66.5 - 69.4 | D+ |Orange |#ebb147 | -| 62.5 - 66.4 | D |Orange |#ebb147 | -| 59.5 - 62.4 | D- |Orange |#ebb147 | -| 0 - 59.4 | F |Red |#eb4747 | - - - -## License - -This project is licensed under the GNU General Public License, version 3 - see the [LICENSE.md](LICENSE.md) file for details. +| Grade Range | Letter | Primary Color | Secondary Color | +|-------------|--------|---------------|-----------------| +| 96.5 - 100 | A+ | \#1E8541 | \#3d995c | +| 92.5 - 96.4 | A | \#1E8541 | \#3d995c | +| 89.5 - 92.4 | A- | \#1E8541 | \#3d995c | +| 86.5 - 89.4 | B+ | \#6666FF | \#a3a3f5 | +| 82.5 - 86.4 | B | \#6666FF | \#a3a3f5 | +| 79.5 - 82.4 | B- | \#6666FF | \#a3a3f5 | +| 76.5 - 79.4 | C+ | \#ff9900 | \#eba947 | +| 72.5 - 76.4 | C | \#ff9900 | \#eba947 | +| 69.5 - 72.4 | C- | \#ff9900 | \#eba947 | +| 66.5 - 69.4 | D+ | Orange | \#ebb147 | +| 62.5 - 66.4 | D | Orange | \#ebb147 | +| 59.5 - 62.4 | D- | Orange | \#ebb147 | +| 0 - 59.4 | F | Red | \#eb4747 | + +License +------- + +This project is licensed under the GNU General Public License, version 3 - see +the [LICENSE.md](LICENSE.md) file for details. diff --git a/install.sh b/install.sh index fedf376d..5114911d 100755 --- a/install.sh +++ b/install.sh @@ -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 diff --git a/public/.DS_Store b/public/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7c363d94628424ebacd3c57bc5fde9ce2b562f38 GIT binary patch literal 8196 zcmeHM&2G~`5S~raHlYplP^m>+d;p0GHFkl!k3|s{U@XY2`%y{mrvt~35 z7zX}J2KfG9p|h;Ta;T)dbzqPs0AvA&Wy2hGfW%m_ti^Juq=dqzsvblP6>*6n6ddO* zR)?&`a;T(&lTdIHv1buiC_;J%&XVdRYD${XFkl!MXMk(>Sz1NC?xA|u>-TUkh?-6i zIndywx{rSMmu#33<*7++YNxcmq_n2!5MKjA>ZCQrVoLKC9YHg~7+@{yv`G#;R506y zjdlFGM=qpCTbQrXF>Ibvkn}I!r>vHs7eUXUeN zrJJKMd->B7Bm0NISc%Dr&9SLa{0p4^h}Xkx%jei9Q7Ii1~;gqhs`d7~8u zQFz44=+~JOy1vnKAlrF<>N!jM_EQi2p@-|UGYwl3rQq##^|0Fpwk5lF80%roVYTF zTGAr3GtrLBC*960yp0&iL~*|8sJR4cEfdFCla1TR!pZ#6ab@^xBI7*lw<|M0V}Ci$ zCLLLlY&P+|(UURbQn4J{{DYS-i#T;fMMV&G9U`O zjoms{_UGj-y-2RLE%XC)Zmc&{QbI7uavV~Y
- diff --git a/public/home.js b/public/home.js index 66766de1..a71f526a 100644 --- a/public/home.js +++ b/public/home.js @@ -2,6 +2,7 @@ let pdf_index = 0; let termConverter = ['current', 'q1', 'q2', 'q3', 'q4']; let pdfrendering = false; +let curQ = 0; let statsModal = document.getElementById('stats_modal'); let term_dropdown_active = true; let currentTerm = "current"; @@ -619,17 +620,101 @@ let termsReset = {}; for (let i = 1; i <= 4; i++) { let sum = 0; let count = 0; + let fourSum = 0; + let fiveSum = 0; for (let j = 0; j < tableData.overview.length; j++) { if (tableData.overview[j]["q" + i] != "") { - if (parseFloat(tableData.overview[j]["q" + i]) > 100 ) { + + if (parseFloat(tableData.overview[j]["q" + i]) > 100 ) { sum += 100; } else { sum += parseFloat(tableData.overview[j]["q" + i]); } count++; - } + + //--------GPA OUT OF 4.0 + let curG = 0; + if(parseFloat(tableData.overview[j]["q" + i]) >= 63) { + + } + if(parseFloat(tableData.overview[j]["q" + i]) >= 66) { + curG = 1.0; + + } + if(parseFloat(tableData.overview[j]["q" + i]) >= 67) { + curG = 1.3; + + } + if(parseFloat(tableData.overview[j]["q" + i]) >= 70) { + curG = 1.7; + + } + + if(parseFloat(tableData.overview[j]["q" + i]) >= 73) { + curG = 2.0; + + } + + if(parseFloat(tableData.overview[j]["q" + i]) >= 77) { + curG = 2.3; + + } + if(parseFloat(tableData.overview[j]["q" + i]) >= 80) { + curG = 2.7; + + } + if(parseFloat(tableData.overview[j]["q" + i]) >= 83) { + curG = 3.0; + + } + if(parseFloat(tableData.overview[j]["q" + i]) >= 87) { + curG = 3.3; + + } + if(parseFloat(tableData.overview[j]["q" + i]) >= 90) { + curG = 3.7; + + } + if(parseFloat(tableData.overview[j]["q" + i]) >= 93) { + curG = 4.0; + } + + if(parseFloat(tableData.overview[j]["q" + i]) >= 97) { + curG = 4.0; + } + fourSum += curG; + fiveSum += curG; + + + if(tableData.overview[j].class.includes("AP")) { + fiveSum += 1; + } + if(tableData.overview[j].class.includes("HN")) { + fiveSum += .5 + } + + //----WEIGHTED GPA (OUT OF 5.0)------- + + + } + console.log(fiveSum + "" + tableData.overview[j].class); } + console.log(fiveSum); + console.log(count); tableData.terms["q" + i].GPA = Math.round(sum / count * 100) / 100; + tableData.terms["q" + i].outOfFourGPA = fourSum / count; + tableData.terms["q" + i].outOfFiveGPA = fiveSum / count; + + + if(i == 2) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** + tableData.currentTermData.outOfFourGPA = fourSum / count; + tableData.currentTermData.outOfFiveGPA = fiveSum / count; + + } + + + + } //Stuff to do now that tableData is initialized @@ -640,16 +725,16 @@ let termsReset = {}; initialize_quarter_dropdown(); termsReset[currentTerm] = JSON.parse(JSON.stringify(tableData.terms[currentTerm])); - $(".select-selected").html("Current Quarter GPA: " + tableData.currentTermData.GPA); + $(".select-selected").html("Current Quarter GPA Percent: " + 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; + document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA Percent: " + tableData.currentTermData.GPA; + document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA Percent: " + tableData.currentTermData.GPA; $(".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; + document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA Percent: " + tableData.terms["current"].GPA; + document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA Percent: " + tableData.terms["current"].GPA; } else { if (!isNaN(tableData.terms["q" + i].GPA)) { $(this).html("Q" + i + " GPA: " + tableData.terms["q" + i].GPA); @@ -674,6 +759,31 @@ let termsReset = {}; success: scheduleCallback }); } + + + function GPAType() { + var e = document.getElementById("gpa_select"); + var i = e.options[e.selectedIndex].value; + + if(i == 0) {//NEEDS TO BE CHANGED ON NEXT QUARTER + + i = 2; + } + + if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Percent")) { + $(".select-selected").html("Current Quarter GPA Unweighted: " + tableData.terms["q" + i].outOfFourGPA); + } + else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Unweighted")) { + $(".select-selected").html("Current Quarter GPA Weighted: " + tableData.terms["q" + i].outOfFiveGPA); + + } + + else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Weighted")) { + $(".select-selected").html("Current Quarter GPA Percent: " + tableData.terms["q" + i].GPA); + + } + + } function responseCallbackPartial(response) { @@ -723,6 +833,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") { @@ -740,6 +851,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] + "
" + times[i] : "Extra"; tableData.schedule.black[i].class = tableData.schedule.black[i].name + "
" + tableData.schedule.black[i].teacher; @@ -869,3 +981,7 @@ if (tab_name == "reports") { recentAttendance.redraw(); } document.getElementById("default_open").click(); + + + + diff --git a/start.sh b/start.sh index 671a721d..41f66bc2 100755 --- a/start.sh +++ b/start.sh @@ -1,2 +1,3 @@ #!/bin/bash -redis-server redis.conf & node ./serve.js insecure + +node ./serve.js insecure From 7d3e7238b5be78c7cfb240676e7d303d291630bf Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Sun, 12 Jan 2020 17:51:08 -0500 Subject: [PATCH 02/33] Revert changes to README Apparently kdk1616's editor completely changed the formatting of the README. As there were no substantial changes, I have reverted all changes that were made to the README. --- .gitignore | 1 + README.md | 162 +++++++++++++++++------------------------------ public/.DS_Store | Bin 8196 -> 0 bytes 3 files changed, 60 insertions(+), 103 deletions(-) delete mode 100644 public/.DS_Store diff --git a/.gitignore b/.gitignore index 8863ae54..2b0e0501 100755 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ package-lock.json db/*.rdb usage_log.txt +.DS_Store diff --git a/README.md b/README.md index e0cd54f0..aa4a259c 100755 --- a/README.md +++ b/README.md @@ -1,36 +1,29 @@ -Aspine -====== +# Aspine -Who needs Aspen when you have Aspine. It serves as a one stop shop for -everything Aspen related, and there are rainbows! +Who needs Aspen when you have Aspine. It serves as a one stop shop for everything Aspen related, and there are rainbows! -Getting Started ---------------- +## Getting Started -Using Aspine is as easy as 1, 2, 3. Just visit aspine.us and login with your -Aspen credentials. +Using Aspine is as easy as 1, 2, 3. Just visit aspine.us and login with your Aspen credentials. -Features --------- +## Features -- Aesthetic Grade Checking - -- CRLS Clock +* Aesthetic Grade Checking +* CRLS Clock ![CRLS Clock Image](images/crls_clock.png) -- Grade Comparison via boxplot +* Grade Comparison via boxplot ![Example Boxplot Image](images/boxplot.png) -- Calendar +* Calendar ![Example Calendar Image](images/calendar.png) -- Chat with your classmates (coming soon...) +* Chat with your classmates (coming soon...) -FAQ ---- +## FAQ ##### How are usernames and passwords handled? @@ -38,113 +31,76 @@ Aspine does not store any usernames or passwords. ##### How are calculated grades computed? -First, calculated category percentages are computed by dividing a student's -total earned points within a category by the total available points for that -category. Then, the category percentages are multiplied by their respective -weights and summed in order to produce the calculated grade for a class. - -Note: \* Assignments scored with free text (i.e. "Missing", "Exempt") are -ignored during grade computation. (Improvements coming soon) \* Due to the -mysterious workings of Aspen, it is impossible to achieve 100% accuracy when -making grade prediction calculations. That being said, Aspine's cutting edge -grade calcuation algorithm is unmatched. - -Built With ----------- - -- [Tabulator](https://github.com/olifolkerd/tabulator) - -- [Plotly](https://plot.ly/javascript/) - -- [CRLS Clock](https://github.com/CRLSCSClub/CRLSTime) - -- [Full Calendar](https://fullcalendar.io/) +First, calculated category percentages are computed by dividing a student's total earned points within a category by the total available points for that category. Then, the category percentages are multiplied by their respective weights and summed in order to produce the calculated grade for a class. -Contributing / Locally Running Aspine -------------------------------------- +Note: +* Assignments scored with free text (i.e. "Missing", "Exempt") are ignored during grade computation. (Improvements coming soon) +* Due to the mysterious workings of Aspen, it is impossible to achieve 100% accuracy when making grade prediction calculations. That being said, Aspine's cutting edge grade calcuation algorithm is unmatched. -Feel free to suggest an enhancement or post a bug issue either via github issues -or this [google form](https://goo.gl/forms/PYQDtzkp0vHJbFLz2)! -If you would like to directly contribute to Aspine, you can fork this repository -and clone your fork on your computer with a [git](https://git-scm.com/) client. +## Built With +* [Tabulator](https://github.com/olifolkerd/tabulator) +* [Plotly](https://plot.ly/javascript/) +* [CRLS Clock](https://github.com/CRLSCSClub/CRLSTime) +* [Full Calendar](https://fullcalendar.io/) -If you would just like to try out Aspine on your computer, you can click on -"Clone or download" above the file list and download and extract a ZIP file with -Aspine. +## Contributing / Locally Running Aspine -Right-click on the file "install1.bat" and click "Run as administrator" to begin -the process. If you have already done this, double-click on the file -"npminstall.bat". The ".bat" file extension may be invisible depending on your -system configuration. +Feel free to suggest an enhancement or post a bug issue either via github issues or this [google form](https://goo.gl/forms/PYQDtzkp0vHJbFLz2)! -- Make sure that you have installed [node.js](https://nodejs.org/), npm, and - [redis](https://redis.io/). +If you would like to directly contribute to Aspine, you can fork this repository and clone your fork on your computer with a [git](https://git-scm.com/) client. -- On GNU+Linux, you should be able to find both of these in your package - manager (e.g. `apt`/`dpkg`, `yum`/`dnf`, `zypper`, `pacman`). npm may be in - a separate package from node.js. +If you would just like to try out Aspine on your computer, you can click on "Clone or download" above the file list and download and extract a ZIP file with Aspine. -- On macOS, node.js (including npm) and redis are available on - [Homebrew](https://brew.sh/), as - [node](https://formulae.brew.sh/formula/node) and - [redis](https://formulae.brew.sh/formula/redis) respectively. You can run - the script `install.sh` to install these dependencies. +If you use Windows, you can just right-click on the file "install1.bat" and click "Run as administrator" to begin the process. If you have already done this, double-click on the file "npminstall.bat". The ".bat" file extension may be invisible depending on your system configuration. -- Open a new terminal or command prompt, navigate to the directory in which - you cloned the Aspine git repository, and run `npm install` to install the - remaining dependencies. +* Make sure that you have installed [node.js](https://nodejs.org/), npm, and [redis](https://redis.io/). + * On GNU+Linux, you should be able to find both of these in your package manager (e.g. `apt`/`dpkg`, `yum`/`dnf`, `zypper`, `pacman`). npm may be in a separate package from node.js. + * On macOS, node.js (including npm) and redis are available on [Homebrew](https://brew.sh/), as [`node`](https://formulae.brew.sh/formula/node) and [`redis`](https://formulae.brew.sh/formula/redis) respectively. You can run the script `install.sh` to install these dependencies. + * Open a new terminal or command prompt, navigate to the directory in which you cloned the Aspine git repository, and run `npm install` to install the remaining dependencies. +* Open another terminal or command prompt, navigate to that same directory, and run `redis-server redis.conf`. +* In the other terminal or command prompt, run `node ./serve.js insecure`, or `node ./serve.js insecure fake` to use the `sample.json` file instead of pulling from Aspen (for faster testing). -- Open another terminal or command prompt, navigate to that same directory, - and run `redis-server redis.conf`. +## Authors -- In the other terminal or command prompt, run `node ./serve.js insecure`, or - `node ./serve.js insecure fake` to use the `sample.json` file instead of - pulling from Aspen (for faster testing). +* [**Max Katz-Christy**](https://github.com/maxtkc) +* [**Cole Killian**](https://github.com/ruborcalor) +* [**psvenk**](https://github.com/psvenk) -Authors -------- -- [Max Katz-Christy](https://github.com/maxtkc) - -- [Cole Killian](https://github.com/ruborcalor) - -- [psvenk](https://github.com/psvenk) - -[Color Scheme](http://paletton.com/#uid=12W0u0kw0e-n8nFrjj8Hz9QS55d) --------------------------------------------------------------------- +## [Color Scheme](http://paletton.com/#uid=12W0u0kw0e-n8nFrjj8Hz9QS55d) ![Color Palette](images/color_palette.png) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``` Primary Color: #00551D Secondary Colors: - #268A48 - #107031 - #003913 - #001E0A -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``` #### Grade Lettering and Coloring -| Grade Range | Letter | Primary Color | Secondary Color | -|-------------|--------|---------------|-----------------| -| 96.5 - 100 | A+ | \#1E8541 | \#3d995c | -| 92.5 - 96.4 | A | \#1E8541 | \#3d995c | -| 89.5 - 92.4 | A- | \#1E8541 | \#3d995c | -| 86.5 - 89.4 | B+ | \#6666FF | \#a3a3f5 | -| 82.5 - 86.4 | B | \#6666FF | \#a3a3f5 | -| 79.5 - 82.4 | B- | \#6666FF | \#a3a3f5 | -| 76.5 - 79.4 | C+ | \#ff9900 | \#eba947 | -| 72.5 - 76.4 | C | \#ff9900 | \#eba947 | -| 69.5 - 72.4 | C- | \#ff9900 | \#eba947 | -| 66.5 - 69.4 | D+ | Orange | \#ebb147 | -| 62.5 - 66.4 | D | Orange | \#ebb147 | -| 59.5 - 62.4 | D- | Orange | \#ebb147 | -| 0 - 59.4 | F | Red | \#eb4747 | - -License -------- - -This project is licensed under the GNU General Public License, version 3 - see -the [LICENSE.md](LICENSE.md) file for details. +| Grade Range | Letter | Primary Color | Secondary Color | +| :----------- |:--------------|:------ |:------ | +| 96.5 - 100 | A+ |#1E8541 |#3d995c | +| 92.5 - 96.4 | A |#1E8541 |#3d995c | +| 89.5 - 92.4 | A- |#1E8541 |#3d995c | +| 86.5 - 89.4 | B+ |#6666FF |#a3a3f5 | +| 82.5 - 86.4 | B |#6666FF |#a3a3f5 | +| 79.5 - 82.4 | B- |#6666FF |#a3a3f5 | +| 76.5 - 79.4 | C+ |#ff9900 |#eba947 | +| 72.5 - 76.4 | C |#ff9900 |#eba947 | +| 69.5 - 72.4 | C- |#ff9900 |#eba947 | +| 66.5 - 69.4 | D+ |Orange |#ebb147 | +| 62.5 - 66.4 | D |Orange |#ebb147 | +| 59.5 - 62.4 | D- |Orange |#ebb147 | +| 0 - 59.4 | F |Red |#eb4747 | + + + +## License + +This project is licensed under the GNU General Public License, version 3 - see the [LICENSE.md](LICENSE.md) file for details. diff --git a/public/.DS_Store b/public/.DS_Store deleted file mode 100644 index 7c363d94628424ebacd3c57bc5fde9ce2b562f38..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM&2G~`5S~raHlYplP^m>+d;p0GHFkl!k3|s{U@XY2`%y{mrvt~35 z7zX}J2KfG9p|h;Ta;T)dbzqPs0AvA&Wy2hGfW%m_ti^Juq=dqzsvblP6>*6n6ddO* zR)?&`a;T(&lTdIHv1buiC_;J%&XVdRYD${XFkl!MXMk(>Sz1NC?xA|u>-TUkh?-6i zIndywx{rSMmu#33<*7++YNxcmq_n2!5MKjA>ZCQrVoLKC9YHg~7+@{yv`G#;R506y zjdlFGM=qpCTbQrXF>Ibvkn}I!r>vHs7eUXUeN zrJJKMd->B7Bm0NISc%Dr&9SLa{0p4^h}Xkx%jei9Q7Ii1~;gqhs`d7~8u zQFz44=+~JOy1vnKAlrF<>N!jM_EQi2p@-|UGYwl3rQq##^|0Fpwk5lF80%roVYTF zTGAr3GtrLBC*960yp0&iL~*|8sJR4cEfdFCla1TR!pZ#6ab@^xBI7*lw<|M0V}Ci$ zCLLLlY&P+|(UURbQn4J{{DYS-i#T;fMMV&G9U`O zjoms{_UGj-y-2RLE%XC)Zmc&{QbI7uavV~Y Date: Sun, 12 Jan 2020 21:44:42 -0500 Subject: [PATCH 03/33] Fixed GPA Toggle not working for other quarters... had to hardcode variable for current term --- public/home.js | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) mode change 100644 => 100755 public/home.js diff --git a/public/home.js b/public/home.js old mode 100644 new mode 100755 index a71f526a..2aabdfa6 --- a/public/home.js +++ b/public/home.js @@ -1,4 +1,5 @@ ////////////////////Global Variables/////// +let currentQuarterRightNow = 2; //REMOVE THIS!!!!!!!!! let pdf_index = 0; let termConverter = ['current', 'q1', 'q2', 'q3', 'q4']; let pdfrendering = false; @@ -706,7 +707,7 @@ let termsReset = {}; tableData.terms["q" + i].outOfFiveGPA = fiveSum / count; - if(i == 2) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** + if(i == currentQuarterRightNow) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** tableData.currentTermData.outOfFourGPA = fourSum / count; tableData.currentTermData.outOfFiveGPA = fiveSum / count; @@ -727,14 +728,14 @@ let termsReset = {}; $(".select-selected").html("Current Quarter GPA Percent: " + tableData.currentTermData.GPA); $("#current").html("Current Quarter GPA: " + tableData.currentTermData.GPA); - document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA Percent: " + tableData.currentTermData.GPA; - document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA Percent: " + 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-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 Percent: " + tableData.terms["current"].GPA; - document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA Percent: " + 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; } else { if (!isNaN(tableData.terms["q" + i].GPA)) { $(this).html("Q" + i + " GPA: " + tableData.terms["q" + i].GPA); @@ -765,21 +766,26 @@ let termsReset = {}; var e = document.getElementById("gpa_select"); var i = e.options[e.selectedIndex].value; + + var quarter = i; if(i == 0) {//NEEDS TO BE CHANGED ON NEXT QUARTER - - i = 2; + i = currentQuarterRightNow;//CURRENT QUARTER... WONT BE 2 FOR LONG + quarter = "Current Quarter"; + } + else { + quarter = "Q" + i; } - if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Percent")) { - $(".select-selected").html("Current Quarter GPA Unweighted: " + tableData.terms["q" + i].outOfFourGPA); + if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("GPA")) { + $(".select-selected").html(quarter +" Unweighted: " + tableData.terms["q" + i].outOfFourGPA); } else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Unweighted")) { - $(".select-selected").html("Current Quarter GPA Weighted: " + tableData.terms["q" + i].outOfFiveGPA); + $(".select-selected").html(quarter +" Weighted: " + tableData.terms["q" + i].outOfFiveGPA); } else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Weighted")) { - $(".select-selected").html("Current Quarter GPA Percent: " + tableData.terms["q" + i].GPA); + $(".select-selected").html(quarter +" GPA: " + tableData.terms["q" + i].GPA); } @@ -791,7 +797,11 @@ function responseCallbackPartial(response) { tableData.currentTermData = parseTableData(response.classes); - tableData.terms[currentTerm] = parseTableData(response.classes); + let temp_term_data = parseTableData(response.classes); + tableData.terms[currentTerm].classes = temp_term_data.classes; + tableData.terms[currentTerm].GPA = temp_term_data.calcGPA; + tableData.terms[currentTerm].calcGPA = parseTableData(response.classes).calcGPA; + if (currentTerm == 'current') { @@ -812,6 +822,7 @@ function responseCallbackPartial(response) { $("#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])); From 8da0aa40652ff5d1de32569d464c4d8611929438 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 15:28:29 -0500 Subject: [PATCH 04/33] Use function for getting GPA out of 4.0 There is a function in extraFunctions.js to convert a percentage to a GPA out of 4.0; the inline code duplicating that behavior has been replaced by a function call. --- public/home.js | 50 +------------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/public/home.js b/public/home.js index 2aabdfa6..37f48917 100755 --- a/public/home.js +++ b/public/home.js @@ -634,55 +634,7 @@ let termsReset = {}; count++; //--------GPA OUT OF 4.0 - let curG = 0; - if(parseFloat(tableData.overview[j]["q" + i]) >= 63) { - - } - if(parseFloat(tableData.overview[j]["q" + i]) >= 66) { - curG = 1.0; - - } - if(parseFloat(tableData.overview[j]["q" + i]) >= 67) { - curG = 1.3; - - } - if(parseFloat(tableData.overview[j]["q" + i]) >= 70) { - curG = 1.7; - - } - - if(parseFloat(tableData.overview[j]["q" + i]) >= 73) { - curG = 2.0; - - } - - if(parseFloat(tableData.overview[j]["q" + i]) >= 77) { - curG = 2.3; - - } - if(parseFloat(tableData.overview[j]["q" + i]) >= 80) { - curG = 2.7; - - } - if(parseFloat(tableData.overview[j]["q" + i]) >= 83) { - curG = 3.0; - - } - if(parseFloat(tableData.overview[j]["q" + i]) >= 87) { - curG = 3.3; - - } - if(parseFloat(tableData.overview[j]["q" + i]) >= 90) { - curG = 3.7; - - } - if(parseFloat(tableData.overview[j]["q" + i]) >= 93) { - curG = 4.0; - } - - if(parseFloat(tableData.overview[j]["q" + i]) >= 97) { - curG = 4.0; - } + let curG = getGPA(tableData.overview[j]["q" + i]); fourSum += curG; fiveSum += curG; From 9b101e479bf2c2e8e0ed34876735f607d5b546ab Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 15:36:43 -0500 Subject: [PATCH 05/33] Use tableData.terms.current for current term This is a minor change, as the currently selected term is the same as the current term when Aspine is first loading, but it aids code readability for the refactoring to come. --- public/home.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/home.js b/public/home.js index 37f48917..c8f41098 100755 --- a/public/home.js +++ b/public/home.js @@ -660,8 +660,8 @@ let termsReset = {}; if(i == currentQuarterRightNow) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** - tableData.currentTermData.outOfFourGPA = fourSum / count; - tableData.currentTermData.outOfFiveGPA = fiveSum / count; + tableData.terms.current.outOfFourGPA = fourSum / count; + tableData.terms.current.outOfFiveGPA = fiveSum / count; } From 5ed4a2f38886e4761ab074e2b96d56f1b54f72bc Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 15:55:48 -0500 Subject: [PATCH 06/33] Use for..of loop instead of iterator in GPA calculation Abstracting away the iterator reduces the potential for errors and simplifies the code. --- public/home.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/public/home.js b/public/home.js index c8f41098..f5f924a0 100755 --- a/public/home.js +++ b/public/home.js @@ -623,26 +623,26 @@ let termsReset = {}; let count = 0; let fourSum = 0; let fiveSum = 0; - for (let j = 0; j < tableData.overview.length; j++) { - if (tableData.overview[j]["q" + i] != "") { + for (let classOverview of tableData.overview) { + if (classOverview["q" + i] != "") { - if (parseFloat(tableData.overview[j]["q" + i]) > 100 ) { + if (parseFloat(classOverview["q" + i]) > 100 ) { sum += 100; } else { - sum += parseFloat(tableData.overview[j]["q" + i]); + sum += parseFloat(classOverview["q" + i]); } count++; //--------GPA OUT OF 4.0 - let curG = getGPA(tableData.overview[j]["q" + i]); + let curG = getGPA(classOverview["q" + i]); fourSum += curG; fiveSum += curG; - if(tableData.overview[j].class.includes("AP")) { + if(classOverview.class.includes("AP")) { fiveSum += 1; } - if(tableData.overview[j].class.includes("HN")) { + if(classOverview.class.includes("HN")) { fiveSum += .5 } @@ -650,7 +650,7 @@ let termsReset = {}; } - console.log(fiveSum + "" + tableData.overview[j].class); + console.log(fiveSum + "" + classOverview.class); } console.log(fiveSum); console.log(count); From c256f7b470f18e7c475361da96e5057abf858319 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 15:59:49 -0500 Subject: [PATCH 07/33] Improve code readability --- public/home.js | 53 +++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/public/home.js b/public/home.js index f5f924a0..0bd43a84 100755 --- a/public/home.js +++ b/public/home.js @@ -619,36 +619,31 @@ let termsReset = {}; tableData.overview = response.overview; for (let i = 1; i <= 4; i++) { - let sum = 0; - let count = 0; - let fourSum = 0; - let fiveSum = 0; + let sum = 0; // Sum of classes' grades + let count = 0; // Number of classes + let fourSum = 0; // Sum of classes' grades on 4.0 scale + let fiveSum = 0; // Sum of classes' grades on 5.0 scale for (let classOverview of tableData.overview) { - if (classOverview["q" + i] != "") { - - if (parseFloat(classOverview["q" + i]) > 100 ) { - sum += 100; - } else { - sum += parseFloat(classOverview["q" + i]); - } - count++; - - //--------GPA OUT OF 4.0 - let curG = getGPA(classOverview["q" + i]); - fourSum += curG; - fiveSum += curG; - - - if(classOverview.class.includes("AP")) { - fiveSum += 1; - } - if(classOverview.class.includes("HN")) { - fiveSum += .5 - } - - //----WEIGHTED GPA (OUT OF 5.0)------- - - + if (classOverview["q" + i]) { + if (parseFloat(classOverview["q" + i]) > 100) { + sum += 100; + } else { + sum += parseFloat(classOverview["q" + i]); + } + count++; + + //--------GPA OUT OF 4.0 + let curG = getGPA(classOverview["q" + i]); + fourSum += curG; + fiveSum += curG; + + //----WEIGHTED GPA (OUT OF 5.0)------- + if (classOverview.class.includes("AP")) { + fiveSum += 1; + } + if (classOverview.class.includes("HN")) { + fiveSum += .5 + } } console.log(fiveSum + "" + classOverview.class); } From 53ddaa6a2872aff022c4fbfad2637a0d5314ad4b Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:28:09 -0500 Subject: [PATCH 08/33] Further improve code readability and formatting --- public/home.js | 120 ++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/public/home.js b/public/home.js index 0bd43a84..a83cd7a9 100755 --- a/public/home.js +++ b/public/home.js @@ -621,48 +621,48 @@ let termsReset = {}; for (let i = 1; i <= 4; i++) { let sum = 0; // Sum of classes' grades let count = 0; // Number of classes - let fourSum = 0; // Sum of classes' grades on 4.0 scale - let fiveSum = 0; // Sum of classes' grades on 5.0 scale - for (let classOverview of tableData.overview) { - if (classOverview["q" + i]) { - if (parseFloat(classOverview["q" + i]) > 100) { + let fourSum = 0; // Sum of classes' grades on 4.0 scale + let fiveSum = 0; // Sum of classes' grades on 5.0 scale + for (let overviewClass of tableData.overview) { + if (overviewClass["q" + i]) { + if (parseFloat(overviewClass["q" + i]) > 100) { sum += 100; } else { - sum += parseFloat(classOverview["q" + i]); + sum += parseFloat(overviewClass["q" + i]); } count++; //--------GPA OUT OF 4.0 - let curG = getGPA(classOverview["q" + i]); + let curG = getGPA(overviewClass["q" + i]); fourSum += curG; - fiveSum += curG; - + //----WEIGHTED GPA (OUT OF 5.0)------- - if (classOverview.class.includes("AP")) { - fiveSum += 1; - } - if (classOverview.class.includes("HN")) { + fiveSum += curG; + if (overviewClass.class.includes("HN")) { fiveSum += .5 } - } - console.log(fiveSum + "" + classOverview.class); + if (overviewClass.class.includes("AP")) { + fiveSum += 1; + } + } + console.log(fiveSum + "" + overviewClass.class); } - console.log(fiveSum); - console.log(count); + console.log(fiveSum); + console.log(count); tableData.terms["q" + i].GPA = Math.round(sum / count * 100) / 100; tableData.terms["q" + i].outOfFourGPA = fourSum / count; tableData.terms["q" + i].outOfFiveGPA = fiveSum / count; - - - if(i == currentQuarterRightNow) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** - tableData.terms.current.outOfFourGPA = fourSum / count; - tableData.terms.current.outOfFiveGPA = fiveSum / count; - - } - - - - + + + if(i == currentQuarterRightNow) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** + tableData.terms.current.outOfFourGPA = fourSum / count; + tableData.terms.current.outOfFiveGPA = fiveSum / count; + + } + + + + } //Stuff to do now that tableData is initialized @@ -707,36 +707,36 @@ let termsReset = {}; success: scheduleCallback }); } - - - function GPAType() { - var e = document.getElementById("gpa_select"); - var i = e.options[e.selectedIndex].value; - - - var quarter = i; - if(i == 0) {//NEEDS TO BE CHANGED ON NEXT QUARTER - i = currentQuarterRightNow;//CURRENT QUARTER... WONT BE 2 FOR LONG - quarter = "Current Quarter"; - } - else { - quarter = "Q" + i; - } - - if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("GPA")) { - $(".select-selected").html(quarter +" Unweighted: " + tableData.terms["q" + i].outOfFourGPA); - } - else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Unweighted")) { - $(".select-selected").html(quarter +" Weighted: " + tableData.terms["q" + i].outOfFiveGPA); - - } - - else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Weighted")) { - $(".select-selected").html(quarter +" GPA: " + tableData.terms["q" + i].GPA); - - } - - } + + + function GPAType() { + var e = document.getElementById("gpa_select"); + var i = e.options[e.selectedIndex].value; + + + var quarter = i; + if(i == 0) {//NEEDS TO BE CHANGED ON NEXT QUARTER + i = currentQuarterRightNow;//CURRENT QUARTER... WONT BE 2 FOR LONG + quarter = "Current Quarter"; + } + else { + quarter = "Q" + i; + } + + if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("GPA")) { + $(".select-selected").html(quarter +" Unweighted: " + tableData.terms["q" + i].outOfFourGPA); + } + else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Unweighted")) { + $(".select-selected").html(quarter +" Weighted: " + tableData.terms["q" + i].outOfFiveGPA); + + } + + else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Weighted")) { + $(".select-selected").html(quarter +" GPA: " + tableData.terms["q" + i].GPA); + + } + + } function responseCallbackPartial(response) { @@ -791,7 +791,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") { @@ -809,7 +809,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] + "
" + times[i] : "Extra"; tableData.schedule.black[i].class = tableData.schedule.black[i].name + "
" + tableData.schedule.black[i].teacher; From 4a6a60908b6f0b43c82f1f1008b6aa7ef3c7799b Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:46:16 -0500 Subject: [PATCH 09/33] Normalize whitespace and comment out `console.log`s --- public/home.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/public/home.js b/public/home.js index a83cd7a9..18435e4c 100755 --- a/public/home.js +++ b/public/home.js @@ -645,20 +645,19 @@ let termsReset = {}; fiveSum += 1; } } - console.log(fiveSum + "" + overviewClass.class); + // console.log(fiveSum + "" + overviewClass.class); } - console.log(fiveSum); - console.log(count); - tableData.terms["q" + i].GPA = Math.round(sum / count * 100) / 100; - tableData.terms["q" + i].outOfFourGPA = fourSum / count; - tableData.terms["q" + i].outOfFiveGPA = fiveSum / count; + // console.log(fiveSum); + // console.log(count); + tableData.terms["q" + i].GPA = Math.round(sum / count * 100) / 100; + tableData.terms["q" + i].outOfFourGPA = fourSum / count; + tableData.terms["q" + i].outOfFiveGPA = fiveSum / count; - if(i == currentQuarterRightNow) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** - tableData.terms.current.outOfFourGPA = fourSum / count; - tableData.terms.current.outOfFiveGPA = fiveSum / count; - - } + if (i == currentQuarterRightNow) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** + tableData.terms.current.outOfFourGPA = fourSum / count; + tableData.terms.current.outOfFiveGPA = fiveSum / count; + } From 869f02995949f1d8ea136dda90e6eac8d9d95978 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 20:17:26 -0500 Subject: [PATCH 10/33] Change GPA to an object + reduce dependence on currentQuarterRightNow The GPA and calcGPA attributes of each term's object under tableData are now themselves objects with attributes "percent", "outOfFour", and "outOfFive". This approach is more scalable and also allows all GPAs to be returned by a single function, computeGPA, which has been modified to compute all three formats of GPA. --- public/home.js | 68 ++++++++++++++++-------------------- public/js/buttonFunctions.js | 52 +++++++++++++-------------- public/js/calculate_grade.js | 37 +++++++++++++++----- public/js/extraFunctions.js | 6 ++-- 4 files changed, 88 insertions(+), 75 deletions(-) diff --git a/public/home.js b/public/home.js index 18435e4c..4985fc93 100755 --- a/public/home.js +++ b/public/home.js @@ -617,7 +617,11 @@ let termsReset = {}; } + // Calculate GPA for current term + tableData.terms.current.GPA = computeGPA(tableData.terms.current.classes); + tableData.overview = response.overview; + // Calculate GPA for each quarter for (let i = 1; i <= 4; i++) { let sum = 0; // Sum of classes' grades let count = 0; // Number of classes @@ -639,29 +643,19 @@ let termsReset = {}; //----WEIGHTED GPA (OUT OF 5.0)------- fiveSum += curG; if (overviewClass.class.includes("HN")) { - fiveSum += .5 + fiveSum += .5; } if (overviewClass.class.includes("AP")) { fiveSum += 1; } } - // console.log(fiveSum + "" + overviewClass.class); } - // console.log(fiveSum); - // console.log(count); - tableData.terms["q" + i].GPA = Math.round(sum / count * 100) / 100; - tableData.terms["q" + i].outOfFourGPA = fourSum / count; - tableData.terms["q" + i].outOfFiveGPA = fiveSum / count; - - - if (i == currentQuarterRightNow) {//***THIS WILL NEED TO BE CHANGED NEXT QUARTER*** - tableData.terms.current.outOfFourGPA = fourSum / count; - tableData.terms.current.outOfFiveGPA = fiveSum / count; - } - - - - + + tableData.terms["q" + i].GPA = { + percent: Math.round(sum / count * 100) / 100, + outOfFour: fourSum / count, + outOfFive: fiveSum / count + }; } //Stuff to do now that tableData is initialized @@ -672,20 +666,20 @@ let termsReset = {}; initialize_quarter_dropdown(); termsReset[currentTerm] = JSON.parse(JSON.stringify(tableData.terms[currentTerm])); - $(".select-selected").html("Current Quarter GPA Percent: " + 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 Percent: " + 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; + $(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"; @@ -723,15 +717,15 @@ let termsReset = {}; } if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("GPA")) { - $(".select-selected").html(quarter +" Unweighted: " + tableData.terms["q" + i].outOfFourGPA); + $(".select-selected").html(quarter +" Unweighted: " + tableData.terms["q" + i].GPA.outOfFour); } else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Unweighted")) { - $(".select-selected").html(quarter +" Weighted: " + tableData.terms["q" + i].outOfFiveGPA); + $(".select-selected").html(quarter +" Weighted: " + tableData.terms["q" + i].GPA.outOfFive); } else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Weighted")) { - $(".select-selected").html(quarter +" GPA: " + tableData.terms["q" + i].GPA); + $(".select-selected").html(quarter +" GPA: " + tableData.terms["q" + i].GPA.percent); } @@ -751,15 +745,15 @@ function responseCallbackPartial(response) { 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; } diff --git a/public/js/buttonFunctions.js b/public/js/buttonFunctions.js index 5bd6902e..96a581d2 100755 --- a/public/js/buttonFunctions.js +++ b/public/js/buttonFunctions.js @@ -61,7 +61,7 @@ let resetTableData = function() { } classesTable.setData(tableData.currentTermData.classes); - tableData.currentTermData.calcGPA = computeGPA(); + tableData.currentTermData.calcGPA = computeGPA(tableData.currentTermData.classes); let GPA = tableData.terms[currentTerm].GPA; let calcGPA = tableData.terms[currentTerm].calcGPA; @@ -70,37 +70,37 @@ let resetTableData = function() { //fix the editing system in the if statement above to be true if any of the classes are edited if (currentTerm == "current") { $(".select-selected").css('padding', "5px 16px 5px 16px"); - $(".select-selected").html("Current Quarter GPA: " + GPA + "
Calculated GPA: " + calcGPA); + $(".select-selected").html("Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); $("#" + currentTerm).css('padding', "5px 16px 5px 16px"); - $("#" + currentTerm).html("Current Quarter GPA: " + GPA + "
Calculated GPA: " + calcGPA); - document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + GPA + "
Calculated GPA: " + calcGPA; - document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + GPA + "
Calculated GPA: " + calcGPA; + $("#" + currentTerm).html("Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); + document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent; + document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent; } else { $(".select-selected").css('padding', "5px 16px 5px 16px"); - $(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA + "
Calculated GPA: " + calcGPA); + $(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); $("#" + currentTerm).css('padding', "5px 16px 5px 16px"); - $("#" + currentTerm).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA + "
Calculated GPA: " + calcGPA); - document.getElementById('gpa_select').options[termConverter.indexOf(currentTerm) + 1].innerHTML = "Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA + "
Calculated GPA: " + calcGPA; + $("#" + currentTerm).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); + document.getElementById('gpa_select').options[termConverter.indexOf(currentTerm) + 1].innerHTML = "Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent; } } else { if (currentTerm == "current") { $(".select-selected").css("padding", "13px 16px 13px 16px"); - $(".select-selected").html("Current Quarter GPA: " + GPA); + $(".select-selected").html("Current Quarter GPA: " + GPA.percent); $("#" + currentTerm).css("padding", "13px 16px 13px 16px"); - $("#" + currentTerm).html("Current Quarter GPA: " + GPA); - document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + GPA; - document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + GPA; + $("#" + currentTerm).html("Current Quarter GPA: " + GPA.percent); + document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + GPA.percent; + document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + GPA.percent; } else { $(".select-selected").css("padding", "13px 16px 13px 16px"); - $(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA); + $(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent); $("#" + currentTerm).css("padding", "13px 16px 13px 16px"); - $("#" + currentTerm).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA); - document.getElementById('gpa_select').options[termConverter.indexOf(currentTerm) + 1].innerHTML = "Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA; + $("#" + currentTerm).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent); + document.getElementById('gpa_select').options[termConverter.indexOf(currentTerm) + 1].innerHTML = "Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent; } } $("#assignmentsTable").hide(); //;.setData(tableData[i].assignments); @@ -125,8 +125,8 @@ let updateGradePage = function() { assignmentsTable.replaceData(tableData.currentTermData.classes[selected_class_i].assignments); - tableData.currentTermData.calcGPA = computeGPA(); - tableData.terms[currentTerm].calcGPA = computeGPA(); + tableData.currentTermData.calcGPA = computeGPA(tableData.currentTermData.classes); + tableData.terms[currentTerm].calcGPA = computeGPA(tableData.currentTermData.classes); let GPA = tableData.terms[currentTerm].GPA; let calcGPA = tableData.terms[currentTerm].calcGPA; @@ -135,19 +135,19 @@ let updateGradePage = function() { //fix the editing system in the if statement above to be true if any of the classes are edited if (currentTerm == "current") { $(".select-selected").css('padding', "5px 16px 5px 16px"); - $(".select-selected").html("Current Quarter GPA: " + GPA + "
Calculated GPA: " + calcGPA); + $(".select-selected").html("Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); $("#" + currentTerm).css('padding', "5px 16px 5px 16px"); - $("#" + currentTerm).html("Current Quarter GPA: " + GPA + "
Calculated GPA: " + calcGPA); - document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + GPA + "
Calculated GPA: " + calcGPA; - document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + GPA + "
Calculated GPA: " + calcGPA; + $("#" + currentTerm).html("Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); + document.getElementById('gpa_select').options[0].innerHTML = "Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent; + document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent; } else { $(".select-selected").css('padding', "5px 16px 5px 16px"); - $(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA + "
Calculated GPA: " + calcGPA); + $(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); $("#" + currentTerm).css('padding', "5px 16px 5px 16px"); - $("#" + currentTerm).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA + "
Calculated GPA: " + calcGPA); - document.getElementById('gpa_select').options[termConverter.indexOf(currentTerm) + 1].innerHTML = "Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA + "
Calculated GPA: " + calcGPA; + $("#" + currentTerm).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); + document.getElementById('gpa_select').options[termConverter.indexOf(currentTerm) + 1].innerHTML = "Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent; } //document.getElementById("GPA").style.padding = "3.5px 16px 3.5px 16px"; @@ -157,7 +157,7 @@ let updateGradePage = function() { $(".select-selected").css("padding", "13px 16px 13px 16px"); $("#" + currentTerm).css("padding", "13px 16px 13px 16px"); - $(".select-selected").html("Quarter GPA: " + GPA); - $("#" + currentTerm).html("Quarter GPA: " + GPA); + $(".select-selected").html("Quarter GPA: " + GPA.percent); + $("#" + currentTerm).html("Quarter GPA: " + GPA.percent); } } diff --git a/public/js/calculate_grade.js b/public/js/calculate_grade.js index 479bc523..1703d977 100755 --- a/public/js/calculate_grade.js +++ b/public/js/calculate_grade.js @@ -174,20 +174,39 @@ function getRGB(gradeToBeColored) { } } -function computeGPA() { - let sum = 0; - let counter = 0.0; - for (let i = 0; i < tableData.currentTermData.classes.length; i++) { - if (!isNaN(parseFloat(tableData.currentTermData.classes[i].calculated_grade))) { - if (parseFloat(tableData.currentTermData.classes[i].calculated_grade) > 100) { +function computeGPA(classes) { + let sum = 0; // Sum of classes' grades + let count = 0; // Number of classes + let fourSum = 0; // Sum of classes' grades on 4.0 scale + let fiveSum = 0; // Sum of classes' grades on 5.0 scale + for (let classInfo of classes) { + if (!isNaN(parseFloat(classInfo.calculated_grade))) { + if (parseFloat(classInfo.calculated_grade) > 100) { sum += 100; } else { - sum += parseFloat(tableData.currentTermData.classes[i].calculated_grade); + sum += parseFloat(classInfo.calculated_grade); + } + count++; + + //--------GPA OUT OF 4.0 + let curG = getGPA(classInfo.calculated_grade); + fourSum += curG; + + //----WEIGHTED GPA (OUT OF 5.0)------- + fiveSum += curG; + if (classInfo.name.includes("HN")) { + fiveSum += .5; + } + if (classInfo.name.includes("AP")) { + fiveSum += 1; } - counter += 1.0; } } - return Math.round(sum / counter * 100) / 100; + return { + percent: Math.round(sum / count * 100) / 100, + outOfFour: fourSum / count, + outOfFive: fiveSum / count + }; } function doCalculations(assignments, categories) { diff --git a/public/js/extraFunctions.js b/public/js/extraFunctions.js index 60a1b602..f22e5f63 100755 --- a/public/js/extraFunctions.js +++ b/public/js/extraFunctions.js @@ -591,7 +591,7 @@ let initialize_quarter_dropdown = function() { c = document.createElement("DIV"); c.innerHTML = selElmnt.options[j].innerHTML; c.id = termConverter[j - 1]; - // if (!isNaN(tableData.terms[termConverter[j - 1]].GPA)) { + // if (!isNaN(tableData.terms[termConverter[j - 1]].GPA.percent)) { c.addEventListener("click", function(e) { if (!this.innerHTML.includes("None")) { /* When an item is clicked, update the original select box, @@ -824,8 +824,8 @@ function parseTableData(classes) { } } tableData.currentTermData.classes = classes; - let GPA = computeGPA(); - let calcGPA = computeGPA(); + let GPA = computeGPA(tableData.currentTermData.classes); + let calcGPA = computeGPA(tableData.currentTermData.classes); return { classes, GPA, From df7578ae89ab1bd55917141babf1fdd6b368e76a Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:01:32 -0500 Subject: [PATCH 11/33] Refactor GPAType so that currentQuarterRightNow is not needed The current quarter need not be hardcoded anymore. Also, the refactored GPAType uses jQuery and is more readable. --- public/home.js | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/public/home.js b/public/home.js index 4985fc93..00b7b3fb 100755 --- a/public/home.js +++ b/public/home.js @@ -1,5 +1,4 @@ ////////////////////Global Variables/////// -let currentQuarterRightNow = 2; //REMOVE THIS!!!!!!!!! let pdf_index = 0; let termConverter = ['current', 'q1', 'q2', 'q3', 'q4']; let pdfrendering = false; @@ -703,32 +702,31 @@ let termsReset = {}; function GPAType() { - var e = document.getElementById("gpa_select"); - var i = e.options[e.selectedIndex].value; - - - var quarter = i; - if(i == 0) {//NEEDS TO BE CHANGED ON NEXT QUARTER - i = currentQuarterRightNow;//CURRENT QUARTER... WONT BE 2 FOR LONG - quarter = "Current Quarter"; - } - else { - quarter = "Q" + i; - } - - if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("GPA")) { - $(".select-selected").html(quarter +" Unweighted: " + tableData.terms["q" + i].GPA.outOfFour); - } - else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Unweighted")) { - $(".select-selected").html(quarter +" Weighted: " + tableData.terms["q" + i].GPA.outOfFive); - - } - - else if(document.getElementsByClassName('select-selected')[0].innerHTML.includes("Weighted")) { - $(".select-selected").html(quarter +" GPA: " + tableData.terms["q" + i].GPA.percent); - - } + let selectElem = $("#gpa_select"); + let selectedElem = $(".select-selected"); + let selection = $("#gpa_select option")[selectElem.prop("selectedIndex")].value; + + let quarterName = ""; + let quarterData; + if (selection === 0) { + quarterName = "Current Quarter"; + quarterData = tableData.terms.current; + } + else { + quarterName = "Q" + selection; + quarterData = tableData.terms["q" + selection]; + } + + if (selectedElem.html().includes("GPA")) { + selectedElem.html(quarterName + " Unweighted: " + quarterData.GPA.outOfFour); + } + else if (selectedElem.html().includes("Unweighted")) { + selectedElem.html(quarterName + " Weighted: " + quarterData.GPA.outOfFive); + } + else if (selectedElem.html().includes("Weighted")) { + selectedElem.html(quarterName + " GPA: " + quarterData.GPA.percent); + } } function responseCallbackPartial(response) { From e20eb4c1816fb098c67a152c032bd2d8d5bd7b40 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:03:06 -0500 Subject: [PATCH 12/33] Round 4.0 and 5.0 scale GPAs to 2 places after decimal point --- public/home.js | 4 ++-- public/js/calculate_grade.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/home.js b/public/home.js index 00b7b3fb..cadd73e4 100755 --- a/public/home.js +++ b/public/home.js @@ -652,8 +652,8 @@ let termsReset = {}; tableData.terms["q" + i].GPA = { percent: Math.round(sum / count * 100) / 100, - outOfFour: fourSum / count, - outOfFive: fiveSum / count + outOfFour: Math.round(fourSum / count * 100) / 100, + outOfFive: Math.round(fiveSum / count * 100) / 100 }; } diff --git a/public/js/calculate_grade.js b/public/js/calculate_grade.js index 1703d977..0b8e88af 100755 --- a/public/js/calculate_grade.js +++ b/public/js/calculate_grade.js @@ -204,8 +204,8 @@ function computeGPA(classes) { } return { percent: Math.round(sum / count * 100) / 100, - outOfFour: fourSum / count, - outOfFive: fiveSum / count + outOfFour: Math.round(fourSum / count * 100) / 100, + outOfFive: Math.round(fiveSum / count * 100) / 100 }; } From cbd9eb2077a068536dee212b6e22f89643f23439 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:08:10 -0500 Subject: [PATCH 13/33] Fix bug in which GPA switcher does not work Because the selection of the @@ -99,6 +100,8 @@

+ +

diff --git a/public/home.js b/public/home.js index 32b84831..b1446528 100755 --- a/public/home.js +++ b/public/home.js @@ -620,15 +620,20 @@ let termsReset = {}; tableData.terms.current.GPA = computeGPA(tableData.terms.current.classes); tableData.overview = response.overview; + +document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

Percent: " + cumGPA(1) + "

Unweighted: " + cumGPA(2) + "

Weighted: " + cumGPA(3) +"

";//SET CUM GPA FIELD TO PERCENT + // Calculate GPA for each quarter for (let i = 1; i <= 4; i++) { - let sum = 0; // Sum of classes' grades + + + /* let sum = 0; // Sum of classes' grades let count = 0; // Number of classes let fourSum = 0; // Sum of classes' grades on 4.0 scale let fiveSum = 0; // Sum of classes' grades on 5.0 scale - for (let overviewClass of tableData.overview) { + for (let overviewClass of tableData.overview) { if (overviewClass["q" + i]) { - if (parseFloat(overviewClass["q" + i]) > 100) { + if (parseFloat(overviewClass["q" + i]) > 100) { sum += 100; } else { sum += parseFloat(overviewClass["q" + i]); @@ -648,12 +653,17 @@ let termsReset = {}; fiveSum += 1; } } - } - + }*/ + + let GPAS = computeGPAQuarter(tableData.overview,i); + // let GPAs = computeGPA(tableData.overview); + //console.log(GPAs); + + tableData.terms["q" + i].GPA = { - percent: Math.round(sum / count * 100) / 100, - outOfFour: Math.round(fourSum / count * 100) / 100, - outOfFive: Math.round(fiveSum / count * 100) / 100 + percent: GPAS.percent, + outOfFour: GPAS.outOfFour, + outOfFive: GPAS.outOfFive }; } @@ -671,7 +681,8 @@ let termsReset = {}; document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + tableData.currentTermData.GPA.percent; $(".select-items").children().each(function(i, elem) { - if (i == 0) { + 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; @@ -684,6 +695,7 @@ let termsReset = {}; document.getElementById('gpa_select').options[i + 1].innerHTML ="Q" + i + " GPA: None"; } } + } }); // scheduleTable.setData(tableData.schedule.black); recentActivity.setData(tableData.recent.recentActivityArray); @@ -701,6 +713,40 @@ let termsReset = {}; } + function cumGPA(type) { + let sumGPA = 0; + let sumOutOfFour = 0; + let sumOutOfFive = 0; + + let count = 0; + for(var i = 1; i <= 4; i ++) { + + if (!isNaN(computeGPAQuarter(tableData.overview,i).percent)) { + sumGPA += computeGPAQuarter(tableData.overview,i).percent; + sumOutOfFour += computeGPAQuarter(tableData.overview,i).outOfFour; + sumOutOfFive += computeGPAQuarter(tableData.overview,i).outOfFive; + + count ++; + } + + } + if(type == 1) { + return sumGPA/count; + } + if(type == 2) { + return sumOutOfFour/count; + + } + if(type == 3) { + return sumOutOfFive/count; + + } + } + + + + + function GPAType() { let selectElem = $("#gpa_select"); let selectedElem = $(".select-selected"); @@ -719,35 +765,61 @@ let termsReset = {}; } if (selectedElem.html().includes("GPA")) { - selectedElem.html(quarterName + " Unweighted: " + quarterData.GPA.outOfFour); + + if (quarterData.GPA.outOfFour != quarterData.calcGPA.outOfFour) { + + selectedElem.html(quarterName + " Unweighted: " + quarterData.GPA.outOfFour + "\n Calculated: " +quarterData.calcGPA.outOfFour); + + } + + else { + selectedElem.html(quarterName + " Unweighted: " + quarterData.GPA.outOfFour); + + } + + } else if (selectedElem.html().includes("Unweighted")) { - selectedElem.html(quarterName + " Weighted: " + quarterData.GPA.outOfFive); + + if (quarterData.GPA.outOfFive != quarterData.calcGPA.outOfFive) { + + selectedElem.html(quarterName + " Weighted: " + quarterData.GPA.outOfFive + "\n Calculated: " + quarterData.calcGPA.outOfFive); + } + else { + selectedElem.html(quarterName + " Weighted: " + quarterData.GPA.outOfFive); + + } + } else if (selectedElem.html().includes("Weighted")) { - selectedElem.html(quarterName + " GPA: " + quarterData.GPA.percent); + + if (quarterData.GPA.percent != quarterData.calcGPA.percent) { + selectedElem.html(quarterName + " GPA: " + quarterData.GPA.percent + "\n Calculated: " + quarterData.calcGPA.percent); + } + else { + selectedElem.html(quarterName + " GPA: " + quarterData.GPA.percent); + } + } } function responseCallbackPartial(response) { - $("#loader").hide(); tableData.currentTermData = parseTableData(response.classes); let temp_term_data = parseTableData(response.classes); tableData.terms[currentTerm].classes = temp_term_data.classes; - tableData.terms[currentTerm].GPA = temp_term_data.calcGPA; - tableData.terms[currentTerm].calcGPA = parseTableData(response.classes).calcGPA; - - + tableData.terms[currentTerm].GPA = temp_term_data.calcGPA; + tableData.terms[currentTerm].calcGPA = parseTableData(response.classes).calcGPA; + if (currentTerm == 'current') { $(".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.percent); $("#q" + termConverter.indexOf(currentTerm)).html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + tableData.currentTermData.GPA.percent); diff --git a/public/js/buttonFunctions.js b/public/js/buttonFunctions.js index 96a581d2..07633034 100755 --- a/public/js/buttonFunctions.js +++ b/public/js/buttonFunctions.js @@ -62,7 +62,6 @@ let resetTableData = function() { classesTable.setData(tableData.currentTermData.classes); tableData.currentTermData.calcGPA = computeGPA(tableData.currentTermData.classes); - let GPA = tableData.terms[currentTerm].GPA; let calcGPA = tableData.terms[currentTerm].calcGPA; @@ -77,6 +76,11 @@ let resetTableData = function() { document.getElementById('gpa_select').options[1].innerHTML = "Current Quarter GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent; } else { + tableData.currentTermData.calcGPA = computeGPA(tableData.currentTermData.classes,termConverter.indexOf(currentTerm)); + + + + $(".select-selected").css('padding', "5px 16px 5px 16px"); $(".select-selected").html("Q" + termConverter.indexOf(currentTerm) + " GPA: " + GPA.percent + "
Calculated GPA: " + calcGPA.percent); diff --git a/public/js/calculate_grade.js b/public/js/calculate_grade.js index 0b8e88af..53faf51d 100755 --- a/public/js/calculate_grade.js +++ b/public/js/calculate_grade.js @@ -209,6 +209,46 @@ function computeGPA(classes) { }; } + +function computeGPAQuarter(classes, i) { + + let sum = 0; // Sum of classes' grades + let count = 0; // Number of classes + let fourSum = 0; // Sum of classes' grades on 4.0 scale + let fiveSum = 0; // Sum of classes' grades on 5.0 scale + for (let overviewClass of tableData.overview) { + if (overviewClass["q" + i]) { + if (parseFloat(overviewClass["q" + i]) > 100) { + sum += 100; + } else { + sum += parseFloat(overviewClass["q" + i]); + } + count++; + + //--------GPA OUT OF 4.0 + let curG = getGPA(overviewClass["q" + i]); + fourSum += curG; + + //----WEIGHTED GPA (OUT OF 5.0)------- + fiveSum += curG; + if (overviewClass.class.includes("HN")) { + fiveSum += .5; + } + if (overviewClass.class.includes("AP")) { + fiveSum += 1; + } + } + } + + return { + percent: Math.round(sum / count * 100) / 100, + outOfFour: Math.round(fourSum / count * 100) / 100, + outOfFive: Math.round(fiveSum / count * 100) / 100 + }; + +} + + function doCalculations(assignments, categories) { let categoryScores = {}, categoryMaxScores = {}, categoryGrades = {}; From 5a79cb1f722c062435ab1ed8bc6da935f86e7b07 Mon Sep 17 00:00:00 2001 From: kdk1616 <31357347+kdk1616@users.noreply.github.com> Date: Sat, 15 Feb 2020 14:41:44 -0500 Subject: [PATCH 15/33] Made login button autofocus, made cum GPA limited to two decimals --- public/home.js | 6 +++--- public/login.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/home.js b/public/home.js index b1446528..b217163a 100755 --- a/public/home.js +++ b/public/home.js @@ -731,14 +731,14 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P } if(type == 1) { - return sumGPA/count; + return (sumGPA/count).toFixed(2); } if(type == 2) { - return sumOutOfFour/count; + return (sumOutOfFour/count).toFixed(2); } if(type == 3) { - return sumOutOfFive/count; + return (sumOutOfFive/count).toFixed(2); } } diff --git a/public/login.html b/public/login.html index a5666a64..cc1c0abf 100755 --- a/public/login.html +++ b/public/login.html @@ -90,7 +90,7 @@

- From 100dc9b02b20762649b53c52a7fd78d8f28611b3 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Wed, 19 Feb 2020 15:21:38 -0500 Subject: [PATCH 16/33] Make computeGPAQuarter function stateless computeGPAQuarter was using a global variable instead of using its own argument; this has now been changed. --- public/home.js | 41 +----------------------------------- public/js/calculate_grade.js | 4 ++-- 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/public/home.js b/public/home.js index b217163a..830a340a 100755 --- a/public/home.js +++ b/public/home.js @@ -625,46 +625,7 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P // Calculate GPA for each quarter for (let i = 1; i <= 4; i++) { - - - /* let sum = 0; // Sum of classes' grades - let count = 0; // Number of classes - let fourSum = 0; // Sum of classes' grades on 4.0 scale - let fiveSum = 0; // Sum of classes' grades on 5.0 scale - for (let overviewClass of tableData.overview) { - if (overviewClass["q" + i]) { - if (parseFloat(overviewClass["q" + i]) > 100) { - sum += 100; - } else { - sum += parseFloat(overviewClass["q" + i]); - } - count++; - - //--------GPA OUT OF 4.0 - let curG = getGPA(overviewClass["q" + i]); - fourSum += curG; - - //----WEIGHTED GPA (OUT OF 5.0)------- - fiveSum += curG; - if (overviewClass.class.includes("HN")) { - fiveSum += .5; - } - if (overviewClass.class.includes("AP")) { - fiveSum += 1; - } - } - }*/ - - let GPAS = computeGPAQuarter(tableData.overview,i); - // let GPAs = computeGPA(tableData.overview); - //console.log(GPAs); - - - tableData.terms["q" + i].GPA = { - percent: GPAS.percent, - outOfFour: GPAS.outOfFour, - outOfFive: GPAS.outOfFive - }; + tableData.terms["q" + i].GPA = computeGPAQuarter(tableData.overview,i); } //Stuff to do now that tableData is initialized diff --git a/public/js/calculate_grade.js b/public/js/calculate_grade.js index 53faf51d..4b17f3c1 100755 --- a/public/js/calculate_grade.js +++ b/public/js/calculate_grade.js @@ -210,13 +210,13 @@ function computeGPA(classes) { } -function computeGPAQuarter(classes, i) { +function computeGPAQuarter(overview, i) { let sum = 0; // Sum of classes' grades let count = 0; // Number of classes let fourSum = 0; // Sum of classes' grades on 4.0 scale let fiveSum = 0; // Sum of classes' grades on 5.0 scale - for (let overviewClass of tableData.overview) { + for (let overviewClass of overview) { if (overviewClass["q" + i]) { if (parseFloat(overviewClass["q" + i]) > 100) { sum += 100; From 0093daee57154d025eaf591602c8bddf6557c4d0 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Wed, 19 Feb 2020 15:24:37 -0500 Subject: [PATCH 17/33] Remove useless variable curQ --- public/home.js | 1 - 1 file changed, 1 deletion(-) diff --git a/public/home.js b/public/home.js index 830a340a..5517a9a3 100755 --- a/public/home.js +++ b/public/home.js @@ -2,7 +2,6 @@ let pdf_index = 0; let termConverter = ['current', 'q1', 'q2', 'q3', 'q4']; let pdfrendering = false; -let curQ = 0; let statsModal = document.getElementById('stats_modal'); let term_dropdown_active = true; let currentTerm = "current"; From 3170569ef4e09949e38e1ac902d3c428e0b2c220 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Wed, 19 Feb 2020 15:33:20 -0500 Subject: [PATCH 18/33] Normalize indentation and whitespace in GPAType() --- public/home.js | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/public/home.js b/public/home.js index 5517a9a3..f92f800f 100755 --- a/public/home.js +++ b/public/home.js @@ -723,43 +723,45 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P quarterName = "Q" + selection; quarterData = tableData.terms["q" + selection]; } - + if (selectedElem.html().includes("GPA")) { - if (quarterData.GPA.outOfFour != quarterData.calcGPA.outOfFour) { - - selectedElem.html(quarterName + " Unweighted: " + quarterData.GPA.outOfFour + "\n Calculated: " +quarterData.calcGPA.outOfFour); - - } - - else { - selectedElem.html(quarterName + " Unweighted: " + quarterData.GPA.outOfFour); - - } - - + selectedElem.html( + quarterName + " Unweighted: " + quarterData.GPA.outOfFour + + "\n Calculated: " +quarterData.calcGPA.outOfFour + ); + } + else { + selectedElem.html( + quarterName + " Unweighted: " + quarterData.GPA.outOfFour + ); + } } else if (selectedElem.html().includes("Unweighted")) { - if (quarterData.GPA.outOfFive != quarterData.calcGPA.outOfFive) { - - selectedElem.html(quarterName + " Weighted: " + quarterData.GPA.outOfFive + "\n Calculated: " + quarterData.calcGPA.outOfFive); + selectedElem.html( + quarterName + " Weighted: " + quarterData.GPA.outOfFive + + "\n Calculated: " + quarterData.calcGPA.outOfFive + ); } else { - selectedElem.html(quarterName + " Weighted: " + quarterData.GPA.outOfFive); - + selectedElem.html( + quarterName + " Weighted: " + quarterData.GPA.outOfFive + ); } - } else if (selectedElem.html().includes("Weighted")) { - if (quarterData.GPA.percent != quarterData.calcGPA.percent) { - selectedElem.html(quarterName + " GPA: " + quarterData.GPA.percent + "\n Calculated: " + quarterData.calcGPA.percent); + selectedElem.html( + quarterName + " GPA: " + quarterData.GPA.percent + + "\n Calculated: " + quarterData.calcGPA.percent + ); } else { - selectedElem.html(quarterName + " GPA: " + quarterData.GPA.percent); + selectedElem.html( + quarterName + " GPA: " + quarterData.GPA.percent + ); } - } } From 172ccf95f7168e5506320dee26fffa2d2d650f24 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Wed, 19 Feb 2020 16:09:17 -0500 Subject: [PATCH 19/33] Add cumGPA to tableData --- public/home.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/home.js b/public/home.js index f92f800f..9db71326 100755 --- a/public/home.js +++ b/public/home.js @@ -620,7 +620,12 @@ let termsReset = {}; tableData.overview = response.overview; -document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

Percent: " + cumGPA(1) + "

Unweighted: " + cumGPA(2) + "

Weighted: " + cumGPA(3) +"

";//SET CUM GPA FIELD TO PERCENT + tableData.cumGPA = { + percent: cumGPA(1), + outOfFour: cumGPA(2), + outOfFive: cumGPA(3) + }; +document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

Percent: " + tableData.cumGPA.percent + "

Unweighted: " + tableData.cumGPA.outOfFour + "

Weighted: " + tableData.cumGPA.outOfFive +"

";//SET CUM GPA FIELD TO PERCENT // Calculate GPA for each quarter for (let i = 1; i <= 4; i++) { From b80eeccb5f45738ddeaa9682b777f0eee4684e43 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Wed, 19 Feb 2020 16:11:49 -0500 Subject: [PATCH 20/33] Store cumulative GPA as numbers rather than as strings --- public/home.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/home.js b/public/home.js index 9db71326..047d9a1e 100755 --- a/public/home.js +++ b/public/home.js @@ -625,7 +625,7 @@ let termsReset = {}; outOfFour: cumGPA(2), outOfFive: cumGPA(3) }; -document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

Percent: " + tableData.cumGPA.percent + "

Unweighted: " + tableData.cumGPA.outOfFour + "

Weighted: " + tableData.cumGPA.outOfFive +"

";//SET CUM GPA FIELD TO PERCENT +document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

Percent: " + tableData.cumGPA.percent.toFixed(2) + "

Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) + "

Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) +"

";//SET CUM GPA FIELD TO PERCENT // Calculate GPA for each quarter for (let i = 1; i <= 4; i++) { @@ -696,14 +696,14 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P } if(type == 1) { - return (sumGPA/count).toFixed(2); + return sumGPA/count; } if(type == 2) { - return (sumOutOfFour/count).toFixed(2); + return sumOutOfFour/count; } if(type == 3) { - return (sumOutOfFive/count).toFixed(2); + return sumOutOfFive/count; } } From 7f431abaf0e2fe0369316461e40971bf78d932ef Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Wed, 19 Feb 2020 16:15:17 -0500 Subject: [PATCH 21/33] Make cumGPA() return an object directly Instead of taking `type` as a parameter and giving a different value depending on the type, cumGPA() now returns an object containing all GPA types. --- public/home.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/public/home.js b/public/home.js index 047d9a1e..4af4ed73 100755 --- a/public/home.js +++ b/public/home.js @@ -620,11 +620,7 @@ let termsReset = {}; tableData.overview = response.overview; - tableData.cumGPA = { - percent: cumGPA(1), - outOfFour: cumGPA(2), - outOfFive: cumGPA(3) - }; + tableData.cumGPA = cumGPA(); document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

Percent: " + tableData.cumGPA.percent.toFixed(2) + "

Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) + "

Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) +"

";//SET CUM GPA FIELD TO PERCENT // Calculate GPA for each quarter @@ -678,7 +674,7 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P } - function cumGPA(type) { + function cumGPA() { let sumGPA = 0; let sumOutOfFour = 0; let sumOutOfFive = 0; @@ -695,17 +691,11 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P } } - if(type == 1) { - return sumGPA/count; - } - if(type == 2) { - return sumOutOfFour/count; - - } - if(type == 3) { - return sumOutOfFive/count; - - } + return { + percent: sumGPA/count, + outOfFour: sumOutOfFour/count, + outOfFive: sumOutOfFive/count + }; } From 8ce0dc14622518fa0a25f68bcb70c31ea73bbd39 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Wed, 19 Feb 2020 16:55:13 -0500 Subject: [PATCH 22/33] Make "GPA Type" button control all terms The "GPA Type" button now controls the GPA type of all terms in the dropdown instead of only the selected one, and the term can be changed while a non-percent GPA type is selected. --- public/home.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/public/home.js b/public/home.js index 4af4ed73..4ac9b075 100755 --- a/public/home.js +++ b/public/home.js @@ -721,12 +721,30 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P if (selectedElem.html().includes("GPA")) { if (quarterData.GPA.outOfFour != quarterData.calcGPA.outOfFour) { + $("#current, #current_gpa, #init_gpa").html( + "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour + + "\n Calculated: " + tableData.terms.current.calcGPA.outOfFour + ); + for (i = 1; i <= 4; i++) { + $(`#q${i}, #q${i}_gpa`).html( + "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour + + "\n Calculated: " + tableData.terms["q" + i].calcGPA.outOfFour + ); + } selectedElem.html( quarterName + " Unweighted: " + quarterData.GPA.outOfFour + "\n Calculated: " +quarterData.calcGPA.outOfFour ); } else { + $("#current, #current_gpa, #init_gpa").html( + "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour + ); + for (i = 1; i <= 4; i++) { + $(`#q${i}, #q${i}_gpa`).html( + "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour + ); + } selectedElem.html( quarterName + " Unweighted: " + quarterData.GPA.outOfFour ); @@ -734,12 +752,30 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P } else if (selectedElem.html().includes("Unweighted")) { if (quarterData.GPA.outOfFive != quarterData.calcGPA.outOfFive) { + $("#current, #current_gpa, #init_gpa").html( + "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive + + "\n Calculated: " + tableData.terms.current.calcGPA.outOfFive + ); + for (i = 1; i <= 4; i++) { + $(`#q${i}, #q${i}_gpa`).html( + "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive + + "\n Calculated: " + tableData.terms["q" + i].calcGPA.outOfFive + ); + } selectedElem.html( quarterName + " Weighted: " + quarterData.GPA.outOfFive + "\n Calculated: " + quarterData.calcGPA.outOfFive ); } else { + $("#current, #current_gpa, #init_gpa").html( + "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive + ); + for (i = 1; i <= 4; i++) { + $(`#q${i}, #q${i}_gpa`).html( + "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive + ); + } selectedElem.html( quarterName + " Weighted: " + quarterData.GPA.outOfFive ); @@ -747,12 +783,30 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P } else if (selectedElem.html().includes("Weighted")) { if (quarterData.GPA.percent != quarterData.calcGPA.percent) { + $("#current, #current_gpa, #init_gpa").html( + "Current Quarter GPA: " + tableData.terms.current.GPA.percent + + "\n Calculated: " + tableData.terms.current.calcGPA.percent + ); + for (i = 1; i <= 4; i++) { + $(`#q${i}, #q${i}_gpa`).html( + "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent + + "\n Calculated: " + tableData.terms["q" + i].calcGPA.percent + ); + } selectedElem.html( quarterName + " GPA: " + quarterData.GPA.percent + "\n Calculated: " + quarterData.calcGPA.percent ); } else { + $("#current, #current_gpa, #init_gpa").html( + "Current Quarter GPA: " + tableData.terms.current.GPA.percent + ); + for (i = 1; i <= 4; i++) { + $(`#q${i}, #q${i}_gpa`).html( + "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent + ); + } selectedElem.html( quarterName + " GPA: " + quarterData.GPA.percent ); @@ -771,6 +825,7 @@ function responseCallbackPartial(response) { tableData.terms[currentTerm].calcGPA = parseTableData(response.classes).calcGPA; + /* if (currentTerm == 'current') { $(".select-selected").html("Current Quarter GPA: " + tableData.currentTermData.GPA.percent); $("#current").html("Current Quarter GPA: " + tableData.currentTermData.GPA.percent); @@ -782,6 +837,7 @@ function responseCallbackPartial(response) { $("#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); From e00e504a97504ea2404d92aaf3f8b2c648dea667 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 16 Mar 2020 17:07:34 -0400 Subject: [PATCH 23/33] Remove word "Percent" to be consistent --- public/home.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/home.js b/public/home.js index 4ac9b075..ecdda058 100755 --- a/public/home.js +++ b/public/home.js @@ -636,7 +636,7 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P initialize_quarter_dropdown(); termsReset[currentTerm] = JSON.parse(JSON.stringify(tableData.terms[currentTerm])); - $(".select-selected").html("Current Quarter GPA Percent: " + tableData.currentTermData.GPA.percent); + $(".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; From 8006c446f4a1e51682f6eb14c6817ee613ec4633 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 16 Mar 2020 17:19:21 -0400 Subject: [PATCH 24/33] Move "GPA Type" button out of dropdown This makes the UI work more intuitively and allows the term dropdown to resize horizontally as needed. --- public/css/stylesheet.css | 2 +- public/home.html | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/css/stylesheet.css b/public/css/stylesheet.css index 1a6d8ffe..7d881b7a 100755 --- a/public/css/stylesheet.css +++ b/public/css/stylesheet.css @@ -195,7 +195,7 @@ button { } -.tab button#logout { +.tab .tablinks-right { float: right; } diff --git a/public/home.html b/public/home.html index 3147a557..b54456c3 100755 --- a/public/home.html +++ b/public/home.html @@ -90,20 +90,20 @@

- +
- - - - +
+ +

From f3ed54dfc7cf287c54d181f590806e57d7387f7f Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 16 Mar 2020 18:33:07 -0400 Subject: [PATCH 25/33] Fix bug relating to fetching terms Fix a bug in which fetching a new term would overwrite the current term data --- public/home.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/home.js b/public/home.js index ecdda058..5586da5a 100755 --- a/public/home.js +++ b/public/home.js @@ -816,13 +816,13 @@ document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

P function responseCallbackPartial(response) { $("#loader").hide(); - - tableData.currentTermData = 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.calcGPA; - tableData.terms[currentTerm].calcGPA = parseTableData(response.classes).calcGPA; + tableData.terms[currentTerm].GPA = temp_term_data.GPA; + tableData.terms[currentTerm].calcGPA = temp_term_data.calcGPA; /* From dc3ddc33be4eea168a03a6848181518532a8750a Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 16 Mar 2020 19:46:57 -0400 Subject: [PATCH 26/33] Make calculated GPA play nicely with unweighted/weighted Fix some bugs that would be encountered if a user modifies some assignments, thus generating a calculated GPA, in any one of the non-percent GPA types. --- public/home.html | 2 +- public/home.js | 12 +++- public/js/buttonFunctions.js | 132 ++++++++++++++++++++++++++++++----- 3 files changed, 125 insertions(+), 21 deletions(-) diff --git a/public/home.html b/public/home.html index b54456c3..d06d86cc 100755 --- a/public/home.html +++ b/public/home.html @@ -94,7 +94,7 @@

diff --git a/public/home.js b/public/home.js index d95bd988..3f6f599e 100755 --- a/public/home.js +++ b/public/home.js @@ -621,7 +621,7 @@ let termsReset = {}; tableData.overview = response.overview; tableData.cumGPA = cumGPA(); -document.getElementById("cumGPA").innerHTML = "

Cumulative GPA:

" + "

Percent: " + tableData.cumGPA.percent.toFixed(2) + "

Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) + "

Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) +"

";//SET CUM GPA FIELD TO PERCENT + document.getElementById("cum_gpa").innerHTML = "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2); // Calculate GPA for each quarter for (let i = 1; i <= 4; i++) { diff --git a/public/js/buttonFunctions.js b/public/js/buttonFunctions.js index c38229c5..f59b1020 100755 --- a/public/js/buttonFunctions.js +++ b/public/js/buttonFunctions.js @@ -170,6 +170,9 @@ let updateGradePage = function() { quarterName + " GPA: " + quarterData.GPA.percent + "
Calculated: " + quarterData.calcGPA.percent ); + $("#cum, #cum_gpa").html( + "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2) + ); } else { $("#current, #current_gpa, #init_gpa").html( @@ -183,6 +186,9 @@ let updateGradePage = function() { selectedElem.html( quarterName + " GPA: " + quarterData.GPA.percent ); + $("#cum, #cum_gpa").html( + "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2) + ); } } else if (selectedElem.html().includes("Unweighted")) { @@ -203,6 +209,9 @@ let updateGradePage = function() { quarterName + " Unweighted: " + quarterData.GPA.outOfFour + "
Calculated: " + quarterData.calcGPA.outOfFour ); + $("#cum, #cum_gpa").html( + "Cumulative Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) + ); } else { $("#current, #current_gpa, #init_gpa").html( @@ -216,6 +225,9 @@ let updateGradePage = function() { selectedElem.html( quarterName + " Unweighted: " + quarterData.GPA.outOfFour ); + $("#cum, #cum_gpa").html( + "Cumulative Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) + ); } } else if (selectedElem.html().includes("Weighted")) { @@ -236,6 +248,9 @@ let updateGradePage = function() { quarterName + " Weighted: " + quarterData.GPA.outOfFive + "
Calculated: " + quarterData.calcGPA.outOfFive ); + $("#cum, #cum_gpa").html( + "Cumulative Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) + ); } else { $("#current, #current_gpa, #init_gpa").html( @@ -249,6 +264,9 @@ let updateGradePage = function() { selectedElem.html( quarterName + " Weighted: " + quarterData.GPA.outOfFive ); + $("#cum, #cum_gpa").html( + "Cumulative Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) + ); } } diff --git a/public/js/extraFunctions.js b/public/js/extraFunctions.js index 8ec85362..0efb99da 100755 --- a/public/js/extraFunctions.js +++ b/public/js/extraFunctions.js @@ -99,6 +99,9 @@ function GPAType() { quarterName + " Unweighted: " + quarterData.GPA.outOfFour + "
Calculated: " + quarterData.calcGPA.outOfFour ); + $("#cum, #cum_gpa").html( + "Cumulative Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) + ); } else { $("#current, #current_gpa, #init_gpa").html( @@ -112,6 +115,9 @@ function GPAType() { selectedElem.html( quarterName + " Unweighted: " + quarterData.GPA.outOfFour ); + $("#cum, #cum_gpa").html( + "Cumulative Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) + ); } } else if (selectedElem.html().includes("Unweighted")) { @@ -132,6 +138,9 @@ function GPAType() { quarterName + " Weighted: " + quarterData.GPA.outOfFive + "
Calculated: " + quarterData.calcGPA.outOfFive ); + $("#cum, #cum_gpa").html( + "Cumulative Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) + ); } else { $("#current, #current_gpa, #init_gpa").html( @@ -145,6 +154,9 @@ function GPAType() { selectedElem.html( quarterName + " Weighted: " + quarterData.GPA.outOfFive ); + $("#cum, #cum_gpa").html( + "Cumulative Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) + ); } } else if (selectedElem.html().includes("Weighted")) { @@ -165,6 +177,9 @@ function GPAType() { quarterName + " GPA: " + quarterData.GPA.percent + "
Calculated: " + quarterData.calcGPA.percent ); + $("#cum, #cum_gpa").html( + "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2) + ); } else { $("#current, #current_gpa, #init_gpa").html( @@ -178,6 +193,9 @@ function GPAType() { selectedElem.html( quarterName + " GPA: " + quarterData.GPA.percent ); + $("#cum, #cum_gpa").html( + "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2) + ); } } } @@ -731,7 +749,7 @@ let initialize_quarter_dropdown = function() { create a new DIV that will act as an option item: */ c = document.createElement("DIV"); c.innerHTML = selElmnt.options[j].innerHTML; - c.id = termConverter[j - 1]; + c.id = termConverter[j - 1] || "cum"; // if (!isNaN(tableData.terms[termConverter[j - 1]].GPA.percent)) { c.addEventListener("click", function(e) { if (!this.innerHTML.includes("None")) { From c5194b160f410d856a4d2262e1248e2e6f72e5ce Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 16 Mar 2020 21:26:02 -0400 Subject: [PATCH 31/33] Display GPAs to 2 decimal places and store cumGPA rounded --- public/js/buttonFunctions.js | 54 ++++++++++++++++---------------- public/js/extraFunctions.js | 60 ++++++++++++++++++------------------ 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/public/js/buttonFunctions.js b/public/js/buttonFunctions.js index f59b1020..294e49f5 100755 --- a/public/js/buttonFunctions.js +++ b/public/js/buttonFunctions.js @@ -155,20 +155,20 @@ let updateGradePage = function() { if (selectedElem.html().includes("GPA")) { if (quarterData.GPA.percent != quarterData.calcGPA.percent) { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter GPA: " + tableData.terms.current.GPA.percent + - "
Calculated: " + tableData.terms.current.calcGPA.percent + "Current Quarter GPA: " + tableData.terms.current.GPA.percent.toFixed(2) + + "
Calculated: " + tableData.terms.current.calcGPA.percent.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent + + "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent.toFixed(2) + (tableData.terms["q" + i].calcGPA ? ( - "
Calculated: " + tableData.terms["q" + i].calcGPA.percent + "
Calculated: " + tableData.terms["q" + i].calcGPA.percent.toFixed(2) ) : "") ); } selectedElem.html( - quarterName + " GPA: " + quarterData.GPA.percent + - "
Calculated: " + quarterData.calcGPA.percent + quarterName + " GPA: " + quarterData.GPA.percent.toFixed(2) + + "
Calculated: " + quarterData.calcGPA.percent.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2) @@ -176,15 +176,15 @@ let updateGradePage = function() { } else { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter GPA: " + tableData.terms.current.GPA.percent + "Current Quarter GPA: " + tableData.terms.current.GPA.percent.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent + "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent.toFixed(2) ); } selectedElem.html( - quarterName + " GPA: " + quarterData.GPA.percent + quarterName + " GPA: " + quarterData.GPA.percent.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2) @@ -194,20 +194,20 @@ let updateGradePage = function() { else if (selectedElem.html().includes("Unweighted")) { if (quarterData.GPA.outOfFour != quarterData.calcGPA.outOfFour) { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour + - "
Calculated: " + tableData.terms.current.calcGPA.outOfFour + "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour.toFixed(2) + + "
Calculated: " + tableData.terms.current.calcGPA.outOfFour.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour + + "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour.toFixed(2) + (tableData.terms["q" + i].calcGPA ? ( - "
Calculated: " + tableData.terms["q" + i].calcGPA.outOfFour + "
Calculated: " + tableData.terms["q" + i].calcGPA.outOfFour.toFixed(2) ) : "") ); } selectedElem.html( - quarterName + " Unweighted: " + quarterData.GPA.outOfFour + - "
Calculated: " + quarterData.calcGPA.outOfFour + quarterName + " Unweighted: " + quarterData.GPA.outOfFour.toFixed(2) + + "
Calculated: " + quarterData.calcGPA.outOfFour.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) @@ -215,15 +215,15 @@ let updateGradePage = function() { } else { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour + "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour + "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour.toFixed(2) ); } selectedElem.html( - quarterName + " Unweighted: " + quarterData.GPA.outOfFour + quarterName + " Unweighted: " + quarterData.GPA.outOfFour.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) @@ -233,20 +233,20 @@ let updateGradePage = function() { else if (selectedElem.html().includes("Weighted")) { if (quarterData.GPA.outOfFive != quarterData.calcGPA.outOfFive) { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive + - "
Calculated: " + tableData.terms.current.calcGPA.outOfFive + "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive.toFixed(2) + + "
Calculated: " + tableData.terms.current.calcGPA.outOfFive.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive + + "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive.toFixed(2) + (tableData.terms["q" + i].calcGPA ? ( - "
Calculated: " + tableData.terms["q" + i].calcGPA.outOfFive + "
Calculated: " + tableData.terms["q" + i].calcGPA.outOfFive.toFixed(2) ) : "") ); } selectedElem.html( - quarterName + " Weighted: " + quarterData.GPA.outOfFive + - "
Calculated: " + quarterData.calcGPA.outOfFive + quarterName + " Weighted: " + quarterData.GPA.outOfFive.toFixed(2) + + "
Calculated: " + quarterData.calcGPA.outOfFive.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) @@ -254,15 +254,15 @@ let updateGradePage = function() { } else { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive + "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive + "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive.toFixed(2) ); } selectedElem.html( - quarterName + " Weighted: " + quarterData.GPA.outOfFive + quarterName + " Weighted: " + quarterData.GPA.outOfFive.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) diff --git a/public/js/extraFunctions.js b/public/js/extraFunctions.js index 0efb99da..cc96e808 100755 --- a/public/js/extraFunctions.js +++ b/public/js/extraFunctions.js @@ -59,9 +59,9 @@ function cumGPA() { } return { - percent: sumGPA / count, - outOfFour: sumOutOfFour / count, - outOfFive: sumOutOfFive / count + percent: Math.round(sumGPA / count * 100) / 100, + outOfFour: Math.round(sumOutOfFour / count * 100) / 100, + outOfFive: Math.round(sumOutOfFive / count * 100) / 100 }; } function GPAType() { @@ -84,20 +84,20 @@ function GPAType() { if (selectedElem.html().includes("GPA")) { if (quarterData.GPA.outOfFour != quarterData.calcGPA.outOfFour) { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour + - "
Calculated: " + tableData.terms.current.calcGPA.outOfFour + "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour.toFixed(2) + + "
Calculated: " + tableData.terms.current.calcGPA.outOfFour.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour + + "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour.toFixed(2) + (tableData.terms["q" + i].calcGPA ? ( - "
Calculated: " + tableData.terms["q" + i].calcGPA.outOfFour + "
Calculated: " + tableData.terms["q" + i].calcGPA.outOfFour.toFixed(2) ) : "") ); } selectedElem.html( - quarterName + " Unweighted: " + quarterData.GPA.outOfFour + - "
Calculated: " + quarterData.calcGPA.outOfFour + quarterName + " Unweighted: " + quarterData.GPA.outOfFour.toFixed(2) + + "
Calculated: " + quarterData.calcGPA.outOfFour.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) @@ -105,15 +105,15 @@ function GPAType() { } else { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour + "Current Quarter Unweighted: " + tableData.terms.current.GPA.outOfFour.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour + "Q" + i + " Unweighted: " + tableData.terms["q" + i].GPA.outOfFour.toFixed(2) ); } selectedElem.html( - quarterName + " Unweighted: " + quarterData.GPA.outOfFour + quarterName + " Unweighted: " + quarterData.GPA.outOfFour.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative Unweighted: " + tableData.cumGPA.outOfFour.toFixed(2) @@ -123,20 +123,20 @@ function GPAType() { else if (selectedElem.html().includes("Unweighted")) { if (quarterData.GPA.outOfFive != quarterData.calcGPA.outOfFive) { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive + - "
Calculated: " + tableData.terms.current.calcGPA.outOfFive + "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive.toFixed(2) + + "
Calculated: " + tableData.terms.current.calcGPA.outOfFive.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive + + "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive.toFixed(2) + (tableData.terms["q" + i].calcGPA ? ( - "
Calculated: " + tableData.terms["q" + i].calcGPA.outOfFive + "
Calculated: " + tableData.terms["q" + i].calcGPA.outOfFive.toFixed(2) ) : "") ); } selectedElem.html( - quarterName + " Weighted: " + quarterData.GPA.outOfFive + - "
Calculated: " + quarterData.calcGPA.outOfFive + quarterName + " Weighted: " + quarterData.GPA.outOfFive.toFixed(2) + + "
Calculated: " + quarterData.calcGPA.outOfFive.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) @@ -144,15 +144,15 @@ function GPAType() { } else { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive + "Current Quarter Weighted: " + tableData.terms.current.GPA.outOfFive.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive + "Q" + i + " Weighted: " + tableData.terms["q" + i].GPA.outOfFive.toFixed(2) ); } selectedElem.html( - quarterName + " Weighted: " + quarterData.GPA.outOfFive + quarterName + " Weighted: " + quarterData.GPA.outOfFive.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative Weighted: " + tableData.cumGPA.outOfFive.toFixed(2) @@ -162,20 +162,20 @@ function GPAType() { else if (selectedElem.html().includes("Weighted")) { if (quarterData.GPA.percent != quarterData.calcGPA.percent) { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter GPA: " + tableData.terms.current.GPA.percent + - "
Calculated: " + tableData.terms.current.calcGPA.percent + "Current Quarter GPA: " + tableData.terms.current.GPA.percent.toFixed(2) + + "
Calculated: " + tableData.terms.current.calcGPA.percent.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent + + "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent.toFixed(2) + (tableData.terms["q" + i].calcGPA ? ( - "
Calculated: " + tableData.terms["q" + i].calcGPA.percent + "
Calculated: " + tableData.terms["q" + i].calcGPA.percent.toFixed(2) ) : "") ); } selectedElem.html( - quarterName + " GPA: " + quarterData.GPA.percent + - "
Calculated: " + quarterData.calcGPA.percent + quarterName + " GPA: " + quarterData.GPA.percent.toFixed(2) + + "
Calculated: " + quarterData.calcGPA.percent.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2) @@ -183,15 +183,15 @@ function GPAType() { } else { $("#current, #current_gpa, #init_gpa").html( - "Current Quarter GPA: " + tableData.terms.current.GPA.percent + "Current Quarter GPA: " + tableData.terms.current.GPA.percent.toFixed(2) ); for (i = 1; i <= 4; i++) { $(`#q${i}, #q${i}_gpa`).html( - "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent + "Q" + i + " GPA: " + tableData.terms["q" + i].GPA.percent.toFixed(2) ); } selectedElem.html( - quarterName + " GPA: " + quarterData.GPA.percent + quarterName + " GPA: " + quarterData.GPA.percent.toFixed(2) ); $("#cum, #cum_gpa").html( "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2) From a94a671828bd368b941647d27fb6de68e2bc4a6b Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 16 Mar 2020 21:28:17 -0400 Subject: [PATCH 32/33] Move cumGPA function definition to calculate_grade.js --- public/js/calculate_grade.js | 23 +++++++++++++++++++++++ public/js/extraFunctions.js | 23 ----------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/public/js/calculate_grade.js b/public/js/calculate_grade.js index 4b17f3c1..44f20f80 100755 --- a/public/js/calculate_grade.js +++ b/public/js/calculate_grade.js @@ -248,6 +248,29 @@ function computeGPAQuarter(overview, i) { } +function cumGPA() { + let sumGPA = 0; + let sumOutOfFour = 0; + let sumOutOfFive = 0; + + let count = 0; + for (var i = 1; i <= 4; i++) { + + if (!isNaN(computeGPAQuarter(tableData.overview, i).percent)) { + sumGPA += computeGPAQuarter(tableData.overview, i).percent; + sumOutOfFour += computeGPAQuarter(tableData.overview, i).outOfFour; + sumOutOfFive += computeGPAQuarter(tableData.overview, i).outOfFive; + + count++; + } + + } + return { + percent: Math.round(sumGPA / count * 100) / 100, + outOfFour: Math.round(sumOutOfFour / count * 100) / 100, + outOfFive: Math.round(sumOutOfFive / count * 100) / 100 + }; +} function doCalculations(assignments, categories) { diff --git a/public/js/extraFunctions.js b/public/js/extraFunctions.js index cc96e808..9a87e21a 100755 --- a/public/js/extraFunctions.js +++ b/public/js/extraFunctions.js @@ -41,29 +41,6 @@ function getGPA(gradeToBeGPA) { } } -function cumGPA() { - let sumGPA = 0; - let sumOutOfFour = 0; - let sumOutOfFive = 0; - - let count = 0; - for (var i = 1; i <= 4; i++) { - - if (!isNaN(computeGPAQuarter(tableData.overview, i).percent)) { - sumGPA += computeGPAQuarter(tableData.overview, i).percent; - sumOutOfFour += computeGPAQuarter(tableData.overview, i).outOfFour; - sumOutOfFive += computeGPAQuarter(tableData.overview, i).outOfFive; - - count++; - } - - } - return { - percent: Math.round(sumGPA / count * 100) / 100, - outOfFour: Math.round(sumOutOfFour / count * 100) / 100, - outOfFive: Math.round(sumOutOfFive / count * 100) / 100 - }; -} function GPAType() { let selectElem = $("#gpa_select"); let selectedElem = $(".select-selected"); From 3288939d1cb1b0afa0d3063dd4ddd771ae9861a6 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 16 Mar 2020 21:40:37 -0400 Subject: [PATCH 33/33] Make cumGPA take overview as an argument --- public/home.js | 2 +- public/js/calculate_grade.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/home.js b/public/home.js index 3f6f599e..acb3fc59 100755 --- a/public/home.js +++ b/public/home.js @@ -620,7 +620,7 @@ let termsReset = {}; tableData.overview = response.overview; - tableData.cumGPA = cumGPA(); + tableData.cumGPA = cumGPA(tableData.overview); document.getElementById("cum_gpa").innerHTML = "Cumulative GPA: " + tableData.cumGPA.percent.toFixed(2); // Calculate GPA for each quarter diff --git a/public/js/calculate_grade.js b/public/js/calculate_grade.js index 44f20f80..3d697a4e 100755 --- a/public/js/calculate_grade.js +++ b/public/js/calculate_grade.js @@ -248,7 +248,7 @@ function computeGPAQuarter(overview, i) { } -function cumGPA() { +function cumGPA(overview) { let sumGPA = 0; let sumOutOfFour = 0; let sumOutOfFive = 0; @@ -256,10 +256,10 @@ function cumGPA() { let count = 0; for (var i = 1; i <= 4; i++) { - if (!isNaN(computeGPAQuarter(tableData.overview, i).percent)) { - sumGPA += computeGPAQuarter(tableData.overview, i).percent; - sumOutOfFour += computeGPAQuarter(tableData.overview, i).outOfFour; - sumOutOfFive += computeGPAQuarter(tableData.overview, i).outOfFive; + if (!isNaN(computeGPAQuarter(overview, i).percent)) { + sumGPA += computeGPAQuarter(overview, i).percent; + sumOutOfFour += computeGPAQuarter(overview, i).outOfFour; + sumOutOfFive += computeGPAQuarter(overview, i).outOfFive; count++; }