Assignment 2: Bid points
Due: 5pm, Friday, February 10. Value: 40 pts. You may work with one other student on this assignment if you wish. Submit to Sauron.
In this assignment, you'll develop a front end (as described
under Front end
below) for allowing
students to bid
for courses. We'll suppose that each
student enrolling in the course has 10 points
to allocate
between courses that the student would like to take; whenever the student
wishes to enroll in the course, a bid of at least one must be
placed onto the course.
Back end
I have already created a back end using an SQLite database. This includes two files to be executed using Node.js (with the nodejs command). There should be no reason for you to modify either of these two files, linked below.
bids-init.js Creates the initial database, deleting old database if necessary. bids-server.js Runs the HTTP server to serve files and respond to requests
The initial database as configured by bids-init.js has a set of 15 courses (as it happens, those offered for Maymester 2012), along with bids for three students (named bugs, daffy, and elmer).
For most requests coming from the browser, the HTTP server
bids-server.js assumes
that the path requested represents a filename, and it looks in
the current directory to find the data it should send in
response. However, there are two special
paths that the
server treats specially: /fetch and /set_bid.
- /fetch
This should be sent as a GET request, with a parameter named user (technically optional). The server returns a JSON object containing a success property that is true or false. If success is false, then the JSON object has a message property whose value is a string denoting the problem with the request. If success is true, then the JSON object has a results property whose value is an array of objects representing each course in the database. Each of these course objects has the following properties (all with string values):
course The course identifier (e.g., CSCI 135
)title The course title (e.g., Robotics Explorations Studio
)instructor The instructor (e.g., Ferrer
)enroll The number of students who have bid for the course. bid The number of points bid by the indicated user. (This is omitted if the GET request omits a user parameter). - /set_bid
This should be sent as a POST request, with three parameters: user specifying the student's user ID, course specifying the course ID (e.g.,
CSCI 135
), and bid specifying the requested bid that the indicated user wishes to place on the requested course. The server returns a JSON object containing a success property whose value is true or false. If success is false, then the JSON object has a message property whose value is a string denoting the problem with the request. Some potential problems are a user ID with nonalphanumeric characters, a user ID whose length is not between 1 and 40, an unrecognized course ID, a bid that is identical to the current bid in the database, or a bid that will push the user's total bids over 10.
Front end
In addition to the two back-end files displayed above, you'll also want to download the jQuery JavaScript library, which will be served as part of the front end alongside the JavaScript file that you write.
jquery-1.7.1.js jQuery library
The front end should work as follows:
The page will initially display a log in
form consisting
of a blank requesting the user ID and a button for logging in.
The page should send a /fetch request to
the server; if successful, the log-in form should
disappear, replaced with the information sent
by /fetch in a table such as the following.
ARTS 130 Digital Art I Payne 0 — ARTS 290 Beginning Bookbinding Jensen 0 — CLAS 255 Medical Etymology Resinski 0 — CSCI 135 Robotics Explorations Studio Ferrer 2 1 DANC 205 Intro to Asian Music and Dance Griebling/Rogers 0 — ENGC 390 Non-Contemporary Poetry Jaeger 1 2 ENGL 272 Crime Literature and Film West 1 — PHIL 200 Ethics and Pornography Campolo 2 — PHYS 100 Physics of Superheroes Wright 3 4 PHYS 160 Astronomy Wright 1 — POLI 365 Law and Legal Reasoning Maslin-Wicks 1 — PSYC 180 Illusions and the Brain Puri 0 — PSYC 185 Sleep and Dreaming Peszka 0 — PSYC 190 Social Psychology in Film Zorwick 2 3
From here, entering an integer into any blank and clicking the Change button should result in a /set_bid request being sent to the server for the corresponding course. Upon the completion of the /set_bid request, if success is false, the message should be displayed for the user to see; and if success is true, the page should refresh the table to reflect the updated value.
After logging in, the page should also include a link for refreshing the table (which would get updated information in case another user has registered for a course since the current information was entered) and a link for logging out (which would return the screen to its initial login state).
While the above description describes the basic behavior of
your Web page fairly thoroughly, there is quite a bit of
flexibility about how exactly it is presented.
You should strive to make your page as
usable
as possible. As always, feel free to talk with me
regarding any questions about how to do something specific.
Submit the files containing your HTML, CSS, and JavaScript (but not the distributed files) to Sauron.

