Beispiel #1
0
 def get_agent_work_status(self, assignment_id):
     client = get_mturk_client(self.is_sandbox)
     try:
         response = client.get_assignment(AssignmentId=assignment_id)
         return response['Assignment']['AssignmentStatus']
     except ClientError as e:
         if 'This operation can be called with a status of: Reviewable,Approved,Rejected' in e.response['Error']['Message']:
             return ASSIGNMENT_NOT_DONE
Beispiel #2
0
 def email_worker(self, worker_id, subject, message_text):
     client = get_mturk_client(self.is_sandbox)
     response = client.notify_workers(Subject=subject,
                                      MessageText=message_text,
                                      WorkerIds=[worker_id])
     if len(response['NotifyWorkersFailureStatuses']) > 0:
         return {
             'failure':
             response['NotifyWorkersFailureStatuses'][0]
             ['NotifyWorkersFailureMessage']
         }
     else:
         return {'success': True}
Beispiel #3
0
    def pay_bonus(self, worker_id, bonus_amount, assignment_id, reason, unique_request_token):
        total_cost = calculate_mturk_cost(payment_opt={'type': 'bonus', 'amount': bonus_amount})
        if not check_mturk_balance(balance_needed=total_cost, is_sandbox=self.is_sandbox):
            print("Cannot pay bonus. Reason: Insufficient fund in your MTurk account.")
            return False

        client = get_mturk_client(self.is_sandbox)
        client.send_bonus(
            WorkerId=worker_id,
            BonusAmount=str(bonus_amount),
            AssignmentId=assignment_id,
            Reason=reason,
            UniqueRequestToken=unique_request_token # Could be useful in the future, for handling network errors
        )

        return True
Beispiel #4
0
 def block_worker(self, worker_id, reason):
     client = get_mturk_client(self.is_sandbox)
     client.create_worker_block(WorkerId=worker_id, Reason=reason)
Beispiel #5
0
 def reject_work(self, assignment_id, reason):
     client = get_mturk_client(self.is_sandbox)
     client.reject_assignment(AssignmentId=assignment_id, RequesterFeedback=reason)
Beispiel #6
0
 def approve_work(self, assignment_id):
     client = get_mturk_client(self.is_sandbox)
     client.approve_assignment(AssignmentId=assignment_id)