PHP Assignment
Assignment 3 COMP1230 (Advanced Web Programming) Fall 2021 - Assignment3 version 1.0 Due date: Nov 19 by 11:59 pm. Weighs 9% of the total mark for this course We suggest you start early so you will allow enough time to have your questions answered. Objective: The objective of this assignment is to create a simple PHP application to perform CRUD (Create, Read, Update, Delete) operations using a flat-file (no database). This will enable students to practice using arrays, iterations, conditional statements, and user-defined functions. Students will also have the opportunity to use Bootstrap in their application to present their content/pages responsively. Operations: Implement a user-friendly interface to allow users to create & manage records (CRUD operations). You may assume you are building the back-end portion of an application, which the owner of a store/company will use to manage the inventory. This store sells TVs of certain brands. a) Create — Consists of a form that allows users to enter information about a new record. A dedicated function should be responsible to handle adding a record to the CSV file. If insufficient data are submitted (empty/invalid data), the user should be notified and given the chance to meet the required field/s without re-entering data that was already inputted. Once the data is validated, your function should generate a unique id for the record and generate a 5-digit random number to be used as an item number. Your function would then append the record to the CSV file. The form should contain the following fields/controls: Required fields are indicated by * (asterisk) - Type * dropdown menu with following options: - Brand * radio buttons with the following options: - Model: string * - Size: Integer value represents TV size in inches * - Price: floating number up to two decimals * - Sale: floating number up to two decimals to display when a TV is on sale - Description: Text field to be used to input more info (specs) about a tv. Note: text typed in this field may contain commas, so your logic should be able to handle that (comma typed in this field should not be treated as a delimiter). b) Read — a. Allow users to preview all records. This function would not alter the records - it would simply retrieve the resource and make it available to your controller/view to be displayed in a tabular format. The table should contain the following columns: If a TV is on sale (sale price field contains value), the sale price should be displayed instead of the original price (in red colour) as demonstrated in the example above. This view would be the default landing page for your application. It should also allow users to select: read, update, or delete an individual record if they wish. b. You should also have a function to retrieve a single record. All data (related to a single record) should be presented to the user in read-only (none-editable) format. The page should give the user an option to click to get back to the main view. To make it more user-friendly, you could provide an edit & delete buttons on this page to trigger your update/delete functionality (reusability). c) Update — Consists of a form where information about an existing record would be presented in edit mode. A dedicated function should handle the submission of this form. This function saves the record back in the CSV file without assigning a new id (the original id of the record should not change). d) Delete — There should be a function to call to remove a record from the CSV file. Users should be prompted to confirm the removal of any record to ensure they did not accidentally request that action. e) Search – user should be able to search for a record by item number f) Filtering records in main view – user should be able to filter out records to only view TVs of a specific brand: g) Export the data as a CSV file – This feature (a link/button) will trigger a function that downloads the CSV file from server to user’s machine. h) Import the data in CSV format – This feature allows the user to upload a CSV file to be used by your application. Note: you must name the new file as your original data file used by your application (replacing the existing one). Each task must be handled by a dedicated function, and all your functions must be placed in a file called functions.inc.php Grading criteria: Please note your assignment must be fully functional. There will be no partial mark. ▪ Your assignment will be marked according to how well it meets the following criteria: o Originality, overall functionality -- 50% o Overall design (GUI) -- 20% ▪ User friendly & accessibility ▪ Tidiness ▪ Responsive o Efficiency, logic, reusability -- 20% o Code documentation (commenting), indentation, readability, naming conversion -- 10% When will you lose mark: 1. Late penalty -10%/day 2. Your assignment does not pass the HTML5 validation (or you have ignored adding the validation script before closing the body tag). -10% 3. Make sure to include (your assignment will not be marked if this is ignored) 4. If your GBLearn account is not set up your assignment will not be marked. a. Grant, both of your instructors, access to preview content of your GBLearn account, by adding them to the instructors list on my.gblearn.com b. Create comp1230 directory structure (specified on Blackboard) c. Update your GBLearn profile page (public_html/index.html), to include your information: o current picture of yourself (your face must be visible) o brief bio about yourself o a relative link to the comp1230 directory in your account Submission Guidelines: a. Upload all your files to the following directory in your GBLearn account comp1230/assignments/assignment3/ b. Login to my.gblearn.com and ONLY submit your functions.inc.php c. Follow the naming convention and have meaningful names for your variables and function. d. Apply proper indentation and space before and after operators for readability. e. Removing unnecessary/unrelated code & comments. f. Add necessary comments to summarize your code or to explain the programmer's intent. The act of plagiarism can be intentional or unintentional. The consequences are just as serious. Examples of plagiarism include (but are not limited to): ● Submitting an assignment that is not your own ● Submitting an assignment with sections that are not your own ● Cutting and pasting text or images from the internet without citing the source ● Including an exact quote without using quotation marks or citing the source ● Using any published or unpublished source of information (including ideas!) without citing the source ● Paraphrasing any source of information (including ideas!) without citing the source If you have any questions or concerns, remember always to ask your instructor and consult George Brown College’s STUDENT CODE OF CONDUCT AND DISCIPLINE for further details. http://www.georgebrown.ca/policies/Student_Code_of_Conduct_and_Discipline.pdf