def submit_edit_submission(request,submission_id,worker): print "SUBMIT RESULTS" old_submission=get_object_or_404(SubmittedTask,id=submission_id,worker=worker) workitem = old_submission.hit; session = workitem.session; assignmentId="INTERNAL" postS=pickler.dumps((request.GET,request.POST)) submission=SubmittedTask(hit=workitem,session_id=session.id,worker=worker,assignment_id=assignmentId, response=postS); submission.revision=old_submission.revision+1; submission.state=old_submission.state; submission.approval_state=old_submission.approval_state; submission.save(); session.task_def.type.get_engine().on_deactivate(old_submission); old_submission.valid=0; old_submission.revision_state=2; old_submission.save(); session.task_def.type.get_engine().on_submit(submission); ros_integration.on_submission(submission) (worker,created)=Worker.objects.get_or_create(session=None,worker=worker) if created: worker.save(); if session.is_gold: re_grade_submission_with_gold(session,old_submission,submission,worker) return render_to_response('mturk/edit_complete.html')
def submit_result(request): try: task_id="" if 'ExtID' in request.REQUEST: task_id=request.REQUEST['ExtID'] if task_id=="" and 'extid' in request.REQUEST: task_id=request.REQUEST['extid'] except: if 'extid' in request.REQUEST: task_id=request.REQUEST['extid'] print request.POST workitem = get_object_or_404(MTHit,ext_hitid=task_id) #The HIT can belong to some other session session = workitem.session; session_code=session.code; workerId=request.REQUEST['workerId']; if workerId=="": workerId=request.user.username; assignmentId=request.REQUEST['assignmentId']; postS=pickler.dumps((request.GET,request.POST)) submission=SubmittedTask(hit=workitem,session_id=session.id,worker=workerId,assignment_id=assignmentId, response=postS); submission.save(); if 'hitId' in request.REQUEST: mturk_hit_id=request.REQUEST['hitId'] try: mthit=MechTurkHit.object.get(mechturk_hit_id=mturk_hit_id); except: mthit=None; if mthit: mthit.state=2; #Review mthit.save(); session.task_def.type.get_engine().on_submit(submission); #num_possibly_valid_submissions=SubmittedTask.objects.filter(hit=workitem,valid=True).count(); #if num_possibly_valid_submissions>=workitem.get_num_required_submissions(): workitem.state=2; #Submitted workitem.save() print "ROS ON SUBMISSION" ros_integration.on_submission(submission) (worker,created)=Worker.objects.get_or_create(session=None,worker=workerId) if created: worker.save(); print "GOLD?",session.is_gold,session.code if session.is_gold: print "GOLD" finalize_item_substitution(workitem,worker) grade_submission_with_gold(session,submission,worker) else: check_submission_for_progress(session,submission,worker) if session.standalone_mode: return HttpResponseRedirect("/mt/get_task/"+session.code+"/" ); if session.sandbox: submit_target="http://workersandbox.mturk.com/mturk/externalSubmit" else: submit_target="http://www.mturk.com/mturk/externalSubmit" return render_to_response('mturk/after_submit.html', {'submit_target':submit_target, 'extid': workitem.ext_hitid, 'workerId':workerId, 'assignmentId':assignmentId });