In this assignment, you will create a simple grade management system. Think of this as an assignment-sized version of WebCT's "Your Grades" feature.

Again, you can have a look at a working grade manager to see how things should work. You can use XHTML code from this if you want.

There are three different programs that you have to write. They each accomplish different aspects of the grade management:

* View all grades: If the user types the correct administrator's password, the program should display a list of all of the students in the system along with their grades and comments.

* View a student's grade: Used to view the grades for a single student. If the given userid isn't in the system, you should display a message saying so.

* Set a student's grade: If the correct administrator's password is given, the student's information should be added.

A few other notes about the programs:

* You don't have to worry about catching errors in the user's input.

* All of your XHTML (including generated XHTML) and CSS must be valid.

* Keep good coding style in mind when creating your programs for this assignment.

* You should make sure that any comments with HTML tags or entities are displayed as code, not interpreted by the browser. The "Displaying HTML Source" example in the Guide handles this—you can handle the comments the same way here.

You can also use the cgi.escape function (from the cgi module) for this. So, to print all of the comments in the file, you might do this:

for entry in data:
print cgi.escape(entry[2])

Storing the List

The programs will have to store all of the grade data in a variable. The entry for a single student will be a list like this:

[ "userid", 10, "Comments" ]

The first entry in the list is the student's userid, the second is their mark (an integer) and the last is a string containing comments.

The entire grade list will be a list of these. So, it's a list of lists and you'll have to work with this data structure. For example, this loop will output the userids of all the students in the grade list grades:

for entry in data:
print entry[0]

Reading and Writing a Data File

You will have to store the data in a file, so it is accessible to the different programs that need it. You don't have to do this yourself; the provided gradelist module does this for you. You should download the source for the module and put it in the same directory as your programs. The module defines these functions:

* gradelist.write(data): Write the data from the grade list data to a file names grades.data in the current directory.

* data = gradelist.read(): Read the data from grades.data and return the grade list.

Once the module file is in your directory, you can use this module the same way as a built-in module: import gradelist .

Note that the argument to the gradelist.write function is the whole data object. So, the way you would use it (if you're modifying the file in some way) is like this:

import gradelist
data = gradelist.read()
... # do something to modify data
gradelist.write(data)

You can also start with a sample data file. This will let you work on the programs that use the data before you complete the program that sets user's grades.

You can experiment with the library and data structure in the Python interpreter:

>>> import gradelist
>>> data = gradelist.read()
>>> print data[0]
['somebody', 75, 'No answer for question 3']
>>> print data[1]
['astudent', 100, 'Very well done.']
>>> for entry in data:
... print entry[0]
...
somebody
astudent

Suggested Plan of Attack

1. Create the initial XHTML page with the forms.

2. Write a program that uses the gradelist module to load the data. Print out all of the userids. This doesn't have to be a web script (yet). Use the sample data file for testing.

3. Modify the program so that it outputs XHTML code and can be used as a web script. Add checking for the administrator's password and an error if it's incorrect.

4. Add printing of the user's mark and comments to this script.

5. Make a copy of the "view all" script and modify it so it only outputs one user's mark. Remove the password checking.

6. Write a program that reads the new grade from the form and outputs it to the XHTML page (so you can confirm that it's there).

7. Modify the program so it appends the new data to the end of the list (even if the user is already in the system).

8. Go back to the two programs that output data and make sure they convert <,> and & to entities. Test this by entering a comment like "Used the <h1> & <h2> tags." The rest of the page shouldn't turn into a heading when this is displayed.

9. Check the XHTML produced by all of the pages to make sure it's valid.

anyone know how this works??? its confusin

Computer/web programming help needed here.

The assignment you mentioned is about creating a simple grade management system using three different programs. The programs are responsible for viewing all grades, viewing a student's grade, and setting a student's grade.

To get started with understanding how this works, you can follow the suggested plan of attack provided in the assignment:

1. Create the initial XHTML page with the forms.
- This involves creating a webpage with forms where the user can interact and perform actions like viewing grades, setting grades, etc.

2. Write a program using the gradelist module to load the data and print out all userids.
- The gradelist module in this case helps in reading and writing data from a file called "grades.data" that stores the grade information.
- You can test this program by using the sample data provided or by modifying the file manually.

3. Modify the program to output XHTML code and add password checking for the administrator.
- This step involves converting the program into a web script and ensuring that the generated XHTML code is valid.
- You will also need to implement password checking to restrict access to certain functionalities.

4. Add printing of the user's mark and comments to the script.
- Modify the program to display the grade and comments of a specific user when requested by the administrator.

5. Create a copy of the "view all" script and modify it to display only one user's mark without password checking.
- This step involves creating a separate program that displays the grade and comments of a single user without requiring a password.

6. Write a program to read the new grade from a form and display it on the XHTML page for confirmation.
- Implement a program that takes input from a form (probably from the administrator), retrieves the new grade information, and displays it on the XHTML page.

7. Modify the program to append the new data to the end of the list, even if the user is already in the system.
- Update the program to handle the addition of new grades, ensuring that the data is correctly added to the existing grade list.

8. Convert special characters like "<", ">", and "&" to entities in the output.
- Make sure that when displaying comments or any other text, special characters are converted to their corresponding HTML entities. This avoids any rendering issues on the webpage.

9. Validate the generated XHTML code for all pages.
- Ensure that all the generated XHTML code is valid by using an XHTML validator tool or service.

Following these steps will help you understand and implement the grade management system. Remember to read and understand the provided grading module (gradelist) for reading and writing data. Feel free to ask if you have any specific questions or need further clarification.