For this project, my main focus was just to get the website working. Did I accomplish my goal? Yes. The current website is not only live, but it allows a person to discover where they are in pathway completion successfully. It also allows for an external person, like a teacher, to go in and update the possible classes for each pathway from a Google Sheet behind the scenes. The entire website is extremely cohesive.
[1] First, the "All Classes" tab of the public Google Sheet is pulled by the PHP program classPull.php by downloading the corresponding .csv file.
[2] Next, the classPull.php program parses each row of the Google Sheet into an individual "key-value" array inside one big array in the allclasses.json file. This part of the program runs until every row of the Google Sheet has been iterated through and added to the JSON file. The first line of the Google Sheet is used for every "key" value in each array while every corresponding line in the Google Sheet is used as the "value" part of each array. Each "key-value" array inside of the big array in the JSON file will appear something similar to the following, ['name':'Audio & Video Production I']. This allows for a much easier experience when trying to decipher which classes have been selected and what ID they pertain to.
[3] The website will then populate the search bar with all of the classes from the allClasses.json file using the "name" key from each array.
Currently, through the use of GitHub automation, steps [1-3], including step [1.5], which is explained later, are all set to automatically run every Sunday at 1 a.m. MST. This means that if someone, like a teacher, updates the Google Sheet, the website will automatically update it's JSON database every week with the most recent information.
[4] Once the user has entered all of their classes using the search bar, a new unique array of class IDs is created. This array is called $_POST and contains all of the corresponding"classID" keys from the class names in the search bar. When the user clicks the blue "Check" or "Search" button, the $_POST variable is then sent to the next screen, search.php. This next page of the website is run through the code of search.php.
[1.5] This step will parse all of the different pathway Google Sheets into their own unique JSON files. The same logic from steps [1-3] are used here. The only difference here is that instead of the sheets being used to populate the search bar, they are being used to compare the selected classes to those that are in each pathway currently offered at GMHS. Also, instead of the JSON files being called allClasses.json, they are a combination of numbers and letters in the format Ax-Py where "x" refers to the academy number and "y" refers to the pathway number. NOTE: In addition to the "name" and "id" keys in the Google Sheet, I have created additional keys for each class. These include "creditType", and"creditAmount." These unique keys are used elsewhere in my program to calculate percentages and print classes in certain places.
[5] The search.php code then takes the array of selected classes' IDs and compares them with the array of the needed classes' IDs for each pathway, one at a time. Then, it will add a certain amount of credit based on the "creditAmount" key in the array to the $foundationCount or $supportingCount variable depending on the "creditType" key.
[6] Once all of the classes have been iterated through, a percentage is calculated by dividing the $foundationCount and $supportingCount variables by the total number of required credits for both foundational classes and supporting classes respectively. This value is printed in the Foundation Classes percentage and Supporting Classes percentage on the website.
[7] Once everything above is complete, a final, overall, percentage is calculated. To calculate the main percentage of the entire pathway, the percentages of both the foundation classes and supporting classes are added together and divided by a total possible percentage of 200%. This final value is then multiplied by 100 and printed on the screen under the Pathway percentage on the website.
All of the pathways that are printed on this page on the website are printed through a big foreach loop that loops until there are no more pathways to check.