reidhoman / class-survey

0 stars 0 forks source link

Code Dev - CIS 486 Tutor Application #1

Open reidhoman opened 3 years ago

reidhoman commented 3 years ago

https://github.com/reidhoman/class-survey/tree/main/CIS486Survey

While learning PHP, I decided to put it to the test and create a PHP form application that identifies whether a student may be eligible to become a tutor for the class. Linked above are the 5 php files that make up my entire form that I placed in a public repository.

In the application:

  1. It asks for a students' first and last name (index.php)
  2. It provides a list of skills that a student can check depending if they have the skill (topics.php)
  3. It asks the student to write about their former experiences (experience.php)
  4. It pulls all the data from previous files and asks user if it looks correct (confirmation.php)
  5. PHP code analyzes data to see if student is eligible to receive an interview for the tutor position (results.php)
reidhoman commented 3 years ago

https://rhoman.herokuapp.com/

I was able to figure out how to deploy my php code through my personal Heroku (which is linked above). It is able to go through each PHP file and maintain/store data (am now a Superglobal/$_SESSION master lol) provided by user. Then my code uses the entered data in a function (results.php) to see if user meets requirements to receive an interview. Also linked below is link to my repository containing each php file. Thanks for your help!

https://github.com/reidhoman/class-survey/tree/main

reidhoman commented 3 years ago

Also, I submitted this for both /MV and /MVC devs. While it obviously provides data to user, it also uses the provided data in a function - which gives the user different results based on the user's input. If not enough skill requirements are checked by the user in the skills.php page of the Tutor Survey Application, its displays "Sorry, your application was rejected. More skills are required for this position" (in function, I set the required amount of skills to 5). However, If the skills requirement is met, the final php page accepts the user for an interview.

reidhoman commented 3 years ago

Resubmission for: (DEV/code) Test Deployment: https://rhoman.herokuapp.com/ Source Code: https://github.com/reidhoman/class-survey/tree/main

Explanation of how I checked for user input within my code:

Within my Tutoring Application, I created 5 PHP files (as displayed in my linked source code above):

  1. '/index.php'
  2. '/topics.php'
  3. '/experience.php'
  4. '/confirmation.php'
  5. '/results.php

The first four files listed above each consist of a PHP form that includes 2 methods: (1. Action 2. Post). Below is a provided code snippet of one of these PHP forms:

form

This 'action' method points to the next intended file in the application. For example, the snippet above is pointing this file to the '/topics.php' file. In order to maintain the entered user data throughout each page, I used PHP Sessions - which are predefined variables (known as superglobals) that allowed me to store and use the data. By placing each file within a Session, I was able to access all the user's entered information in a function within my '/results.php' file. This function (checkResults) is displayed below:

code

It uses the data entered from the '/topics.php' file to determine whether a (student) qualifies for the class tutoring position. This function uses two variables: $desired and $possessed). As displayed in the snippet above, I set the desired number of skills to 5 (variable name: $desired). The $possessed variable is the actual number of skills the student selected in the form - which is passed in from the Session. Within the function, it contains an 'if' statement that checks to see whether the possessed variable is more or less than what is actually desired (5). If the possessed variable is less than desired ($possessed < $desired), the $result variable will equal false - which will echo to the student that he or she did not meet the requirements for the tutoring position. If true, the user will be accepted for an interview.

Thanks for all your feedback!

reidhoman commented 3 years ago

Resubmission for: (DEV/mv) *please excuse my previous bad syntax and use of ~pictures~... can't even say it 😨 Test Deployment: https://rhoman.herokuapp.com/ 🔗 Source Code: https://github.com/reidhoman/class-survey/tree/main 🔗
Purpose: Explanation of where the model (data) is within my application and how it is used by my code.


Within my Tutoring Application, I created 5 PHP files (as displayed in my linked source code above):

index.php topics.php experience.php confirmation.php *results.php

While the first four listed files obtain data from the user and store them via Session variables, the topics.php file contains my Model (data) used to execute my code. This file receives the inputs given by the user (in this case the # of skills selected). It was also important to make sure my data was clearly distinguishable from the coding portion. To separate the html user input from my php code (abstraction), this data is stored in a php session array: $_SESSION['lang'].

As you can see from this superglobal, I used PHP Sessions - which are predefined variables that allowed me to store and use the data. By placing each file within a Session, I was able to access all the user's entered information in a function within my results.php file.

This data (number of desired skills) is used to determine whether or not the student is applicable for the tutoring position. This function (checkResults) is displayed below:

 $possessed = count($_SESSION['lang']);

        function checkResults($desired, $possessed) {
            $result = false;

            if ($possessed < $desired) { //checks for number of skills selected
                $result = false;
            } else {
                $result = true;
            }
            return $result;
        }

        if (checkResults($desired, $possessed)) {
            echo "You are accepted for an interview!";
        } else {
            echo "Sorry, your application was rejected. More skills are required for this position.";
        }
        ?>

This function I created uses the data entered from the topics.php file to determine whether a (student) qualifies for the class tutoring position. This function uses two variables: $desired and $possessed. As displayed in the snippet above, I set the desired number of skills to 5 (variable name: $desired). The $possessed variable is the actual number of skills the student selected in the form - which is embedded from the Session.

Within the function, it contains an 'if' statement that checks to see whether the possessed variable is more or less than what is actually desired (5). If the possessed variable is less than desired ($possessed < $desired), the $result variable will equal false - which will echo to the student that he or she did not meet the requirements for the tutoring position. If true, the user will be accepted for an interview.


Thanks for your feedback! (and dealing with my previous 💩 display of code *insert crying Jordan meme) :electron: Homanator :electron:

reidhoman commented 3 years ago

Submission for: (DEV/deploy) Source Code: https://github.com/reidhoman/class-survey/tree/main Test Deployment: https://rhoman.herokuapp.com/

As linked above, I was able to deploy my CIS 486 Tutoring Application using my personal Heroku account. Because my application consists of 5 PHP files, it is unable to run on Github. However, Heroku has PHP capabilities - which is what ultimately led me to this route.

Before deploying, I first had to upload (push) my PHP application to my own Github repository. Once I completed this step, I began the process of building my Heroku App. In Heroku, I first had to go to the 'Deployment' tab in order to properly sync my Github repository containing all my files. (Initially, my Heroku was connected to your Dev Repository (shoutout to Dev 7). To fix this, I connected it to my new repository, as shown below:

heroku

Next, I had to select the necessary branch from which to deploy from. I connected it using the 'main' branch (which consisted of my Tutoring Application). Image of selected branch below:

Deploy

After successfully syncing my Github repository to Heroku, I was able to view my Application through an "Active Test Link" - which I included at the top of the page. This what extremely beneficial for me - allowing me to work with my new Application without having to use localhost to view it.

Thanks again! Reid

reidhoman commented 3 years ago

Resubmission for: (DEV/lvl-up) *I fixed the syntax. Thanks for letting it slide on the code dev. 🖐️ Test Deployment: https://rhoman.herokuapp.com/ 🔗 Source Code: https://github.com/reidhoman/class-survey/tree/main 🔗 Purpose: Explanation of how I checked for user input, passed data throughout each file, and used the data to record results for the user.


Within my Tutoring Application, I created 5 PHP files (as displayed in my linked source code above):

  1. index.php
  2. topics.php
  3. experience.php
  4. confirmation.php
  5. results.php

The first four files listed above each consist of a PHP form that includes 2 methods: (1. Action 2. Post). Below is a provided code snippet of one of these PHP forms:

<form action = "topics.php" method = "post">
            First Name: <input type = "text" name = 'firstname'><br>
            Last Name: <input type = "text" name = 'lastname'><br>
            Remember Me: <input type="checkbox" name="remember" value="ON" />

            <input type="submit" value="Submit">

        </form>

This 'action' method points to the next intended file in the application. For example, the snippet above is pointing this file to the topics.php file. In order to maintain the entered user data throughout each page, I used PHP Sessions - which are predefined variables (known as superglobals) that allowed me to store and use the data and pass arguments. By placing each file within a Session, I was able to access all the user's entered information in a function within my results.php file. This function (checkResults) is displayed below:

$possessed = count($_SESSION['lang']);

        function checkResults($desired, $possessed) {
            $result = false;

            if ($possessed < $desired) { //checks for number of skills selected
                $result = false;
            } else {
                $result = true;
            }
            return $result;
        }

        if (checkResults($desired, $possessed)) {
            echo "You are accepted for an interview!";
        } else {
            echo "Sorry, your application was rejected. More skills are required for this position.";
        }

It uses the data entered from the topics.php file to determine whether a (student) qualifies for the class tutoring position. This function uses two variables: $desired and $possessed. As displayed in the snippet above, I set the desired number of skills to 5 (variable name: $desired). The $possessed variable is the actual number of skills the student selected in the form - which is passed in from the Session.

Within the function, it contains an 'if' statement that checks to see whether the possessed variable is more or less than what is actually desired (5). If the possessed variable is less than desired ($possessed < $desired), the $result variable will equal false - which will echo to the student that he or she did not meet the requirements for the tutoring position. If true, the user will be accepted for an interview.


Thanks for all your feedback! (I 100% agree it looks wayyyyy better with proper syntax instead of using ~pictures~ ... actually let's not even mention it ever happened) 🤝

:electron: Homanator :electron:

reidhoman commented 3 years ago

Submission for: (DEV/full-stack) 🌟 Source Code: https://github.com/reidhoman/class-survey/tree/main 🔗 Test Deployment: https://rhoman.herokuapp.com/ 🔗 Full-Stack Video Link: https://www.youtube.com/watch?v=2s8Mgm8n8xk&t=172s 🔗 🎥


Linked above is my full-stack video explaining the process of:


Thank you for all your feedback over the course of this class and working with me through my busy baseball schedule! :electron: Homanator :electron: