正在从 Sandbox HIT returns 空 xml 字典中检索结果

Retrieving results from Sandbox HIT returns empty xml dictionary

我正在尝试在 Amazon Mechanical Turk 上创建一个实验。我从那里借用了代码。它运行没有错误,但是 returns 是一个空数组。代码是:

import boto3
import xmltodict

MTURK_SANDBOX = 'https://mturk-requester-sandbox.us-east-1.amazonaws.com'
MTURK_PROD = 'https://mturk-requester.us-east-1.amazonaws.com'
mturk = boto3.client('mturk',
   aws_access_key_id = "key",
   aws_secret_access_key = "secret_key",
   region_name='us-east-1',
   endpoint_url = MTURK_SANDBOX
)

# Read in the questions.xml file saved in the same directory
question = open(file='questions.xml',mode='r', encoding='utf-8').read()
new_hit = mturk.create_hit(
    Title = 'Map the following question to the paragraph/content where the answer to the question may lie.',
    Description = 'Please review the following content to figure out where the answer to the posted question may reside',
    Keywords = 'images, quick, labeling',
    Reward = '0.00',
    MaxAssignments = 1,
    LifetimeInSeconds = 1728,
    AssignmentDurationInSeconds = 600,
    AutoApprovalDelayInSeconds = 14400,
    Question = question,
    AssignmentReviewPolicy={
        'PolicyName':'ScoreMyKnownAnswers/2011-09-01',
        'Parameters':[
            {'Key':'AnswerKey', 'MapEntries':[{'Key': 'question_1', 'Values':['yes']}]},
            {'Key': 'ApproveIfKnownAnswerScoreIsAtLeast', 'Values':['1']},
            {'Key': 'RejectIfKnownAnswerScoreIsLessThan', 'Values':['1']},{'Key': 'RejectReason', 'Values':['Sorry, we could not approve your submission as you did not correctly identify the image containing the Flamingo.']},
            {'Key': 'ExtendIfKnownAnswerScoreIsLessThan','Values':['1']}
    ]}
)

print("A new HIT has been created. You can preview it here:")
print(new_hit['HIT']['HITGroupId'])
print("https://workersandbox.mturk.com/mturk/preview?groupId=" + str(new_hit['HIT']['HITGroupId']))

# Retrive results
# Use the hit_id previously created
hit_id = new_hit['HIT']['HITId']
# We are only publishing this task to one Worker
# So we will get back an array with one item if it has been completed
worker_results = mturk.list_assignments_for_hit(HITId=hit_id, AssignmentStatuses=['Submitted'])
print(worker_results)

其中 questions.xml 看起来像:

<HTMLQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2011-11-11/HTMLQuestion.xsd">
<HTMLContent><![CDATA[
<!-- YOUR HTML BEGINS -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
<script type='text/javascript' src='https://s3.amazonaws.com/mturk-public/externalHIT_v1.js'></script>
</head>
<body>
<form name='mturk_form' method='post' id='mturk_form' action='https://www.mturk.com/mturk/externalSubmit'><input type='hidden' value='' name='assignmentId' id='assignmentId'/>
<h2>Is this Tweet happy, angry, excited, scared, annoyed or upset? Type in one word to describe the main emotion in the message. If it is unclear, type in "unclear".</h2>
<h3> Tweet: "I am really looking forward to the next Seahawks game!"</h3>
<div>
  <input type='text' name='reported_emotion' placeholder='Type in your answer here'>
</div>
<p><input type='submit' id='submitButton' value='Submit' /></p></form>
<script language='Javascript'>turkSetAssignmentID();</script>
</body></html>
<!-- YOUR HTML ENDS -->
]]>
</HTMLContent>
<FrameHeight>600</FrameHeight>
</HTMLQuestion>

然后我完成and。使用我创建的 MTurk 工作人员帐户接受 HIT。我作为 worker_results 得到的 xml 字典是:

{'NumResults': 0, 'Assignments': [], 'ResponseMetadata': {'RequestId': '29d88641-ce06-4734-9fd4-b8ac8cb02d03', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': '29d88641-ce06-4734-9fd4-b8ac8cb02d03', 'content-type': 'application/x-amz-json-1.1', 'content-length': '33', 'date': 'Mon, 31 Aug 2020 17:37:51 GMT'}, 'RetryAttempts': 0}}

这不应该至少在前两个条目中显示值吗?

您的代码正在运行。在工作人员接受并提交您的 HIT 之前,Assignments 字段将保持空白。