csci342 – Homework # 3 (Solution)

$ 20.99
Category:

Description

Please ZIP all your files together into one archive as before! There will be lots of files for this assignment. Include the files I’ve provided, so that each assignment is self-contained without my copying my files to your folder.
Instructions:
• Create two files to recreate the web page seen in Figure 1: tomayto.php and tomayto.css.
• This webpage will have the addition of a single input form at the top, allowing the user to pick the movie from a drop-down list of all available movies, and having that movie displayed when the user clicks the “Select” button.
• Your page does not have to match mine perfectly, in fact, it should match your solution to homework #2. You should take that file and modify it so that all of the dynamic information in the web page comes from files and computations on those files performed in php on the server. You should not have to change your CSS file at all, except to add some styling to the movie selector.
• Again, format your html, php, and css to be as readable as possible.
• Place a comment header in each file with your name, a brief description of the assignment, and the file’s contents.
Movie files:
• I have provided a zip archive of several movie files (actually, these were created by others, but I modified them slightly). Your program should handle any number of movies, each in its own subfolder of moviefiles. I will add one or two more movies when testing your page, so do not hard-code the movie names, use a glob pattern.
• Each subfolder will consist of the following files:
info.txt A file with three lines of information about the film. We will only use the first two, the title and the year. For example:
The Princess Bride
1987
95
overview.txt A file with information about the movie to be placed in the General Overview section. Each line starts with a title for that line, followed by a colon, and then the information for that line. There are no line breaks other than between items.
These items are to be displayed as a definition list with a definition list term (dt) and its description (dd). The number of lines in the file varies from movie to movie. Example (I have let the long line overflow to the right to emphasize the fact that this will be on a single line in the file):
STARRING:Cary Elwes, Robin Wright, Andre the Giant, Mandy Patinkin
DIRECTOR:Rob Reiner
PRODUCER:Arnold Scheinman, Rob Reiner
SCREENWRITER:William Goldman
RATING:PG
RUNTIME:98 min
SYNOPSIS:Director Rob Reiner breathes vividly colored cinematic life into William Goldman’s TH
RELEASE COMPANY:20th Century Fox
overview.png The image to display at the top of the General Overview section. This image will be of size 250 × 412px.
review1.txt, review2.txt, … Files containing information for each review of the film. Each review contains exactly four lines: the review, the number of tomatoes (1-4), the reviewer’s name, and their affiliation. For example:
One of Reiner’s most entertaining films, effective as a swashbuckling epic, romantic fable, an
4
Emanuel Levy emanuellevy.com
• All the movie folders should be in a folder called moviefiles in the same folder as your tomayto.php. So, for example, the complete path to the Princess Bride image should be (starting from the same folder as your php file):
moviefiles/princessbride/overview.png The name of the folder is not important.
Your Own Movie: As part of your turnin, create your own set of movie input data for this page. Write info.txt, overview.txt, and at least four review text files for your movie. Also find a suitable image to use as overview.png, of size 250 × 412px.
Server side computations: You will, of course, have to read data from the files to prepare each page. You will also have to do some processing to compute some of the content. For example, you will have to find the average tomato ranking to put as the giant red number at the top of the page. You will do this by running through all the reviews, finding the number of tomatoes and the number of reviews, and calculating the average.
Select movie dropdown: You will also have to find each of the movie folders in order to populate the dropdown selection next to the average tomato rating. This should be a form with a select input in it, with each value being the folder name for the movie, and each text in the selection being the actual movie name (found in the info.txt file).
Further, initially the page should load the “Princess Bride” movie, and this should be selected in the dropdown menu. Thereafter, the selected movie in the drop-down should always be the movie selected.
You will also need a submit button in the form containing the drop-down menu. Its action should be the same page, tomayto.php. We could make this a little nicer by submitting on selection, but that would require javascript and that’s forbidden for this assignment. Your php, therefore, needs to consult the $ GET variable to determine which film to display (with the default of “Princess Bride” if there is none selected).
No javascript: There should be no javascript used in this program. The entire appearance of the page should be created on the server in php, css, and html.
Style:
• Your PHP code should not produce any warnings or errors.
• Programming style will be considered in your grade.
• Do not use any unnecessary global variables.
• Produce as much of your output as possible in HTML mode as possible, without print or echo statements.
• Use functions when they seem appropriate.
• Put descriptive comments in your PHP code where appropriate.

Figure 1: Screenshot of final webpage.

Reviews

There are no reviews yet.

Be the first to review “csci342 – Homework # 3 (Solution)”

Your email address will not be published. Required fields are marked *