任何人都可以提供一个关于如何使用boto的mturk create_qualification_type的基本示例吗?请提供有效answer_key_xml的示例。
或者请指出一些带有示例的文档。官方documentation不是很有帮助。
谢谢!
答案 0 :(得分:2)
这是一个使用boto 2创建资格测试的示例。应该有一种使用boto创建答案密钥的方法,而不是编写XML,但我还没有找到它。
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,
)
答案 1 :(得分:1)
以下是资格测试问题的示例(它是为审核基本编程/代码阅读技巧而创建的):
<?xml version="1.0" encoding="UTF-8"?>
<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
<Overview>
<Title>Trivia Test Qualification</Title>
</Overview>
<Question>
<QuestionIdentifier>question1</QuestionIdentifier>
<QuestionContent>
<Text>The following code will allow the program to obtain a name from the keyboard:</Text>
<Text>String name = Console.readLine("Enter name"):</Text>
</QuestionContent>
<AnswerSpecification>
<SelectionAnswer>
<StyleSuggestion>radiobutton</StyleSuggestion>
<Selections>
<Selection>
<SelectionIdentifier>true</SelectionIdentifier>
<Text>True</Text>
</Selection>
<Selection>
<SelectionIdentifier>false</SelectionIdentifier>
<Text>False</Text>
</Selection>
</Selections>
</SelectionAnswer>
</AnswerSpecification>
</Question>
<Question>
<QuestionIdentifier>question2</QuestionIdentifier>
<QuestionContent>
<Text>The method length( ) will return an integer which represents the length of a string value.</Text>
</QuestionContent>
<AnswerSpecification>
<SelectionAnswer>
<StyleSuggestion>radiobutton</StyleSuggestion>
<Selections>
<Selection>
<SelectionIdentifier>true</SelectionIdentifier>
<Text>True</Text>
</Selection>
<Selection>
<SelectionIdentifier>false</SelectionIdentifier>
<Text>False</Text>
</Selection>
</Selections>
</SelectionAnswer>
</AnswerSpecification>
</Question>
<Question>
<QuestionIdentifier>question3</QuestionIdentifier>
<QuestionContent>
<Text>The name of a variable is known as its:</Text>
</QuestionContent>
<AnswerSpecification>
<SelectionAnswer>
<StyleSuggestion>radiobutton</StyleSuggestion>
<Selections>
<Selection>
<SelectionIdentifier>1</SelectionIdentifier>
<Text>Identifier</Text>
</Selection>
<Selection>
<SelectionIdentifier>2</SelectionIdentifier>
<Text>Constant</Text>
</Selection>
<Selection>
<SelectionIdentifier>3</SelectionIdentifier>
<Text>Data Type</Text>
</Selection>
<Selection>
<SelectionIdentifier>4</SelectionIdentifier>
<Text>Base</Text>
</Selection>
</Selections>
</SelectionAnswer>
</AnswerSpecification>
</Question>
<Question>
<QuestionIdentifier>question4</QuestionIdentifier>
<QuestionContent>
<Text>All variables must be declared before they can be used?</Text>
</QuestionContent>
<AnswerSpecification>
<SelectionAnswer>
<StyleSuggestion>radiobutton</StyleSuggestion>
<Selections>
<Selection>
<SelectionIdentifier>true</SelectionIdentifier>
<Text>True</Text>
</Selection>
<Selection>
<SelectionIdentifier>false</SelectionIdentifier>
<Text>False</Text>
</Selection>
</Selections>
</SelectionAnswer>
</AnswerSpecification>
</Question>
<Question>
<QuestionIdentifier>question5</QuestionIdentifier>
<QuestionContent>
<Text>Array indexing always starts with the number</Text>
</QuestionContent>
<AnswerSpecification>
<SelectionAnswer>
<StyleSuggestion>radiobutton</StyleSuggestion>
<Selections>
<Selection>
<SelectionIdentifier>0</SelectionIdentifier>
<Text>0</Text>
</Selection>
<Selection>
<SelectionIdentifier>1</SelectionIdentifier>
<Text>1</Text>
</Selection>
<Selection>
<SelectionIdentifier>2</SelectionIdentifier>
<Text>2</Text>
</Selection>
<Selection>
<SelectionIdentifier>/0</SelectionIdentifier>
<Text>/0</Text>
</Selection>
</Selections>
</SelectionAnswer>
</AnswerSpecification>
</Question>
</QuestionForm>
以下是答案的一个例子:
<?xml version="1.0" encoding="UTF-8"?>
<AnswerKey xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/AnswerKey.xsd">
<Question>
<QuestionIdentifier>question1</QuestionIdentifier>
<AnswerOption>
<SelectionIdentifier>true</SelectionIdentifier>
<AnswerScore>10</AnswerScore>
</AnswerOption>
</Question>
<Question>
<QuestionIdentifier>question2</QuestionIdentifier>
<AnswerOption>
<SelectionIdentifier>true</SelectionIdentifier>
<AnswerScore>10</AnswerScore>
</AnswerOption>
</Question>
<Question>
<QuestionIdentifier>question3</QuestionIdentifier>
<AnswerOption>
<SelectionIdentifier>1</SelectionIdentifier>
<AnswerScore>10</AnswerScore>
</AnswerOption>
</Question>
<Question>
<QuestionIdentifier>question4</QuestionIdentifier>
<AnswerOption>
<SelectionIdentifier>true</SelectionIdentifier>
<AnswerScore>10</AnswerScore>
</AnswerOption>
</Question>
<Question>
<QuestionIdentifier>question5</QuestionIdentifier>
<AnswerOption>
<SelectionIdentifier>0</SelectionIdentifier>
<AnswerScore>10</AnswerScore>
</AnswerOption>
</Question>
<QualificationValueMapping>
<PercentageMapping>
<MaximumSummedScore>50</MaximumSummedScore>
</PercentageMapping>
</QualificationValueMapping>
</AnswerKey>
希望有所帮助!