CS 3113: Project 2

For this project, we will implement a miniature database with a front-end that is accessible using a web browser.

Objectives

By the end of this project, you will be able to:

Back-End Database

Your database will be stored in a file called grades.bin. Every time your program begins execution, you will open this file for both reading and writing. If the file does not exist on open, then you should create it. Much like your project 1 implementation, your file is composed of fixed-size blocks of data. Each block contains one instance of the AssignmentRecord structure, as defined in record.h:
#ifndef RECORD_H
#define RECORD_H

// Maximum size of assignment name
#define NAME_SIZE 23

// Name types
typedef enum {EXAM=0, HOMEWORK, QUIZ, PROJECT} AssignmentType;

// Name Strings
char *type_names[] = {"EXAM", "HOMEWORK", "QUIZ", "PROJECT"};

// Record of a single assignment
typedef struct {
  char valid;
  char name[NAME_SIZE];
  int type;                // AssignmentType 
  float max_score;
  float score;
  
}AssignmentRecord;

#endif

Notes:

Back-End Commands

Your program can be executed with a number of different sets of command-line parameters. Here are the ones that are specific to the back-end:

Front-End Interface

The front-end interface will generate a web page in the HyperText Markup Language (HTML). For correctness testing purposes, we are prescribing the output very precisely. Because the output is very narrow (and does not use HTML in complicated ways), you should write your own code to generate the output (i.e., don't use external libraries to generate the output).

Below are the program commands that you must support for the front end. Both generate identical output:

Notes:

Initial State

When grades.bin does not exist, starting the server will result in the file being created with no records. The initial file and the response from ./project2 html are as follows:

A Bit of HTML

The job of HTML is to describe the content that goes into a web page and to provide general information about how it should be rendered. The details of rendering, however, are left to the specific web browser that you are using.

Markup commands in HTML are surrounded by < > pairs. The commands often form a "container" that define both the beginning and end of the formatting command. For example, <B> indicates that bold formatting should start at that point and </B> indicates that bold formatting should stop. Specifically:

this is in bold

is implemented using the HTML code:

<B>this is in bold</B>

Looking at the raw text file above, you will notice certain markup commands

Examples

The following represents a sequence of commands, starting from the initial state. For each step, we link to both the database and html files (all are contained in the distributed tar file).
./project2 append "Project 1" PROJECT 100 89.0

adds the Project 1 record to the database. The quotes in the command line force all of "Project", SPACE and the number one to appear as a single string (as argv[2]). The resulting state is:

Notes:


./project2 append "Project 2" PROJECT 100 85.0

adds the Project 2 record to the database. The resulting state is:


./project2 invalid 0

Changes record 0 to be invalid. The resulting state is:


./project2 append "Project 1 (new project assignment)" PROJECT 110 98.0

adds the Project 1 (new project assignment) record to the database. The resulting state is:

Notes:


./project2 append "Midterm exam" EXAM 137 113.0

adds the midterm exam record to the database. The resulting state is:


Testing Your Code

Back-End

Front-End


Submitting Your Program


Grading Criteria


Downloads

The following file contains the record.h header file and a number of example tests: project2_dist.tar

Automated Testing

The testing procedure that we are using is the same as in Project 0.


Hints


Addenda


andrewhfagg at gmail.com

Last modified: Tue Oct 6 16:38:30 2020