WIP. fix for ambiguous assignment id
This commit is contained in:
parent
ac96bbff64
commit
a9f82a5feb
2 changed files with 28 additions and 2 deletions
|
@ -197,6 +197,14 @@ class Assignment(Base):
|
|||
values['turk_country_code'] = None
|
||||
return values
|
||||
|
||||
def getOriginalAssignmentId(self):
|
||||
"""
|
||||
Initial assumption: assignmentId would be unique for each worker. But it is not.
|
||||
Hence assignment_id now gets the value assigmentId_workerId (confusing to say the least!)
|
||||
Sometimes we want to recover the assignment id from this combination
|
||||
"""
|
||||
return self.assignment_id.split('_')[0]
|
||||
|
||||
class Store:
|
||||
def __init__(self, db_filename, logLevel=0):
|
||||
path = os.path.abspath(db_filename)
|
||||
|
|
|
@ -309,6 +309,24 @@ class DrawPageHandler(tornado.web.RequestHandler):
|
|||
try:
|
||||
hit_id = int(self.get_query_argument('id'))
|
||||
if hit_id != self.store.currentHit.id:
|
||||
assignmentId = self.get_query_argument('assignmentId', '')
|
||||
orig_assigmentId = assignmentId
|
||||
if len(assignmentId):
|
||||
assignmentId += '_' + str(self.get_query_argument('workerId', ''))
|
||||
hit = self.store.getHitById(hit_id)
|
||||
assignment = hit.getAssignmentById(assignmentId)
|
||||
if not assignment:
|
||||
self.write("Invalid HIT or assignment id")
|
||||
return
|
||||
submitUrl = self.get_query_argument('turkSubmitTo', '')
|
||||
submitUrl += '/mturk/externalSubmit'
|
||||
self.write("An error occured. Please re-submit your assignment validation code. We're really sorry for the inconvenience.")
|
||||
self.write(f"<form method='post' action='{submitUrl}'>")
|
||||
self.write(f"<input type='text' name='assignmentId' value='{orig_assigmentId}'>")
|
||||
self.write(f"<input type='text' name='surveycode' value='{assignment.uuid}'>")
|
||||
self.write(f"<input type='submit' value='Submit finished assignment'>")
|
||||
self.write("</form>")
|
||||
|
||||
self.write("Invalid HIT")
|
||||
return
|
||||
hit = self.store.currentHit
|
||||
|
@ -320,7 +338,7 @@ class DrawPageHandler(tornado.web.RequestHandler):
|
|||
return
|
||||
|
||||
assignmentId = self.get_query_argument('assignmentId', '')
|
||||
if len(assignmentId):
|
||||
if len(assignmentId) and assignmentId != "ASSIGNMENT_ID_NOT_AVAILABLE":
|
||||
assignmentId += '_' + str(self.get_query_argument('workerId', ''))
|
||||
|
||||
if len(assignmentId) < 1:
|
||||
|
@ -360,7 +378,7 @@ class DrawPageHandler(tornado.web.RequestHandler):
|
|||
.replace("{TOP_PADDING}", str(self.top_padding))\
|
||||
.replace("{LEFT_PADDING}", str(self.left_padding))\
|
||||
.replace("{SCRIPT}", '' if previewOnly else '<script type="text/javascript" src="/assignment.js"></script>')\
|
||||
.replace("{ASSIGNMENT}", '' if previewOnly else str(assignmentId)) # TODO: fix unsafe inserting of GET variable
|
||||
.replace("{ASSIGNMENT}", '' if previewOnly else str(assignment.getOriginalAssignmentId())) # TODO: fix unsafe inserting of GET variable
|
||||
|
||||
self.write(contents)
|
||||
|
||||
|
|
Loading…
Reference in a new issue