Project 1

4002-539/4004-739 - Fall Quarter (20051)

Due Sunday, October 2nd, 8:00 p.m.
Project 1:
Site Design and On-line Polling Application.

On-line polls are a simple way to involve visitors in the content of a web site. Although they are not scientific, they provide some sense of how your visitors feel about a topic and people like to express their opinions. It doesn't hurt that they can be entertaining. In this first programming project, you will build a simple on-line polling application.

This first project is part of a larger process of not only learning about web programming but thinking about the representation of information on a web site and the generation of dynamic content. The poll application will also be incorporated into your final web site so you are building a component. As a matter of fact, your poll must be embedded in a mock-up of your E-Commerce page.

This application is data-driven. You are probably accustomed to writing subroutines that are parameter-driven or applications that are data-driven. Here, the data comes from external sources: another computer (browser) via another process (web server) or from files. Users pick which poll they are interested in, whether they want to cast a vote or just look at results. The choice of polls and data about each individual poll are stored in external files so adding, changing or deleting a poll requires no modification to your code.

There are three basic forms of data that you need to store in text files on your web site.

  • Polls: a poll consists of a question and several user choices (responses) - these are .poll files.
  • User response data: How users are voting on each question (this data can be part of the .poll file, too or as a separate .dat file for each poll.
  • Configuration file: a single file that you will use to simplify administration of your polling application - this is a poll.config file. It contains a list of polls.

Here is a sample poll. Try it out.

Nuts and bolts:

  • Create a sub-directory in your pfw directory on vega called project1 (all directory names must be lowercase) in which you can place this assignment's elements. Everything goes in there.

The specific requirements for the project are listed below:

  1. Design a front page to your E-Commerce site. (Most of it will be static for now.) Your E-Commerce site will be an information/commercial site about a topic of your choosing. Your home page must include a recognizable photo of yourself integrated into the design. The site will eventually include the following things, so they should be part of the design:
    • Poll
    • News Feeds
    • SOAP Services (You can relabel this section later in the quarter when you choose your services.)
  2. Your poll must be part of your mock-up of your web site (even if our example is not :-) )
  3. You must give the user a choice of at least three polls as a starting point. This list is generated dynamically from the contents of the config file, so if your application is well-written, you could have any number of polls and your program would require no modification. The list of polls is maintained in the configuration file.
  4. Polls can have as many as 5 responses to the question to choose from or as few as two. This is actually arbitrary; a well-written program will handle as many choices as you throw at it and thinking about this as dynamic is a better way to begin.
  5. Adding new polls and changing the polls requires no modification to the scripts. Just make a new file with the question and responses in it and add the poll to a configuration file (which is basically a list of polls). Poll files should be called <filename>.poll (like, bush.poll) so they are easy to recognize (by humans and programs).
  6. The configuration file must be called polls.config. It contains a list of polls (the base name would be easier) and, minimally, whether the poll is active or not (can you enter you opinion or is voting over and you can just see the results).
  7. The data for each poll can be stored either in the .poll file or in a separate <filename>.dat file (like, bush.dat).
  8. Put all of your external data files in a subdirectory called polldata.
  9. All external files should be human-readable text files. Using a table metaphor, each line in the file is a row in the table. Use tab characters to delimit the data on a line (make the columns in the table).
  10. When users vote in a poll, they get immediate feedback showing the current results of the poll. The output will state how many votes were cast for each choice and the total number of votes cast. Start by showing a count and then add a percentage for each choice as well. As time permits, add a graphic representation (bar graph).
  11. Use the GET method for input from the browser to the program so that the parameters passed to your scripts are visible to me.
  12. Use file locking to maintain the integrity of the count of votes (we don't want any voting irregularities in our polling places!).
  13. Modularize your code to abstract getting and saving data from external sources. For example, you can put the information about a poll into an array to use it to generate a web page to vote. How it got into the array and where it came from should be unnecessary information for most of your code.
  14. Submit your scripts (.php pages) and your config, an example of your .poll files and .dat files as an attachment to a note posted in your section of the course's subconference for project1. If you did any extras or you need to explain anything about what you did, please put it in this note. This subconference will be set up as a drop box so you can submit work but won't be able to delete what you submit or look at other students submissions. You can resubmit, however.
Extras

Here are a few things that you can do to enhance the assignment (to get an A on the project, you must exceed the basic requirements in some significant way) as examples:

  1. Extend the config.poll file format so that it includes a start and end date for a poll so that you can have current polls in which users can vote and prior polls that have expired for which users can only view results.
  2. Provide a supplemental capability for creating a new poll (the text file that contains the question and choices, a new data file for accumulating voting results), and a new entry in the config fle. This capability must be password protected; only someone with a valid username and password can create a new poll. You may assign new usernames and passwords manually (add them to a file of users and passwords). If you do this option, you must include my password (my username is dsb) in your submission e-mail (not in an archived readme file) so that I can test your program.
  3. Make an administrative interface to make it easy to add new polls, delete/close polls and modify polls.
hints:

Here are some functions and tips that you may find come in handy:

  • The file_exists() function to check if a file exists.
  • fopen() opens a file and returns a file handle.
  • flock() uses a file handle to get or release a lock on a file.
  • split() can make short work of splitting a text string into elements based on a delimiter.
  • round() function converts a real number to an integer (width and height of graphics in html img tags must be integers).
  • You can read an entire file into an array (one line in the file = one element in the array) with the file() function.
  • directories con
grading:

The most essential element of the project is scripts that work properly and functionality that matches the requirements stated above.

  • 75%: It works
    • Basic functionality described above
    • Robustness and error-handling
    • Proper installation
    • Data file format
  • 15% Code quality
    • Code structure and documentation including effective software design principles such as modularity, defining reusable functions, function cohesion (functions/subroutines have a single clearly defined purpose) and minimal coupling (no unnecessary use of globals, proper parameters to avoid unintended side-effects).
  • 10% Web site mock-up
    • Mock-up design
    • Poll is integrated into design

Due date: Due Sunday, October 2nd, 8:00 p.m. 10% per day late. Nothing accepted after Sunday, October 9th, 8:00 p.m. without explicit permission from your professor.

 

©2004 Information Technology Department, RIT