Example #1
0
    def handle(self, *args, **options):
	    mtc = mturk.connect()
	    parts = Participant.objects.filter(group='mturk')
	    for p in parts:
		    treat = p.treatment
		    if not p.base_pay:
			    if p.passed_quiz:
				    print "Approving " + str(p)
				    p.base_pay = 0.10
				    p.save()
				    mtc.approve_assignment(p.assignmentId, "Thank you for participating!")
			    else:
				    print "Rejecting " + str(p)
				    mtc.reject_assignment(p.assignmentId,
				    "We're sorry, you did not complete the experimental pretest. Send all questions to [email protected]. "+
				    "Include the reference, "+str(p)+ '.')
		    else:
			    print str(p) + " has already been approved."
		    if not p.bonus_pay:
			    if p.ended:
				    amnt = p.experiment.earnings_multiplier * p.earnings
				    print 'Paying a bonus of, ' + amnt + " to " + str(p)
				    p.bonus_pay = amnt
				    p.save()
				    mtc.grant_bonus(p.workerId, p.assignmentId, pay(amnt), 
				    "Thank you for your participation. You earned, " + str(p.earnings) + " tokens in the "+
				    "experiment. Send all questions to [email protected]. Include the reference, " + str(p)+ '.')
		    else:
			    print str(p) + " has already had their bonus paid."
Example #2
0
def approve_hit(hit_id):
	mtc = mturk.connect()
	assignments = mtc.get_assignments(hit_id)
	print "found " + str(len(assignments)) + " assignments."
	for assignment in assignments:
	        parts = Participant.objects.filter(workerId=assignment.WorkerId)
	        if len(parts)==0:
	    	    print "Could not find a participant with workerId, " + str(assignment.WorkerId)
	        elif len(parts)>1:
	    	    print "Found more than one record for workerId, " + str(assignment.WorkerId)
	    	    for p in parts:
	    		    str1 = "Started: " + str(p.started) + " | Ended: " + str(p.ended) + " | Passed Quiz: " + str(p.passed_quiz)
	    		    if p.treatment:
	    			    print str1 + "| Earnings: " + str(p.earnings)
	    		    else:
	    			    print str1 + ", NO TREATMENT"
	    	    ask = raw_input("Which one to use? ")
	    	    approve_p(parts[int(ask)])
	        else:
	    	    approve_p(parts[0])
Example #3
0
def approve_p(p):
	treat = p.treatment
	mtc = mturk.connect()
	result = {
		'already_approved':  0,
		'already_paid_bonus':  0,
		'approved':  0,
		'never_played':  0,
		'rejected':  0,
		'amnt': 0,
		'bonus': 0,
		}
	comm = (" If you have any questions please send them to [email protected]. "+
		    "Your reference number is "+str(p)+ '.')
	link = "http://perceptsconcepts.psych.indiana.edu/trustgame/mturk/"+str(p.workerId)
	
	if not p.base_pay:
		if p.passed_quiz:
		    msg = "Thank you for participating! "
		    if not p.treatment:
			    result['never_played'] = 1
			    msg += "It seems that you didn't have the chance to complete the experiment. You can still go to, " + link + '.'
			    msg += " You can still be paid bonuses of up to $7.20 by completing the experiment!"
		    msg+=comm
		    try:
			mtc.approve_assignment(p.assignmentId, msg)
			print "Approving " + str(p)
			result['approved'] = 1
			p.base_pay = 0.10
			p.save()
		    except:
			result['outstanding'] = 1
		else:
		    msg = "We're sorry, you did not complete the experimental pretest."
		    msg+= comm
		    try:
			mtc.reject_assignment(p.assignmentId,msg)
			print "Rejecting " + str(p)
			result['rejected'] = 1
			p.base_pay = 0.0
			p.save()
		    except:
			result['outstanding'] = 1

	else:
		result['already_approved'] = 1
	if not p.bonus_pay:
		if p.treatment and p.game_state == "completed":
	    	    amnt = p.experiment.earnings_multiplier * p.earnings
	    	    if amnt > 10:
	    		    print "This is too much!"
	    		    print "Not paying, " + str(amnt) + " to " + str(p)
	    	    else:
	    		    print 'Paying a bonus of, ' + str(amnt) + " to " + str(p)
			    result['bonus'] = 1
			    result['amnt'] = amnt
			    msg = "Thank you for your participation! "
			    msg += "You earned " + str(p.earnings) + " tokens in the experiment. "
			    msg += "Even if you feel like you didn't do well as you would have liked, "
			    msg += "most groups however never achieve high levels of trust. "
			    msg += "Your earnings thereby are also a small memento of your "
			    msg += "cooperative spirit. We certainly appreciate it as such. "
			    if not p.survey and p.machiv:
				msg += "Also do you know you haven't taken our exit survey? You can still take it at, " + link + '.'
			    msg += comm
			    mtc.grant_bonus(p.workerId, p.assignmentId, mturk.pay(amnt), msg)
			    p.bonus_pay = amnt
	    	    	    p.save()
	else:
		result['already_paid_bonus'] = 1
	return result
Example #4
0
    def handle(self, *args, **options):
	    method = mturk.connect().expire_hit
	    if len(args) != 1:
		    mturk.get_and_execute(method)
	    else:
		    method(args[0])
Example #5
0
def connect(aws_access_key_id=None, aws_secret_access_key=None, bucket_name=None, sandbox=False):

    mturk_host = "mechanicalturk{0}.amazonaws.com".format(".sandbox" if sandbox else "")
    mturk.connect(host=mturk_host, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
    global bucket
    bucket = S3Connection(aws_access_key_id, aws_secret_access_key).get_bucket(bucket_name)