info2300-2020sp-website

Project 3: Well-Designed Photo Gallery

You will design and implement an online photo gallery in PHP. You will demonstrate your ability to design an aesthetically pleasing and usable interactive site. Your photo gallery will be backed by a database which you will use to store information about the images uploaded to your gallery. To help organize the photos in your gallery, you will implement the ability for users of your site to tag the photos.

Learning Objectives

Deadlines & Receiving Credit

Milestone Points Grading Method Slip Days Deadline
Milestone 1 (p3m1) 25 Feedback (completion) Maximum: 2 days
slip days = no feedback!
4/15, 11:59pm ET
Milestone 2 (p3m2) 25 Feedback (completion) Maximum: 2 days
slip days = no feedback!
4/22, 11:59pm ET
Final (p3fin) 150 Rubric
(p3m1 + p3m2 + p3fin)
Maximum: 2 days 4/29, 11:59pm ET

IMPORTANT! No feedback is provided for milestones submitted with slip days! If you want feedback, please submit by deadline.

Milestones are graded twice. First for feedback (completion grade only). Lastly, for points at the final submission (via rubric). All work is graded via rubric for points at the final submission. Use your milestone feedback to improve your final grade; revise milestone work prior to final submission.

Completion credit will be awarded so long as you made a good faith effort to complete the milestone’s requirements. Very obviously incomplete milestone submissions will receive a 0 for the completion grade.

Milestone feedback is not a pre-grade. This feedback is designed to catch large problems (which we sometimes miss). Regardless of the feedback (or lack of feedback) that you get, you are responsible for meeting all of the project’s requirements for the final submission.

Failure to push your submission to GitHub is equivalent to not submitting the assignment. You will receive a 0. It is your responsibility to verify that you submitted your assignment.

Project Tips

This project is challenging. Start working on this project now. Take the milestones seriously. Seek help early. Do not wait till the last minute to start the project or seek help.

Take the design of your website very seriously. Since Project 4 was eliminated, your Project 3 is considered your portfolio showcase for this semester. Your design should look professional, be aesthetically pleasing, follow visual design principles, and be usable by your target audience(s).

Git Repository & Submission

Clone git@github.coecis.cornell.edu:info2300-2020sp/YOUR_GITHUB_USERNAME-project-3.git. Replace YOUR_GITHUB_USERNAME in the URL with your GitHub username. This is usually your NetID.

Submit all materials to your GitHub repository for this assignment. See README.md in your Git repository for submission instructions for each milestone. Never email your submission to the instructor.

Tip: Commit and push your changes every time you work on your project. Every time you commit and push you store your changes on the GitHub server. This acts as a back-up for your work. It also means that if you forget to submit before the deadline, there’s something already on the server that the TAs can grade for partial credit.

Documenting Design (Design Journey)

We will grade your design-journey.md in VS Code’s Markdown Preview. Everything, including images, must be visible in VS Code’s Markdown Preview. If it’s not visible in VS Code’s Markdown Preview, then we won’t grade it. We won’t give you partial credit either.

If you included images in your design journey, they must be visible in VS Code’s Markdown Preview. No credit will be provided for images in your repository that are not properly linked in Markdown. No credit will be given for design work not included in the documents/design-journey.md file; do not rename this file or put your answers in another file! Remember to check and test all assignment submissions!

Requirements

Create an online image gallery.

Note: Your content can be something other than an image gallery but it must follow a similar structure. If you choose entities other than images and tags, you should explain in your design journey how your entities correspond to the requirements of the assignment as written in the language of images and tags.

Design

Requests

Database

File Uploads

Seed Data (Populated Database + Images)

Best Practices

Scope

Milestone 1: Design, Plan, and Draft Website

In Milestone 1, you’ll design and plan your website and database. You’ll also generate seed data and build a draft of your website.

Complete the Milestone 1 section of the design journey: documents/design-journey.md.

Design

Design your Project 3 website. When designing take care to meet the gallery requirements above. Design is substantial component of Project 3. Take it seriously. You should strive to produce a well designed site that you would be proud to include in your portfolio.

Feel free to annotate your sketches with notes about how the behavior or design changes based on certain conditions. For example, “only show tags for this image…”

There is no minimum number of sketches. Include as many as necessary to fully plan out your website’s design.

HTTP Requests

Your gallery will need a quite a few HTTP requests to function. Plan out your requests in the design journey. Use your final design to determine every request you need, what that request does, what type of HTTP request it is (GET or POST), and what parameters you will pass along in your request.

Carefully follow the request requirements above.

Plan your Database Schema & Queries

Plan out your database schema.

Take the time to carefully plan your database. The extra care you put into planning your database will save you time in later milestones with less complex SQL queries. Trust me, poorly planned databases can lead to some pretty impossible SQL queries.

Think about the types of SQL queries you need to implement your design.

You may feel totally lost here. You may feel like there are so many requirements and you don’t know where to begin. This is normal. It’s difficult learning how to take the tools from your web programmer’s toolbox and use those to implement something new. Take it one step at a time. Think about how you might write a query for each of the requirements above. After you go through this process, you’ll starting feeling a lot more confident about this!

Plan PHP Code

Plan out the structure of your website.

Tip: Do not have a PHP page for each table in your database. You’ll often discover that the way you present information to your user is different than the way you store that information in the database.

Plan out your pseudocode for each page. Each page’s pseudocode should indicate where your planned database queries will execute. They should also take care to filter input, and escape output.

For example, you might want to do something like this:

if the user uploaded image (SELECT user_id from images WHERE id = 4) then
  show all tags (SELECT * from tags WHERE image_id = 4) to the user so they can delete them if they want

  if user clicks on delete link (image.php?action=delete_tag&tag_id=10&image_id=4), then
    (DELETE tag_id = 5 for image_id = 4 in image_tags table)
    (double check during filter input that current user "owns" the image before permitting deletion of tag)
  end
end

Note: Observe how I’m using query string parameters to pass information back to the server in order to complete certain requests.

It’s okay if your plan doesn’t exactly match your final code, although it should be close. The point of this exercise is to have you thoroughly think through how you will implement this before you start coding. It’s a lot easier to starting coding once you’ve thought through how you will code it. I really want to help you develop this habit of planning first, and coding second. It really does save you time in the long run and you’ll often be expected to do this for most programming related jobs.

Tip: Feel free to utilize user-defined functions to make this process easier for you.

Database Creation & Seed Data

Create your database based on your plan and populate it with initial seed data. Take care to meet the “Seed Data” requirements above.

You are not permitted to create or populate your database with DB Browser for SQLite. For this project you will need to write the SQL queries to create the tables and insert the seed data in the secure/init.sql file. You will need to look up the reference documentation for creating tables in SQL. We are not covering this in lecture or labs because we want you to have practice with SQL reference documentation.

We are using this script approach (init.sql) so that once Project 3 is over we can help you deploy your website to an actual live production server. Recall that production servers do not usually support SQLite. Instead they use MySQL or PostgreSQL. In order to deploy your website you’ll need to have an SQL script ready in order to create the database on actual web server.

You will also need to upload seed image files for your seed data. Follow the requirements in “Seed Data” above.

Draft Website

Start coding up your website. You should try to get as much of the HTML and CSS done as you can. That way you can focus on the PHP and SQL in future milestones. It’s okay if you don’t get very far yet. Just get it started.

Milestone 2: Gallery

In Milestone 2, you’ll begin to implement the gallery.

Implementation Requirements

Connecting to the Database

Since we’re no longer using DB Browser for SQLite, you’ll need handle creating your database differently to support deploying our website after you’ve finished this Project.

You will need to connect to your database using the $db = open_or_init_sqlite_db('secure/gallery.sqlite', 'secure/init.sql'); function provided for you in includes/init.php. This function checks to see if your SQLite database exists, if it does it connects to it. If it does not exists (i.e. there is no gallery.sqlite file) then this function creates the database initializing it with your secure/init.sql script. If you want to delete your database, just delete the gallery.sqlite file and the next time you refresh a page in your web browser, your database will be recreated!

IMPORTANT! If you change secure/init.sql you must delete secure/gallery.sqlite to regenerate the database. Many students fail to do this before their final submission only to submit broken init.sql scripts. The database then fails to create for the grader and we pretty much have to give you a 0 because your Project 3 won’t work without a database. CHECK CHECK CHECK your init.sql script by deleting gallery.sqlite and visiting index.php in your browser BEFORE you submit!

Warning: Do not run the PHP Server and DB Browser for SQLite at the same time! This can cause your database to become corrupted. If you need to view the database, stop the PHP server and then open DB Browser. When you are done with DB Browser you must exit it before you restart the PHP server.

Tip: If your database does become corrupted and you need a new one, simply delete the .sqlite file from the secure folder. The next time you connect to your database from your PHP code, your database will be recreated from init.sql.

Final Submission: Complete & Polished Website

You will finish coding the website that you planned in Milestone 1 and started implementing in Milestone 2. You should now implement everything necessary to meet the full requirements of the assignment. You should spend most of your time polishing your design. Your design should be professional, be aesthetically pleasing, employ visual design principles, and leverage existing design patterns to improve usability; your design should be worthy of your portfolio.

Complete the Final Submission section of the design journey: documents/design-journey.md.

Test your final web site thoroughly, especially your forms. We will try to break your web page during grading. We will also try to inject HTML & SQL during grading.

IMPORTANT! TEST YOUR DATABASE! Delete gallery.sqlite and visit index.php and double check that your database was successfully re-created from init.sql. No database created for the graders = 0.