Programming in Perl

Homework 5

Due Wednesday, November 20, 2002 - 11:59:59pm EST

FAQ now available


Write a Perl CGI program to serve as a to-do list. The program will have two seperate screens.

In the first screen, you will provide a form for the user log on. This will be a simple form with a text field, a password field, and a submit button. It should also have a way to signify that this is a new user. If the login is successful (see below), you will proceed to the next screen. If not, give an error message, and tell the user to go back.

The second screen is the main program. This screen will show a list of the user's tasks, and provide a method to add a new task. The task must have a title, a description, and a deadline. The deadline should have at least Month, Day, and Year. (Adding Hour, Minute, and Second is optional). Any current tasks that have a deadline in the past must be displayed in red. This screen must also have a means of marking a task completed.

On this second screen will be an Update button. Clicking this button will first add the new task (if any), and secondly it will remove the tasks listed as completed (if any). Also, you must send an email to the user, informing him/her that the task has been completed. In this email, give the task's title, description, deadline, and time completed. After this update button has been pushed, your program must go back to the second screen, and display the updated information.


Users in the system

On the first screen, you have a field for the username, password, and whether or not this is a new user. If the user marks that this is a new user, create this user in the system. New users have no tasks. A username should be an email address (you don't have to check that the username fits an email address pattern), so when you email the user after completing a task, you can just email the username.

If the user logs on with an incorrect password, or with a username not in the system (and it's not marked as a new user), you should print an error message and tell the user to press the Back button. Likewise, if the New User field is marked, and the user entered is already in the system, you should print a similar error message.

Note that only the tasks for the user that is logged onto the system should be displayed. Any other tasks in the system that belong to another user should not be displayed


Deadlines

To determine whether or not a deadline has passed, capture the output of the external program date
This program returns a string in the format:
Ddd Mmm # hh:mm:ss ZONE yyyy
For example:
Wed Nov 6 11:34:49 EST 2002
Using your knowledge of Perl, you should be able to extract the Month, Date, and Year, and be able to compare these values to the values in the deadline for the task.

I would suggest only worrying about the Month, Date, and Year for the purposes of this homework. In that case, a deadline is considered passed if the current date is at least one day beyond the deadline date. (ie, if the two dates are equal, the deadline has not yet passed). If you choose to extend your program to use the Hours, Minutes, and Seconds, then a deadline is passed if the current date is one second beyond the deadline date.

Note that it is perfectly acceptable for a user to enter a new task that is already passed the deadline.

I will point out that there is a Date::Manip module available on CPAN that you may wish to try to use as an alternative. However, I am not endorsing this method, so do not expect any assistance with it from me.

Error Checking

Much of the error checking in this assignment will depend greatly on what you allow your user to do. For example, if the user selects a deadline Month by simply typing it in, you must make sure this is an actual month. But if the user selects a month by choosing one of a provided 12 options, then obviously you don't need to make sure the month is valid.

In general, any time the user does something 'wrong' and then pushes a submit button, print a blank screen with an error message, part of which tells the user to push his/her back button.


Other notes

If you have your own webserver, you may run your program there as opposed to the CS deptartment's CGI server. The homework submission scripts will be modified to ask you for your program's URL. Note that if you choose to use your own webserver, you must insure that the server is up and running from the time of the submission deadline up until the time you get your grade back.

Your entire program must be contained within one single perl file. It is not permissable to have a static HTML file that contains the initial form, or a seperate CGI program for the logon and main screens.

You may choose any style of datafile you wish to create, so long as your program can write to it and parse it.


Grading Criteria

Create New User5
User Logon10
Display Current tasks15
Past Deadline tasks in red10
Add new Task15
Mark Task Completed and remove15
Email user when Task Completed10
Compilation5
Error Checking5
Code Style5
'Output' Style5
As always, 5 Above & Beyond points are available.

Submission Instructions

You may submit the program either via the submission script or via ~lallip/public/submit.pl. The assignent is due Wednesday, November 20th at 11:59:59pm EST. It may be turned in up to 24 hours late for a 20% penalty.