Hier ist ein Beispiel, das einen Qualifikationstest mit Boto 2 erstellt. Es sollte eine Möglichkeit geben, einen Antwortschlüssel mit Boto zu erstellen, anstatt XML zu schreiben, aber ich habe es nicht gefunden.
from boto.mturk.connection import MTurkConnection
from boto.mturk.question import AnswerSpecification, SelectionAnswer
from boto.mturk.question import Question, QuestionContent, QuestionForm
from boto.mturk.question import FormattedContent, Overview
AWS_ACCESS_KEY_ID = 'PUT YOUR AWS KEY ID HERE'
AWS_SECRET_ACCESS_KEY = 'PUT YOUR AWS ACCESS KEY HERE'
questions = []
answers = []
# Question 1
questionContent = QuestionContent()
questionContent.append_field('Title', 'What is your favorite meme?')
questionContent.append(
FormattedContent('<p>Make sure to think this through!</p>')
)
questionAnswer = AnswerSpecification(SelectionAnswer(
min=1,
max=1,
style='radiobutton',
selections=[
('Good Guy Greg', 0),
('Scumbag Steve', 1),
('Success Kid', 2)
],
))
questions.append(Question(
identifier='q1',
content=questionContent,
answer_spec=questionAnswer,
is_required=True,
))
answers.append("""\
<Question>
<QuestionIdentifier>q1</QuestionIdentifier>
<AnswerOption>
<SelectionIdentifier>2</SelectionIdentifier>
<AnswerScore>60</AnswerScore>
</AnswerOption>
</Question>
""")
# Question 2
questionContent = QuestionContent()
questionContent.append_field(
'Title',
'Complete the name of this meme: Socially Awkward ___ ?'
)
questionAnswer = AnswerSpecification(SelectionAnswer(
min=1,
max=1,
style='radiobutton',
selections=[
('Adult', 0),
('Penguin', 1),
('Doge', 2)
],
))
questions.append(Question(
identifier='q2',
content=questionContent,
answer_spec=questionAnswer,
is_required=True,
))
answers.append("""\
<Question>
<QuestionIdentifier>q2</QuestionIdentifier>
<AnswerOption>
<SelectionIdentifier>1</SelectionIdentifier>
<AnswerScore>40</AnswerScore>
</AnswerOption>
</Question>
""")
# Make the overall question form
testForm = QuestionForm()
overview = Overview()
overview.append_field('Text', 'This test is hard but fair. Try it!')
testForm.append(overview)
for q in questions:
testForm.append(q)
# Make the answer key XML
answerKey = '<AnswerKey xmlns="%s">\n' % (
'http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/AnswerKey.xsd'
)
answerKey += ''.join(answers)
answerKey += """\
<QualificationValueMapping>
<PercentageMapping>
<MaximumSummedScore>100</MaximumSummedScore>
</PercentageMapping>
</QualificationValueMapping>
</AnswerKey>
"""
name = 'My Special Qualification'
description = 'My HITS require you to know your memes.'
mtc = MTurkConnection(
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
host='mechanicalturk.sandbox.amazonaws.com',
)
mtc.create_qualification_type(
name,
description,
status='Active',
keywords=['memes', 'fun'],
retry_delay=120,
test=testForm,
answer_key=answerKey,
test_duration=3600,
auto_granted=False,
)
sollten Sie angeben, was Sie gerade versuchen, oder eine verkürzte Version, die zeigt, dass es nicht funktioniert – Vorsprung