9. SRC ACTIVITY - software-projects-qubit/Software-Project-1.0 GitHub Wiki
We have a switch case statement which performs a certain action based on the ACTION attribute stored in $choice.
POST ACTIVITY
If the $choice == POST_ACTIVITY, then this section of the switch case statement will be executed. We get the SRC_MEMBER_USER, which is the SRC member username which is stored in $member_username. We also get the ACTIVITY_TITLE from the app interface with the SRC_MEMBER interacting with it, this is stored in $activity_title. We then store the description of the ACTIVITY at $activity_desc. We finally get the ACTIVITY_DATE and ACTiVITY_TIME which are stored in $activity_date and $activity_time respectively. We have $stmnt which binds everything together along with the insert statement, we have the $args array taking all the attributes which are then executed by the database manager
READ ACTIVITY
If the $choice == READ_ALL_ACTIVITIES, then we execute this part of the switch case statement. in $stmt we store the select * from ACTIVITY_TABLE which has ORDER BY since we want to order by the ACTIVITY_TIME AND ACTIVITY_DATE to rank them from newest to oldest on the list. Database manager executes all of these.
UPDATE ACTIVITY
If the $choice == UPDATE_ACTIVITY, then we execute this part of the switch case statement. We get the ACTIVITY_ID which will be stored in the $activity_id attribute, the ACTIVITY_TITLE stored in the $activity_title and finally the ACTIVITY_DESC which is stored in the $activity_desc. The ACTIVITY_TITLE is the "Heading" and the ACTIVITY_DESC is the description, the body content of the post explaining in further what the title meant. the $args array again takes these and stores them which are executed by the database manager.
DELETE ACTIVITY
If the $choice == DELETE_ACTIVITY, then we execute this part of the switch case statement. We need the ACTIVITY_ID which is not known to us since it's auto incremented. We get this ID by allowing the SRC_MEMBER to click on it, which will return it. We store that in $activity_id which is then used in the $deleteCommentstmt. It is used to reference the exact comment. This action can be done by the SRC member or student, but neither can delete the other's contents. We can delete the ACTIVITY using the $activity_id value which will be removed from the table. We use $stmt to bind everything which is then executed by the database manager.
LIKE/DISLIKE
If the $choice == POST_LIKE_OR_DISLIKE, then we execute this part of the switch case statement. $activity_id, $student_username, $like_dislike store the certain activity id, username of the user and their like or dislike respectively. We use $stmt to store the query that will be used to get the certain activity id matching $activity_id and the student username matching $student_username. We then have an if statement that checks if the number of rows is greater than 0 or not; if it is, then we use $stmt2 to update the like/dislike, or else we actually insert the $stmt3 into the database. $stmt3 store the like/dislike and the activity id.
COMMENT
If the $choice == POST_COMMENT, then we execute this part of the switch case statement. We get activity id, student username, student comment, student anonymity, student_date and time, we then use $stmnt to insert those values into the STUD_COMMENT_TABLE by binding it in the array which is then executed by the databaseManager