December 4th, 2004, 04:39 AM
Something like this, is it?
so convert it into a list of lists!
December 4th, 2004, 04:47 AM
did u get that Jack?
December 4th, 2004, 05:18 AM
arg i feel so stupid.. what am i suppose to do with that?
December 4th, 2004, 05:51 AM
This should clear things up... hopefully...
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 updated (or added if they aren't already there).
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:
This is what they suggested us to do..
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.
7.Modify the program so it always appends the new data to the end of the list (even if the user is already in the system).
8.Modify the program so it check s to if the user is already there. If they are, overwrite the old data instead of creating a new entry.
9.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.
10.Check the XHTML produced by all of the pages to make sure it's valid.
I think all i need to get the program to output the grades after entering 165 then i hsould be fine...
December 4th, 2004, 06:04 AM
I'm don't know anything abt XHTML When do you've to submit your project anyway...guess someone around wld help you out! Am feeling bad as I can't help you out... but Jack the python code that you had written out was right The logic and everything else was proper... Guess theres something with the XHTML scripting or soemthing...not sure
December 4th, 2004, 06:14 AM
nonono, dont worry about xhtml.. i ran my old code.. and it said "unscriptbably something" cause of the entry..
if you could help me out with just python and ignore the xhtml, that would be great.. and it's due on monday.. 11:59 pst.. but i just wanna get started since im stuck
December 4th, 2004, 06:27 AM
Am sorry got to leave...sat eve here... Netytan/Grim cld help you out.... calling Moderator n Grim ...help out plss..
Have hope Jack,
December 4th, 2004, 06:32 AM
Noooooo,.... T_T well thanks for your help anyways..
calling 911..rescuers come plz~
December 4th, 2004, 08:08 AM
No-one seems to have mentioned how are you storing the data i.e. in a file? In which case you should post a sample so we know we're working with. Also could you also attach your gradelist module.
Anyway it seems like pretty simple problem so it shouldn't take long to sort out once we have all the details . If you want to contact me via MSN go right ahead.
Is this a homework assignment for college?
December 4th, 2004, 08:11 AM
Sorry for the slow reply New, I've been out of town for a few days but I'm back on the case now .
Originally Posted by NewPythoner
December 4th, 2004, 12:11 PM
I just have a quick question. Why are you doing input("Administration Password: ")? Input is for integers raw_input is for strings. Are you using input because you are assuming the user will always enter numbers for the password?
December 4th, 2004, 03:34 PM
Yay backup has arrived
okok so here's the gradelist module..
and yea im using input instead of raw because im expecting the pw will be a number.
filename = "grades.data"
Write the data from gradelist to a file.
This overwrites any data currently in the file.
# check the passed data to ensure it's the right type
raise("write: gradelist isn't a list.")
num = 0
for entry in gradelist:
raise("write: Entry "+ str(num) + " isn't a list.")
raise("write: Entry "+ str(num) + " is wrong length.")
raise("write: Userid in entry "+ str(num) + " isn't a string.")
raise("write: Grade in entry "+ str(num) + " isn't an integer.")
raise("write: Comment in entry "+ str(num) + " isn't a string.")
# let the pickle module do the hard work...
fh = open(filename, "w")
Read the gradelist file and return the list.
# open the file and load the data
fh = open(filename, "r")
gradelist = pickle.load(fh)
# check the loaded data to ensure it's the right type
raise("read: Stored data isn't a list.")
num = 0
for entry in gradelist:
raise("read: Entry "+ str(num) + " isn't a list.")
raise("read: Entry "+ str(num) + " is wrong length.")
raise("read: Userid in entry "+ str(num) + " isn't a string.")
raise("read: Grade in entry "+ str(num) + " isn't an integer.")
raise("read: Comment in entry "+ str(num) + " isn't a string.")
December 4th, 2004, 06:14 PM
K so right now i have
and when i type in 165, it outputs "None".. why is that? I have the gradelist module saved in the same folder as my program.. what's wrong?
data = gradelist.read()
x = input("Administration Password: ")
if x == 165:
print "Wrong Password"
December 4th, 2004, 06:20 PM
Hmm i think i know what' wrong.. is it because i haven't gotten the program to read the data file? how do i do that?
December 4th, 2004, 06:42 PM
K cool, I figured out how to output the users in data.. sweeeeeeet