Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 39 lines (29 sloc) 1 KB
# Save user's score for completing level
# NOTE TO SELF how do we prevent people from just posting scores to this
# URL that they didn't actually earn?
from database_tables import Level, Score
from webserver_utils import verify_id
import cgi
import cgitb
import datetime
q = cgi.FieldStorage()
levelName = q.getfirst("levelName", "")
completionTime = q.getfirst("completionTime", "")
player = verify_id()
print "Content-type: text/html"
if (levelName != "" and completionTime != ""):
levels = Level.selectBy(name = levelName)
if levels.count() > 0:
level = levels[0]
score = Score(level = level,
player = player,
completionTime = int(completionTime),
achievedOn =
print "Saved score %d for %s on %s." % (int(completionTime),,
print "No such level as %s" % levelName
print "Required info not provided."