Ejemplo n.º 1
0
def createHits(question, answers, params):
	if SANDBOX:
		mturk_url = 'mechanicalturk.sandbox.amazonaws.com'
		preview_url = 'https://workersandbox.mturk.com/mturk/preview?groupId='
	else:
		mturk_url = 'mechanicalturk.amazonaws.com'
		preview_url = 'https://mturk.com/mturk/preview?groupId='

	#Create Hit Form Structure	
	overview  = Overview()
	overview.append_field('Title', 'We want to know the crowds opinion!')
	overview.append(FormattedContent('<a href="http://programthecrowd.com/">Visit us here</a>'))
	questionContent = QuestionContent()
	questionContent.append_field('Title', question);
	answerChoices = SelectionAnswer(min=1, max=1, style='checkbox', selections=answers, type='text', other=False)
	q = Question(identifier='Help', content=questionContent, answer_spec=AnswerSpecification(answerChoices), is_required=True)
	questionForm = QuestionForm();
	questionForm.append(overview)
	questionForm.append(q)
	hitIdList = []
	global conn
	# key = params['aws_access_key']
	# secret = params['aws_secret_key']
	conn = MTurkConnection(aws_access_key_id='AKIAJBTEJI2RGTJH7OBA', aws_secret_access_key='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', host=mturk_url)
	
	#For Loop to create and post hits
	for i in range(0, NUMBER_OF_HITS):
		create_hit_rs = conn.create_hit(questions=questionForm, lifetime=LIFETIME, max_assignments=NUMBER_OF_ASSIGNMENTS, title=TITLE, keywords=KEYWORDS, reward=REWARD, duration=DURATION, approval_delay=APPROVAL_DELAY, annotation=DESCRIPTION)
		#print(preview_url + create_hit_rs[0].HITTypeId)
		#print("HIT ID: " + create_hit_rs[0].HITId)
		hitIdList.append(create_hit_rs[0].HITId);

	return hitIdList
Ejemplo n.º 2
0
  def generate_hit(self, num_assignments, hit_duration, hit_reward):
    """
    Purpose: Generate and publish the HIT
    Parameters: num_assignments is the number of avaliable assignments for hit, 
                hit_duration is the duration of the hit in seconds (60*5 for 5 minutes),
                hit_reward is the reward given per hit in dollars (0.05 is 5 cents)
    """
    # CONNECT TO MTURK

    mtc = MTurkConnection(aws_access_key_id = self.access_id,
                      aws_secret_access_key = self.secret_key,
                      host = self.host)

    # BUILD OVERVIEW 
     
    overview = Overview()

    overview.append_field('Title', 'The following one or more sentences constitute an incomplete story.')
    story = ""
    for sentence in self.story_sentences:
      story += sentence + " "
    overview.append(FormattedContent(story))
  
    # BUILD QUESTION 1: Copy the first sentence of the story 
     
    qc1 = QuestionContent()
    qc1.append_field('Title','Copy verbatim the first sentence of the provided incomplete story. Please keep all capitalization and punctuation as given. Your sumbission will automatically be rejected if any character is incorrect.')
    fta1 = FreeTextAnswer()
    q1 = Question(identifier='verify_sentence', content = qc1, answer_spec = AnswerSpecification(fta1), is_required = True)

    # BUILD QUESTION 2: Vote on the best sentence to continue the story
    
    sentence_options = []
    for i, sentence in enumerate (self.vote_sentences):
      selection = (sentence, str(i))
      sentence_options.append(selection)
    qc2 = QuestionContent()
    qc2.append_field('Title','Choose the best sentence to continue the story.')
    fta2 = SelectionAnswer(min=1, max=1,style='radiobutton',
                      selections=sentence_options,
                      type='text',
                      other=False)
    q2 = Question(identifier='vote_sentence', content = qc2, answer_spec = AnswerSpecification(fta2), is_required = True)

    # BUILD THE QUESTION FORM 
     
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
     
    # CREATE THE HIT 
     
    mtc.create_hit(questions = question_form,
                   max_assignments = num_assignments,
                   title = self.title,
                   description = self.description,
                   keywords = self.keywords,
                   duration = hit_duration,
                   reward = hit_reward)
    def __generate_qualification_test(self, question_data, num_correct, title):
        '''
            Returns a QuestionForm and AnswerKey for a qualification test from a list of sentence dictionaries.
                question_data : json object containing all the questions.
        '''

        # Get question and answer data
        questions = map(lambda (i,x): self.__generate_qualification_question(x,i), enumerate(question_data))
        answers = map(lambda (i,x): x["answer_key_"+str(i)], enumerate(questions))

        answer_key = self.__generate_answer_key(answers, num_correct, len(question_data))

        # Create form setup
        qual_overview = Overview()
        qual_overview.append_field("Title", title)

        # Instructions
        qual_overview.append(FormattedContent("<h1>Please answer all the questions below.</h1>"))
        qual_overview.append(FormattedContent("<h2>For each question, please choose either the left or right image \
            which you think is more beautiful in terms of its composition. Hints: Please make your decision based on\
            several 'rules of thumb' in photography, such as rule of thirds, visual balance and golden ratio. \
            You may also make your decision by judging which image contains less unimportant or distracting contents.</h2>"))

        # Create question form and append contents
        qual_form = QuestionForm()
        qual_form.append(qual_overview)

        for q in questions:
            i = q["question_num"]
            qual_form.append(q["question_"+str(i)])

        return (qual_form, answer_key)
Ejemplo n.º 4
0
def createHIT2(possibleAnswers,sentence, context):
	title = 'Pick the best translation!'
	description = ('Pick the best translation!')
	keywords = 'translate, language'

	ratingsDic = {}
	ratings = []
	i = 0
	for answer in possibleAnswers:
		ratings.append((answer,i))
		ratingsDic[i] = answer
		i = i + 1
	 
	#---------------  BUILD OVERVIEW -------------------
	 
	overview = Overview()
	overview.append_field('Title', title)
	overview.append(FormattedContent('<p>' + context + '</p>' + '<p><b>' + sentence + '</b></p>'))
	 
	 
	#---------------  BUILD QUESTION 2 -------------------
	 
	qc1 = QuestionContent()
	qc1.append_field('Title','Please pick the best translation for the bolded sentence above.')
	 
	fta1 = SelectionAnswer(min=1, max=1,style='radiobutton',
                      selections=ratings,
                      type='text',
                      other=False)
 
	q1 = Question(identifier='pick',
              content=qc1,
              answer_spec=AnswerSpecification(fta1),
              is_required=True)
	 
	#--------------- BUILD THE QUESTION FORM -------------------
	 
	question_form = QuestionForm()
	question_form.append(overview)
	question_form.append(q1)

	#--------------- CREATE QUALIFICATION REQUIREMENT -------------------
	qual_req = Requirement(qualification_type_id=QUALIFICATION_ID,
					comparator="Exists")
	
	quals = Qualifications(requirements=[qual_req]) 
	#--------------- CREATE THE HIT -------------------
	 
	resultSet = mtc.create_hit(questions=question_form,
				   max_assignments=HIT2_MAX_ASSIGN,
				   title=title,
				   description=description,
				   keywords=keywords,
				   duration = 60*5,
				   reward=0.50,
				   qualifications=quals)

	
	return (resultSet[0].HITId,ratingsDic)
Ejemplo n.º 5
0
def post_HIT1(ACCESS_ID,SECRET_KEY,HOST,url_to_task):
    mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                      aws_secret_access_key=SECRET_KEY,
                      host=HOST)
 
    title = 'Dev deploying simulation test Report From SERVER'
    description = ('Report on events in a simulation')
    keywords = 'website, rating, opinions'
    instructions=('<p>You will take part in a web-based experiment where you will watch a simple simulation and provide reports on events</p>'
                 '<p>Instructions:</p>'
                  '<p>1. Click the link below, which will open the webpage in a new window in your browser</p>'
                  '<p>2. Follow the instructions on the website</p>'
                  '<p>3. Once you have completed your work, you will receive a Reward Code</p>'
                  '<p>4. Return to the mechanical turk webpage and enter your code in the Reward Code text box</p>'
                  '<p>5. Your work will then be checked, after which you will receive your payment</p>'
                  '<br/>CLICK "ACCEPT HIT" BEFORE FOLLOWING LINK'
                  '<br/>YOU WILL NOT BE PAID WITHOUT ACCEPTING THE HIT')
                    
                    
    #---------------  BUILD OVERVIEW -------------------
     
    overview = Overview()
    overview.append_field('Title', description)
    overview.append(FormattedContent(instructions))
    overview.append(FormattedContent('<p>Click "Accept HIT" then click this link <a target="_blank"'
                                     ' href="'+url_to_task+'">'
                                     ' Link to task</a></p>'))
 
    #---------------  BUILD QUESTION 1 -------------------
     
    qc1 = QuestionContent()
    qc1.append_field('Title','Enter reward code here:')
     
    fta1 = FreeTextAnswer(num_lines=1)
    
    q1 = Question(identifier='reward_code',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)
     
     
    #--------------- BUILD THE QUESTION FORM -------------------
     
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    
     
    #--------------- CREATE THE HIT -------------------
     
    mtc.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration = 60*5,
                   reward=0.05)
Ejemplo n.º 6
0
def launchHIT(mtc, drawing_id, payment, title):

  #title = 'Add a single line to this drawing: easy!'
  description = ('We need your help to make the best art possible!')
  keywords = 'drawing, web, art, research, paint, creative, easy, simple, fast'
  choices = [('done','done')]
  drawing_id = "http://2.distributeddrawing.appspot.com/" + drawing_id
  #------------------- Overview ---------------------
  overview_content = ("<p>Your task is to follow the link and draw a single line stroke in the box shown.  It's Easy! Just left-click in the box and drag your cursor around to create your stroke (just like in MS Paint).</p>"
                      '<p>BUT...try to add something to the picture.  If the square is blank, start off the image with something cool.  If there is already an image going, add something that makes it better.</p>'
                      '<p>Help us make some great drawings!</p>'
                      '<ul>'
                      '<li><b>Get started: </b>  <a href=" ' + drawing_id + '" target="_blank">Click here</a> </li>'
                      '</ul>')


  overview = Overview()
  overview.append_field('Title', 'Draw a line in the box to complete the task.')
  overview.append(FormattedContent( overview_content))

  #------------------- Question test ---------------------

  #urlContent = '<a target="_blank" href="http://www.toforge.com"> Canvas </a>'

  qc1 = QuestionContent()
  qc1.append_field('Title','Click on the submit button once you have finished the task.')
  qc1.append(FormattedContent('The payment will not be authorized if you have not completed the task.  Also, you can only complete this task once (all subsequent submissions will be rejected).'))

  answers = SelectionAnswer(min=1, max=1,style='dropdown',
                        selections=choices,
                        type='text',
                        other=False)

  #question1 = ExternalQuestion(external_url='http://distributeddrawing.appspot.com/',frame_height=400)

  q1 = Question(identifier='task',
                content=qc1,
                answer_spec=AnswerSpecification(answers),
                is_required=True)

  #------------------- Question form creation ---------------------

  questionForm = QuestionForm()
  questionForm.append(overview)
  questionForm.append(q1)

  #------------------- HIT creation ---------------------

  return mtc.create_hit(question=questionForm,
                 max_assignments=1,
                 lifetime=datetime.timedelta(days=1),
                 title=title,
                 description=description,
                 keywords=keywords,
                 duration = 60*5,
                 reward=payment,
                 response_groups=['Minimal'])
def create_question_form(mtc, uuid, url):
    title = 'Bovid Labs HIT v2017.07.31 - %(uuid)s' % vars()
    description = ('Help us extract a polygon from this research image.')
    keywords = 'image, extraction, gimp'

    overview = Overview()
    overview.append_field('Title', 'Instructions')

    # Overview text is where we'll put the details about the HIT
    # img previews the tooth image
    # a allows user to download the image and save as

    text = """
      <p>Your job is to extract the outline of the tooth in the following image.</p>
      
      <p>You need to install the current version of Gimp on your computer. It can
      be downloaded from
      <a href="https://www.gimp.org/downloads/">https://www.gimp.org/downloads/</a></p>

      <p>We have prepared a video at <a href="https://www.youtube.com/watch?v=nzxZqIp3XZY">
      https://www.youtube.com/watch?v=nzxZqIp3XZY</a> showing how to do the task. Once you have extracted
      the outline, you will upload the final result (file) to this HIT.
      </p>
      
      <p>For the HIT to be complete, you must upload a the black polygon against
      a white background. The image size must match the original image size.</p>

      <p>Image download URL: <br/>
         <a href="%(url)s">
            <img src="%(url)s" alt="direct link to image %(uuid)s"/>
         </a>
      </p>
      """ % vars()

    overview.append(FormattedContent(text))

    qc1 = QuestionContent()
    qc1.append_field('Title', 'File Upload Question')

    fu1 = FileUploadAnswer(1024, 1024 * 1024 * 10)

    q1 = Question(identifier="fileupload",
                  content=qc1,
                  answer_spec=AnswerSpecification(fu1))

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)

    # TODO: We want to separate creation of form from uploading the hit
    # need to factor out arguments....
    # duration and lifetime are in seconds.
    # we will give 30 minutes duration (30 * 60) to complete the task
    # we will keep these hits around for 14 days (14 * 24 * 60 * 60)
    print(question_form.get_as_xml())
    mtc.create_hit(questions=question_form, max_assignments=3, title=title, description=description, keywords=keywords,
                   duration=60 * 30, lifetime=3 * 24 * 60 * 60, reward=0.10)
Ejemplo n.º 8
0
def submit_extract_keywords_hit(note):
    """Create a Mechanical Turk HIT that asks a worker to
    choose keywords and definitions from the given note."""

    try:
        MTURK_HOST = os.environ['MTURK_HOST']
    except:
        logger.warn('Could not find Mechanical Turk secrets, not running submit_extract_keywords_hit')
        return

    connection = MTurkConnection(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY,
                                 host=MTURK_HOST)

    if note.course.school:
        title = KEYWORDS_HIT_TITLE_TEMPLATE.format(course=note.course.name, school=note.course.school.name)
    else:
        title = KEYWORDS_HIT_TITLE_TEMPLATE.format(course=note.course.name, school=note.course.department.school.name)

    overview = Overview()
    overview.append(FormattedContent(KEYWORDS_HIT_OVERVIEW_TEMPLATE.format(domain=Site.objects.get_current(),
                                                                  link=note.get_absolute_url())))

    keyword_fta = FreeTextAnswer()
    keyword_fta.num_lines = 1

    definition_fta = FreeTextAnswer()
    definition_fta.num_lines = 3

    question_form = QuestionForm()
    question_form.append(overview)

    for i in range(min(len(KEYWORDS_HIT_KEYWORD_FIELDS), len(KEYWORDS_HIT_DEFINITION_FIELDS))):
        keyword_content = QuestionContent()
        keyword_content.append_field('Title', KEYWORDS_HIT_KEYWORD_FIELDS[i][1])
        keyword_question = Question(identifier=KEYWORDS_HIT_KEYWORD_FIELDS[i][0],
                                    content=keyword_content,
                                    answer_spec=AnswerSpecification(keyword_fta),
                                    is_required=True if i <= 10 else False)
        question_form.append(keyword_question)

        definition_content = QuestionContent()
        definition_content.append_field('Title', KEYWORDS_HIT_DEFINITION_FIELDS[i][1])
        definition_question = Question(identifier=KEYWORDS_HIT_DEFINITION_FIELDS[i][0],
                                       content=definition_content,
                                       answer_spec=AnswerSpecification(definition_fta),
                                       is_required=False)
        question_form.append(definition_question)

    hit = connection.create_hit(questions=question_form, max_assignments=1,
                          title=title, description=KEYWORDS_HIT_DESCRIPTION,
                          keywords=KEYWORDS_HIT_KEYWORDS, duration=KEYWORDS_HIT_DURATION,
                          reward=KEYWORDS_HIT_REWARD, qualifications=KEYWORDS_HIT_QUALIFICATION,
                          annotation=str(note.id))[0]

    HIT.objects.create(HITId=hit.HITId, note=note, processed=False)
Ejemplo n.º 9
0
def createHits(question, answers, params):
    if SANDBOX:
        mturk_url = 'mechanicalturk.sandbox.amazonaws.com'
        preview_url = 'https://workersandbox.mturk.com/mturk/preview?groupId='
    else:
        mturk_url = 'mechanicalturk.amazonaws.com'
        preview_url = 'https://mturk.com/mturk/preview?groupId='

    #Create Hit Form Structure
    overview = Overview()
    overview.append_field('Title', 'We want to know the crowds opinion!')
    overview.append(
        FormattedContent(
            '<a href="http://programthecrowd.com/">Visit us here</a>'))
    questionContent = QuestionContent()
    questionContent.append_field('Title', question)
    answerChoices = SelectionAnswer(min=1,
                                    max=1,
                                    style='checkbox',
                                    selections=answers,
                                    type='text',
                                    other=False)
    q = Question(identifier='Help',
                 content=questionContent,
                 answer_spec=AnswerSpecification(answerChoices),
                 is_required=True)
    questionForm = QuestionForm()
    questionForm.append(overview)
    questionForm.append(q)
    hitIdList = []
    global conn
    # key = params['aws_access_key']
    # secret = params['aws_secret_key']
    conn = MTurkConnection(
        aws_access_key_id='AKIAJBTEJI2RGTJH7OBA',
        aws_secret_access_key='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',
        host=mturk_url)

    #For Loop to create and post hits
    for i in range(0, NUMBER_OF_HITS):
        create_hit_rs = conn.create_hit(questions=questionForm,
                                        lifetime=LIFETIME,
                                        max_assignments=NUMBER_OF_ASSIGNMENTS,
                                        title=TITLE,
                                        keywords=KEYWORDS,
                                        reward=REWARD,
                                        duration=DURATION,
                                        approval_delay=APPROVAL_DELAY,
                                        annotation=DESCRIPTION)
        #print(preview_url + create_hit_rs[0].HITTypeId)
        #print("HIT ID: " + create_hit_rs[0].HITId)
        hitIdList.append(create_hit_rs[0].HITId)

    return hitIdList
Ejemplo n.º 10
0
def createHIT1(to_trans,context):

	
	
	title = 'Translate a sentence into spanish!'
	description = ('For realz. Just translate this sentence.')
	keywords = 'translate, language'
	#qualifications = Qualificatiosn(qualificationType)
	
	#---------------  BUILD OVERVIEW -------------------
	 
	overview = Overview()
	overview.append_field('Title', title)
	overview.append(FormattedContent('<p>' + context + '</p>' + '<p><b>' + to_trans + '</b></p>'))
	 
	 
	#---------------  BUILD QUESTION 2 -------------------
	 
	qc1 = QuestionContent()
	qc1.append_field('Title','Please translate the bolded sentence')
	 
	fta1 = FreeTextAnswer()
	 
	q1 = Question(identifier="translation",
				  content=qc1,
				  answer_spec=AnswerSpecification(fta1))
	 
	#--------------- BUILD THE QUESTION FORM -------------------
	 
	question_form = QuestionForm()
	question_form.append(overview)
	question_form.append(q1)
	 
	#--------------- CREATE QUALIFICATION REQUIREMENT -------------------
	qual_req = Requirement(qualification_type_id=QUALIFICATION_ID,
					comparator="Exists")
	
	quals = Qualifications(requirements=[qual_req])
	#--------------- CREATE THE HIT ------------------- 
	resultSet = mtc.create_hit(questions=question_form,
				   max_assignments=HIT1_MAX_ASSIGN,
				   title=title,
				   description=description,
				   keywords=keywords,
				   duration = 60*5,
	               reward=0.50,
				   qualifications=quals)

	
	return resultSet[0].HITId
Ejemplo n.º 11
0
  def generate_hit(self, num_assignments, hit_duration, hit_reward):
    """
    Purpose: Generate and publish the HIT
    Parameters: num_assignments is the number of avaliable assignments for hit, 
                hit_duration is the duration of the hit in seconds (60*5 for 5 minutes),
                hit_reward is the reward given per hit in dollars (0.05 is 5 cents)
    """
    # CONNECT TO MTURK

    mtc = MTurkConnection(aws_access_key_id = self.access_id,
                      aws_secret_access_key = self.secret_key,
                      host = self.host)

    # BUILD OVERVIEW 
     
    overview = Overview()
    overview.append_field('Title', 'The sentence below constitues the beginning of a story.')
    overview.append(FormattedContent(self.starter_sentence))
     
    # BUILD QUESTION 1: Copy given sentence 
     
    qc1 = QuestionContent()
    qc1.append_field('Title','Copy verbatim the provided sentence. Please keep all capitalization and punctuation as given. Your sumbission will automatically be rejected if any character is incorrect.')
    fta1 = FreeTextAnswer()
    q1 = Question(identifier='verify_sentence', content = qc1, answer_spec = AnswerSpecification(fta1), is_required = True)

    # BUILD QUESTION 2: Create new sentence 

    qc2 = QuestionContent()
    qc2.append_field('Title','Type a single sentence to continue the story begun by the given sentence, and please ensure the sentence ends with a period.')
    fta2 = FreeTextAnswer()
    q2 = Question(identifier='create_sentence', content = qc2, answer_spec = AnswerSpecification(fta2), is_required = True)

    # BUILD THE QUESTION FORM 
     
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
     
    # CREATE THE HIT 
     
    mtc.create_hit(questions = question_form,
                   max_assignments = num_assignments,
                   title = self.title,
                   description = self.description,
                   keywords = self.keywords,
                   duration = hit_duration,
                   reward = hit_reward)
Ejemplo n.º 12
0
def create_question(batch, examples):
	"""
	Creates a QuestionForm for a batch of strings

	Args:
		batch (list) : List of pairs of strings to be matched
		examples (tuple) : Input examples for which HTML is to be generated

	Returns:
		question_form : QuestionForm object containing all question fields

	"""

	question_id = []
	question_form = QuestionForm()


	overview = Overview()
	overview.append_field('Title', title)
	
	#examples = ("(abc, aabc) - not match", "(abc, abc) - match")
	overview.append(FormattedContent(utils.gen_html_for_instruction(examples)))

	question_form.append(overview)

	for i in range(0,len(batch)):
		#print 'String 1  = ' + batch[i][0]
		#print 'String 2  = ' + batch[i][1]

		question_content = QuestionContent()
		text = 'String 1 = ' + batch[i][0] + '\n'
		text = text + 'String 2 = ' + batch[i][1] + '\n'
		question_content.append_field('Text', text)

		q_id = 'q' + str(i) + str(i+1)
		question_id.append(q_id)
		selection_answer = SelectionAnswer(min=1, max=1,style='radiobutton',
	                      selections=matches,
	                      type='text',
	                      other=False)
	 
		question = Question(identifier=q_id,
	              content=question_content,
	              answer_spec=AnswerSpecification(selection_answer),
	              is_required=True)

		question_form.append(question)

	return question_form
Ejemplo n.º 13
0
class mTurk:
    def __init__(self):
        self.ACCESS_ID = os.environ["ACCESS_KEY_ID"]
        self.SECRET_KEY = os.environ["SECRET_ACCESS_KEY"]
        self.HOST = "mechanicalturk.sandbox.amazonaws.com"
        self.title = "Please respond as a therapist to this question"
        self.description = "Read this diary entry and give a thoughtful advice to this person"
        self.keywords = "diary,therapist,friend,advice"
        self.connectMTurk()

    def connectMTurk(self):
        self.mtc = MTurkConnection(
            aws_access_key_id=self.ACCESS_ID, aws_secret_access_key=self.SECRET_KEY, host=self.HOST
        )
        # print(self.mtc.get_account_balance())

    def buildOverview(self):
        self.overview = Overview()
        self.overview.append_field("Title", "Deard Response")
        self.overview.append(FormattedContent("<h2>DearD User Post</h2>"))

    def buildQuestion(self, diaryEntry):
        self.qc = QuestionContent()
        self.qc.append_field("Title", diaryEntry)
        self.fta = FreeTextAnswer()
        self.q1 = Question(identifier="comments", content=self.qc, answer_spec=AnswerSpecification(self.fta))

    def buildQuestionForm(self):
        self.question_form = QuestionForm()
        self.question_form.append(self.overview)
        self.question_form.append(self.q1)

    def createHit(self, diaryEntry):
        self.buildOverview()
        self.buildQuestion(diaryEntry)
        self.buildQuestionForm()
        id = self.mtc.create_hit(
            questions=self.question_form,
            max_assignments=1,
            title=self.title,
            description=self.description,
            duration=60 * 5,
            reward=0.50,
        )
        return id[0].HITId
Ejemplo n.º 14
0
    def SubmitHIT(self, sandbox = 'false'):
        """
        Constructs a HIT from the HITGenerator's attributes, registers it with Amazon, and returns the HITId as a unicode string.

        If the sandbox flag is set to true then the hit will be registered with the Sandbox, otherwise it is registered to AWS
        directly.  All of the necessary data must have been submitted during the HITGenerator's initiation.
        """

        if sandbox is 'true':
            self.host = 'mechanicalturk.sandbox.amazonaws.com'
        conn = MTurkConnection(host = self.host, aws_access_key_id = self.AWS_KEY, aws_secret_access_key = self.AWS_SECRET)
        answer_specification = AnswerSpecification(SelectionAnswer(style = self.answer_style, selections = self.answer_options))
        overview = Overview()
        overview.append('Title', 'Translate these sentences')
        overview.append('FormattedContent', overview_content) 
        qc = QuestionContent()
        the_text = "Some arabic Words."
        qc.append('FormattedContent', u'<table><tr><td></td><td align="right" width="538">%s</td></tr></table>' % the_text)
       # construct an answer field
        fta = FreeTextAnswer()
        ansp = AnswerSpecification(fta)
        ql = []
        for q in self.question_list:
            ql.append(Question(identifier=q[1],
                               content=q[0],
                               answer_spec=ansp))
        #q = Question(identifier=str(uuid.uuid4()),
        #             content=qc,
        #             answer_spec=ansp)
        # build question form with question list
        qf = QuestionForm(ql, overview=overview)
        self.hit_response = conn.create_hit(question = qf,
                                            lifetime = self.lifetime,
                                            max_assignments = self.assignment_count,
                                            title = self.title,
                                            description = self.description,
                                            keywords = self.keywords,
                                            reward = self.reward,
                                            )
        # Returns the HITId as a unicode string
#        self.HITId = self.hit_response.HITId
#        return self.HITId
        return self.hit_response
Ejemplo n.º 15
0
def _gen_overview():
    overview_title = 'Translate these sentences'
    overview_content = """<p>Your task is to translate the Spanish sentences into English.  Please make sure that your English translation:</p>
<ul>
    <li>Is faithful to the original in both meaning and style</li>
    <li>Is grammatical, fluent, and natural-sounding English</li>
    <li>Does not add or delete information from the original text</li>
    <li>Does not contain any spelling errors</li>
</ul>
<p>When creating your translation, please follow these guidelines:</p>
<ul>
    <li><b>Do not use any machine translation systems (like transle.google.com)</b></li>
</ul>
"""

    overview = Overview()
    overview.append('Title', overview_title)
    overview.append('FormattedContent', overview_content)

    return overview
Ejemplo n.º 16
0
def _gen_overview():
    overview_title = 'Translate these sentences'
    overview_content = """<p>Your task is to translate the Spanish sentences into English.  Please make sure that your English translation:</p>
<ul>
    <li>Is faithful to the original in both meaning and style</li>
    <li>Is grammatical, fluent, and natural-sounding English</li>
    <li>Does not add or delete information from the original text</li>
    <li>Does not contain any spelling errors</li>
</ul>
<p>When creating your translation, please follow these guidelines:</p>
<ul>
    <li><b>Do not use any machine translation systems (like transle.google.com)</b></li>
</ul>
"""

    overview = Overview()
    overview.append('Title', overview_title)
    overview.append('FormattedContent', overview_content)
    
    return overview
Ejemplo n.º 17
0
def createQuestionForm(overviewTitle, overviewDescription, numberOfTweets,
                       listOfTweets, listOfTweetIDs):
    """
    Create an overview for an MTurk HIT
    """

    #The Question Form should contain 1 overview and 3 odd questions
    questionForm = QuestionForm()

    #Define the Overview
    overview = Overview()
    Title = FormattedContent(overviewTitle)
    overview.append(Title)
    overviewDescription1 = FormattedContent(overviewDescription[0])
    overviewDescription2 = FormattedContent(overviewDescription[1])
    overviewDescription3 = FormattedContent(overviewDescription[2])
    overview.append(overviewDescription1)
    overview.append(overviewDescription2)
    overview.append(overviewDescription3)
    #Append the Overview to the Question Form
    questionForm.append(overview)

    #Create the Questions, and Add them
    for i in xrange(numberOfTweets):
        overview = Overview()
        questionTitle = FormattedContent(
            '<font face="Helvetica" size="2"><b> Tweet #' + str(i + 1) +
            '</b></font>')
        overview.append(questionTitle)
        questionBody = FormattedContent('<font face="Helvetica" size="2">' +
                                        listOfTweets[i] + '</font>')
        overview.append(questionBody)
        #answerTuple = tuple([('<a href="https://wikipedia.org/en/' + y.replace(" ","_") + '" target="_blank">' + y + "</a>") for y in list(listOfAnswers[i])])
        #links = FormattedContent('<b>Links</b> | ' + answerTuple[0] + ' | ' + answerTuple[1])
        #overview.append(links)
        questionForm.append(overview)
        question = createQuestion(listOfTweetIDs[i], i, listOfTweets[i],
                                  ["Positive", "Negative"])
        questionForm.append(question)

    return questionForm
Ejemplo n.º 18
0
    def __generate_qualification_test(self, question_data, num_correct, title):
        '''
            Returns a QuestionForm and AnswerKey for a qualification test from a list of sentence dictionaries.
                question_data : json object containing all the questions.
        '''

        # Get question and answer data
        questions = map(
            lambda (i, x): self.__generate_qualification_question(x, i),
            enumerate(question_data))
        answers = map(lambda (i, x): x["answer_key_" + str(i)],
                      enumerate(questions))

        answer_key = self.__generate_answer_key(answers, num_correct,
                                                len(question_data))

        # Create form setup
        qual_overview = Overview()
        qual_overview.append_field("Title", title)

        # Instructions
        qual_overview.append(
            FormattedContent(
                "<h1>Please answer all the questions below.</h1>"))
        qual_overview.append(
            FormattedContent(
                "<h2>For each question, please choose either the left or right image \
            which you think is more beautiful in terms of its composition. Hints: Please make your decision based on\
            several 'rules of thumb' in photography, such as rule of thirds, visual balance and golden ratio. \
            You may also make your decision by judging which image contains less unimportant or distracting contents.</h2>"
            ))

        # Create question form and append contents
        qual_form = QuestionForm()
        qual_form.append(qual_overview)

        for q in questions:
            i = q["question_num"]
            qual_form.append(q["question_" + str(i)])

        return (qual_form, answer_key)
Ejemplo n.º 19
0
def creating_hits(hitters, location='https://c9.io/gibolt/wordcloud565/workspace/aws-python-example/IMG_5109.JPG'): 
    title = 'First thoughts on the photo'
    description = ('Enter the first word that comes to your mind'
                   ' after seeing this photo')
    keywords = 'photo,easy,short,describe,one,word'
    
    string='<p><img src="'+location+'" alt="oops.image missing" height="400" width="500" /></p>'
    
    overview = Overview()
    overview.append_field('Title', 'What is Your First Impression?')
    overview.append(FormattedContent(string))
     
    
    qc1 = QuestionContent()
    qc1.append_field('Title','First word that comes to mind')
    fta1 = FreeTextAnswer()
    q1 = Question(identifier='photo', content=qc1, answer_spec=AnswerSpecification(fta1))
    qc2 = QuestionContent()
    qc2.append_field('Title', 'Second Word')
    q2typ = FreeTextAnswer()
    q2 = Question(identifier="second", content=qc2, answer_spec=AnswerSpecification(q2typ))
    qc3 = QuestionContent()
    qc3.append_field('Title', 'Third Word')
    q3typ = FreeTextAnswer()
    q3 = Question(identifier="third", content=qc3, answer_spec=AnswerSpecification(q3typ))
    
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
    question_form.append(q3)
     
    for x in range(1,hitters):
        my_hit = conn.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration = 60*5,
                   reward=0.01)
	def __generate_qualification_test(self, question_data, num_correct, title):
		'''
		Returns a QuestionForm and AnswerKey for a qualification test from a list of sentence dictionaries
		'''

		# Get question and answer data
		questions = map(lambda (i,x): self.__generate_qualification_question(x,i), enumerate(question_data))
		answers = map(lambda (i,x): x["answer_key_"+str(i)], enumerate(questions))
		answer_key = self.__generate_answer_key(answers, num_correct, len(question_data))

		# Create form setup
		qual_overview = Overview()
		qual_overview.append_field("Title",title)

		# Instructions
		qual_overview.append(FormattedContent("<h1>You must correctly code "+str(num_correct)+" out of the "+str(len(question_data))+" test sentences below.</h1>"))
		qual_overview.append(FormattedContent("<h2>Coding instructions are listed below. Please read through these carefully before continuing on to the coding task.</h2>"))
		inst_url = "https://s3.amazonaws.com/aws.drewconway.com/mt/experiments/cmp/html/instructions.html"
		qual_overview.append(FormattedContent('<iframe src="'+inst_url+'" frameborder="0" width="1280" height="300" scrolling="auto">This text is necessary to ensure proper XML validation</iframe>'))

		# Create question form and append contents
		qual_form = QuestionForm()
		qual_form.append(qual_overview)
		for q in questions:
			i = q["question_num"]
			qual_form.append(q["policy_area_"+str(i)])
			qual_form.append(q["econ_scale_"+str(i)])
			qual_form.append(q["soc_scale_"+str(i)])

		return (qual_form, answer_key)
Ejemplo n.º 21
0
def postHIT(link):
	title = 'Sing along to an audio file!'

	description = ('Quick, easy, and fun task. Go to the link below read and record sentences shown on the webpage. Copy the given survey code here.')

	keywords = 'recording, english, tesing'

	overview = Overview()
	overview.append_field('Title', title)
	overview.append(FormattedContent('<a href="' + link + '"> Click this link to go to the task</a>'))

	# qc1 = QuestionContent()
	# qc1.append_field('Title', 'Which city are you from?')
	# fta1 = FreeTextAnswer(default="", num_lines=1)
	# q1 = Question(identifier='pronunciation',
	#                     content = qc1,
	#                     answer_spec=AnswerSpecification(fta1),
	#                     is_required = False)

	qc2 = QuestionContent()
	qc2.append_field('Title', 'Put your survey code here')
	fta2 = FreeTextAnswer(default="", num_lines=1)
	q2 = Question(identifier='pronunciation',
			    content = qc2,
			    answer_spec=AnswerSpecification(fta2),
			    is_required = False)

	question_form = QuestionForm()
	question_form.append(overview)
	# question_form.append(q1)
	question_form.append(q2)

	mtc.create_hit(questions = question_form,
		       max_assignments = 1,
		       title = title,
		       description = description,
		       keywords = keywords,
		       duration = 60*60*6,
		       reward = 0.03)
def create_rank_hit(mturk, src_url, URLs, num_assignment, qualification):
    # Constant data for HIT generation
    hit_title = "Photo Quality Ranking"
    hit_description = "This task involves viewing pairs of pictures and judging which picture among the image pair is more beautiful."
    lifetime = 259200
    keywords = ["photo","quality","ranking"]
    duration = 30 * 60
    reward = 0.04
    #approval_delay = 86400

    # Question form for the HIT
    question_form = QuestionForm()

    overview = Overview()
    overview.append_field('Title', 'Photo Quality Ranking')
    overview.append(FormattedContent('Source Image: <img src="'+src_url+'" alt="Image not shown correctly!"></img>'))
    overview.append(FormattedContent('Each of the following questions shows a pair of crops from the source image shown in the above.'))
    overview.append(FormattedContent('For each question, please choose either the left or right image which you think is more beautiful in terms of its <u>composition</u>.'))
    #overview.append(FormattedContent('<b>Hints: Please make your decision based on several "rules of thumb" in photography, such as rule of thirds, visual balance and golden ratio.</b>'))
    overview.append(FormattedContent('Note that it is possible that both of the cropped images do not possess a good composition. Please just select the more preferable one based on your sense of aesthetics.'))
    question_form.append(overview)

    ratings = [('Left', '0'), ('Right','1')]
    for i in xrange(len(URLs)):
        qc = QuestionContent()
        qc.append_field('Title', 'Question')
        qc.append_field('Text', 'Please indicate which one of the following images is more beautiful.')
        qc.append(FormattedContent('<img src="'+URLs[i]+'" alt="Image not shown correctly!"></img>'))
        fta = SelectionAnswer(min=1, max=1, style='radiobutton', selections=ratings, type='text', other=False)
        q = Question(identifier='photo_pair_'+str(i),
                    content=qc,
                    answer_spec=AnswerSpecification(fta),
                    is_required=True
        )
        question_form.append(q)

    hit_res = mturk.create_hit(title=hit_title,
                                description=hit_description,
                                reward=Price(amount=reward),
                                duration=duration,
                                keywords=keywords,
                                #approval_delay=approval_delay,
                                question=question_form,
                                #lifetime=lifetime,
                                max_assignments=num_assignment,
                                qualifications=qualification)
    # return HIT ID
    return hit_res[0].HITId
Ejemplo n.º 23
0
    def __generate_qualification_test(self, question_data, num_correct, title):
        '''
		Returns a QuestionForm and AnswerKey for a qualification test from a list of sentence dictionaries
		'''

        # Get question and answer data
        questions = map(
            lambda (i, x): self.__generate_qualification_question(x, i),
            enumerate(question_data))
        answers = map(lambda (i, x): x["answer_key_" + str(i)],
                      enumerate(questions))
        answer_key = self.__generate_answer_key(answers, num_correct,
                                                len(question_data))

        # Create form setup
        qual_overview = Overview()
        qual_overview.append_field("Title", title)

        # Instructions
        qual_overview.append(
            FormattedContent("<h1>You must correctly code " +
                             str(num_correct) + " out of the " +
                             str(len(question_data)) +
                             " test sentences below.</h1>"))
        qual_overview.append(
            FormattedContent(
                "<h2>Coding instructions are listed below. Please read through these carefully before continuing on to the coding task.</h2>"
            ))
        inst_url = "https://s3.amazonaws.com/aws.drewconway.com/mt/experiments/cmp/html/instructions.html"
        qual_overview.append(
            FormattedContent(
                '<iframe src="' + inst_url +
                '" frameborder="0" width="1280" height="300" scrolling="auto">This text is necessary to ensure proper XML validation</iframe>'
            ))

        # Create question form and append contents
        qual_form = QuestionForm()
        qual_form.append(qual_overview)
        for q in questions:
            i = q["question_num"]
            qual_form.append(q["policy_area_" + str(i)])
            qual_form.append(q["econ_scale_" + str(i)])
            qual_form.append(q["soc_scale_" + str(i)])

        return (qual_form, answer_key)
Ejemplo n.º 24
0
SECRET_KEY = settings.AWS_PRIVATE_KEY
HOST = 'mechanicalturk.sandbox.amazonaws.com'

mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                      aws_secret_access_key=SECRET_KEY,
                      host=HOST)
title = 'Transcription of promotions from image into text'
description = ('Find the promotion information from the image provided.')
keywords = 'image, text, promotion'

#---------------  BUILD OVERVIEW -------------------

overview = Overview()
overview.append_field('Title', title)
overview.append(
    FormattedContent('<a target="_blank"'
                     ' href="http://google.com">'
                     ' Hello</a>'))

#---------------  BUILD QUESTION 1 -------------------

qc1 = QuestionContent()
qc1.append_field('Title', 'How looks the design ?')

fta1 = SelectionAnswer(min=1,
                       max=1,
                       style='dropdown',
                       selections=ratings,
                       type='text',
                       other=False)

q1 = Question(identifier='design',
Ejemplo n.º 25
0
                      host=HOST)


 
title = 'Profile of record Athlete Information'
description = ('Provide Information about the Athlete')
keywords = 'website, rating, opinions'
 
height =[('4\'11','4\'11'),('5\'1','5\'1'),('5\'2','5\'2'),('5\'3','5\'3'),('5\'4','5\'4'),('5\'5','5\'5'),('5\'6','5\'6'),('5\'7','5\'7')]
 
#---------------  BUILD OVERVIEW -------------------
 
overview = Overview()
overview.append_field('Title', 'What is the Height if this Athlete?')
overview.append(FormattedContent('<a> target="_blank"'
                                 ' href="https://en.wikipedia.org/wiki/Brett_Favre"'
                                 ' Athlete Information URL</a>'))
# 
##---------------  BUILD QUESTION  -------------------
# 
qc = QuestionContent()
qc.append_field('Title','What is the Height of Brett Favre')
 
fta = SelectionAnswer(min=1, max=1,style='dropdown',
                      selections=height,
                      type='text',
                      other=False)
 
q = Question(identifier='design',
              content=qc,
              answer_spec=AnswerSpecification(fta),
Ejemplo n.º 26
0
description = ('Visit a website and give us your opinion about'
               ' the design and also some personal comments')
keywords = 'website, rating, opinions'
 
#ratings =[('Very Bad','-2'),
#         ('Bad','-1'),
#         ('Not bad','0'),
#         ('Good','1'),
#         ('Very Good','1')]
# 
#---------------  BUILD OVERVIEW -------------------
 
overview = Overview()
overview.append_field('Title', 'Give your opinion on this website')
overview.append(FormattedContent('<a target="_blank"'
                                 ' href="https://shop.sqor.com/">'
                                 ' Sqor Sports Shop</a>'))
# 
##---------------  BUILD QUESTION 1 -------------------
# 
#qc1 = QuestionContent()
#qc1.append_field('Title','How looks the design ?')
# 
#fta1 = SelectionAnswer(min=1, max=1,style='dropdown',
#                      selections=ratings,
#                      type='text',
#                      other=False)
# 
#q1 = Question(identifier='design',
#              content=qc1,
#              answer_spec=AnswerSpecification(fta1),
Ejemplo n.º 27
0
def demo_create_favorite_color_hit():
    """A HIT to determine the Worker's favorite color"""

    TITLE = 'Tell me your favorite color'
    DESCRIPTION = ('This is a HIT that is created by a computer program '
                   'to demonstrate how Mechanical Turk works. This should '
                   'be a free HIT for the worker.')
    KEYWORDS = 'data collection, favorite, color'
    DURATION = 15 * 60  # 15 minutes (Time to work on HIT)
    MAX_ASSIGNMENTS = 1  # Number of assignments per HIT
    REWARD_PER_ASSIGNMENT = 0.01  # $0.00 USD (1 cent)

    #--------------- BUILD HIT container -------------------
    overview = Overview()
    overview.append_field('Title', TITLE)
    overview.append(FormattedContent(
         "<p>This is an experiment to learn Mechanical Turk</p>"))

    #---------------  BUILD QUESTION 1 -------------------
    question_content = QuestionContent()
    question_content.append(FormattedContent(
         "<b>What is your favorite color?</b> Just testing an API hit. Any answer will win an award."))

    free_text_answer = FreeTextAnswer(num_lines=1)

    q1 = Question(identifier='favorite_color',
                  content=question_content,
                  answer_spec=AnswerSpecification(free_text_answer),
                  is_required=True)

    #---------------  BUILD QUESTION 3 -------------------
    question_content = QuestionContent()
    question_content.append(FormattedContent(
        """<p>Give me a fun comment:</p>"""))

    q2 = Question(identifier="comments",
                  content=question_content,
                  answer_spec=AnswerSpecification(FreeTextAnswer()))

    #--------------- BUILD THE QUESTION FORM -------------------
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)

    #--------------- CREATE THE HIT -------------------
    mtc = get_connection()
    hit = mtc.create_hit(questions=question_form,
                         max_assignments=MAX_ASSIGNMENTS,
                         title=TITLE,
                         description=DESCRIPTION,
                         keywords=KEYWORDS,
                         duration=DURATION,
                         reward=REWARD_PER_ASSIGNMENT)

    #---------- SHOW A LINK TO THE HIT GROUP -----------
    base = get_worker_url()

    print "\nVisit this website to see the HIT that was created:"
    print "%s/mturk/preview?groupId=%s" % (base, hit[0].HITTypeId)

    return hit[0]
               ' in Image Provided')

keywords = 'transcribe, handwriting, opinion'

ratings =[('Very Bad','0'),
         ('Bad','1'),
         ('Not bad','2'),
         ('Good','3'),
         ('Very Good','4')]

#---------------  BUILD OVERVIEW -------------------

overview = Overview()
overview.append_field('Title', 'Handwriting Analysis')
binary_content = Binary('image', 'jpeg', 'http://sid.pythonanywhere.com/static/938620b3ac57ac94efb633e17749a812e43c5ef1f4e7b810f776cd7cf8dd9dac.jpg', alt_text='image is missing')
overview.append(binary_content)

#---------------  BUILD QUESTION 1 -------------------

qc1 = QuestionContent()
qc1.append_field('Title','Rate the overall appearance of the handwriting.' )

fta1 = SelectionAnswer(min=1, max=1,style='dropdown',
                      selections=ratings,
                      type='text',
                      other=False)

q1 = Question(identifier='design',
              content=qc1,
              answer_spec=AnswerSpecification(fta1),
              is_required=True)
Ejemplo n.º 29
0
mtc = MTurkConnection(aws_access_key_id=AWS_ACCESS_KEY_ID,
                      aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                      host=HOST)
                      
if debug: print mtc.get_account_balance()


title = 'Match these Pictures to Macy\'s Products'
description = 'Look at this photo and match it to Macy\'s products'
keywords = 'clothing, rating, opinions, easy, quick, macys'
 
#make overview
 
overview = Overview()
overview.append_field('Title', 'Find three Macys.com Product Web IDs That Match')
overview.append(FormattedContent('<img src="'+PIN_IMAGE_URL+'" alt="Pintrest Image" />'
                                 '<br />'+PIN_IMAGE_TITLE))
               
#make webid1
 
qc1 = QuestionContent()
qc1.append_field('Title','First WebID Code')
 
fta1 = FreeTextAnswer(num_lines=1)
 
q1 = Question(identifier="FirstWebCode",
              content=qc1,
              answer_spec=AnswerSpecification(fta1))

#make webid2
 
qc2 = QuestionContent()
Ejemplo n.º 30
0
def PublishTasks(hitNum, maxAssignments):
    # sandbox in which to simulate: mechanicalturk.sandbox.amazonaws.com
    # real environment: mechanicalturk.amazonaws.com
    mtc = MTurkConnection(host='mechanicalturk.amazonaws.com')

    # print mtc.APIVersion
    # print mtc.get_account_balance()
    # print mtc.get_reviewable_hits()
    # print mtc.get_all_hits()

    #---------------  BUILD OVERVIEW -------------------

    # jbragg: Modified maximum reward description.
    #title = '(Maximum reward possible: $70) Identify the relation between two entities in English sentences'
    title = 'Identify the relation between two entities in English sentences'
    #description = 'You will be given English sentences in which your task is to identify the relation between two designated entities. Your reward will depend on how many questions you have answered. The maximum reward you can earn is $70.'
    description = 'You will be given English sentences in which your task is to identify the relation between two designated entities. Your reward will depend on how many questions you have answered. The maximum reward you can earn is approximately $5.'
    keywords = 'English sentences, relation identification'

    ratings = [('Very Bad', '-2'), ('Bad', '-1'), ('Not bad', '0'),
               ('Good', '1'), ('Very Good', '1')]

    #---------------  BUILD OVERVIEW -------------------

    overview = Overview()
    overview_title = 'Exercise link (please copy the link and paste it in your browser if it cannot be opened directly.)'
    link = '<a target="_blank"' ' href="http://128.208.3.167:3000/mturk">' ' http://128.208.3.167:3000/mturk</a>'
    # jbragg: Commented out long-term bonus.
    instructions = '<p>Instructions:</p><ul><li>You will be presented with sentences that have a person and a location highlighted.</li><li>Your task is to determine which of the 5 designated relations are expressed between the person and location.</li><li>You&#39;ll get paid $0.50 after each successful set of 20 questions<!-- -- plus a bonus of $2.00 after every 10 batches (equal to 200 questions)-->.</li><li>We know the correct answers to some of these sentence questions, and you can stay if you get these questions right.</li><li>You can start by going to the external link above now. After you finish all the questions, you will be provided with a confirm code, used for authentication and determining the appropriate amount of money as the payment.</li><li>In very rare cases where the website crashes, you could click backward and then forward on your browser to reload the question. It won\'t affect the payment because all the questions you have answered are recorded, on which the amount of payment is based. So please don\'t worry about that.</li></ul>'
    overview_content = link + instructions
    overview.append_field('Title', overview_title)
    overview.append(FormattedContent(overview_content))

    #---------------  BUILD QUESTION 1 -------------------

    qc1 = QuestionContent()
    qc1.append_field('Title', 'How looks the design ?')

    fta1 = SelectionAnswer(min=1,
                           max=1,
                           style='dropdown',
                           selections=ratings,
                           type='text',
                           other=False)

    q1 = Question(identifier='design',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)

    #---------------  BUILD QUESTION 2 -------------------

    qc2 = QuestionContent()
    qc2.append_field(
        'Title',
        'Confirm code \n1. The code will be provided to you as you finish from the exercise link. \n2. The code will be verified before paying. \n3. By the end of every 20 questions (as a batch), You can choose to finish and get a confirm code, or continue.'
    )

    fta2 = FreeTextAnswer()

    q2 = Question(identifier="Confirm_code",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))

    #--------------- BUILD THE QUESTION FORM -------------------

    question_form = QuestionForm()
    question_form.append(overview)
    # question_form.append(q1)
    question_form.append(q2)

    #--------------- CREATE HITs -------------------

    HIT_num = hitNum
    for i in range(HIT_num):
        # max_assignments: how many replicas this HIT has
        mtc.create_hit(questions=question_form,
                       max_assignments=maxAssignments,
                       title=title,
                       description=description,
                       keywords=keywords,
                       duration=60 * 60 * 10,
                       reward=0.50)
Ejemplo n.º 31
0
def PublishTasks(hitNum, maxAssignments):
  # sandbox in which to simulate: mechanicalturk.sandbox.amazonaws.com
  # real environment: mechanicalturk.amazonaws.com
  mtc = MTurkConnection(host='mechanicalturk.amazonaws.com')

  # print mtc.APIVersion
  # print mtc.get_account_balance()
  # print mtc.get_reviewable_hits()
  # print mtc.get_all_hits()


  #---------------  BUILD OVERVIEW -------------------

	# jbragg: Modified maximum reward description.
  #title = '(Maximum reward possible: $70) Identify the relation between two entities in English sentences'
  title = 'Identify the relation between two entities in English sentences'
  #description = 'You will be given English sentences in which your task is to identify the relation between two designated entities. Your reward will depend on how many questions you have answered. The maximum reward you can earn is $70.'
  description = 'You will be given English sentences in which your task is to identify the relation between two designated entities. Your reward will depend on how many questions you have answered. The maximum reward you can earn is approximately $5.'
  keywords = 'English sentences, relation identification'


   
  ratings =[('Very Bad','-2'),
           ('Bad','-1'),
           ('Not bad','0'),
           ('Good','1'),
           ('Very Good','1')]
   
  #---------------  BUILD OVERVIEW -------------------
   
  overview = Overview()
  overview_title = 'Exercise link (please copy the link and paste it in your browser if it cannot be opened directly.)'
  link = '<a target="_blank"'' href="http://128.208.3.167:3000/mturk">'' http://128.208.3.167:3000/mturk</a>'
	# jbragg: Commented out long-term bonus.
  instructions = '<p>Instructions:</p><ul><li>You will be presented with sentences that have a person and a location highlighted.</li><li>Your task is to determine which of the 5 designated relations are expressed between the person and location.</li><li>You&#39;ll get paid $0.50 after each successful set of 20 questions<!-- -- plus a bonus of $2.00 after every 10 batches (equal to 200 questions)-->.</li><li>We know the correct answers to some of these sentence questions, and you can stay if you get these questions right.</li><li>You can start by going to the external link above now. After you finish all the questions, you will be provided with a confirm code, used for authentication and determining the appropriate amount of money as the payment.</li><li>In very rare cases where the website crashes, you could click backward and then forward on your browser to reload the question. It won\'t affect the payment because all the questions you have answered are recorded, on which the amount of payment is based. So please don\'t worry about that.</li></ul>'
  overview_content = link + instructions
  overview.append_field('Title', overview_title)
  overview.append(FormattedContent(overview_content))
   
  #---------------  BUILD QUESTION 1 -------------------
   
  qc1 = QuestionContent()
  qc1.append_field('Title','How looks the design ?')
   
  fta1 = SelectionAnswer(min=1, max=1,style='dropdown',
                        selections=ratings,
                        type='text',
                        other=False)
   
  q1 = Question(identifier='design',
                content=qc1,
                answer_spec=AnswerSpecification(fta1),
                is_required=True)
   
  #---------------  BUILD QUESTION 2 -------------------
   
  qc2 = QuestionContent()
  qc2.append_field('Title','Confirm code \n1. The code will be provided to you as you finish from the exercise link. \n2. The code will be verified before paying. \n3. By the end of every 20 questions (as a batch), You can choose to finish and get a confirm code, or continue.')
   
  fta2 = FreeTextAnswer()
   
  q2 = Question(identifier="Confirm_code",
                content=qc2,
                answer_spec=AnswerSpecification(fta2))
   
  #--------------- BUILD THE QUESTION FORM -------------------
   
  question_form = QuestionForm()
  question_form.append(overview)
  # question_form.append(q1)
  question_form.append(q2)
   
  #--------------- CREATE HITs -------------------

  HIT_num = hitNum
  for i in range(HIT_num):
  	# max_assignments: how many replicas this HIT has
  	mtc.create_hit(questions=question_form,
  	               max_assignments=maxAssignments,
  	               title=title,
  	               description=description,
  	               keywords=keywords,
  	               duration = 60*60*10,
  	               reward=0.50)
Ejemplo n.º 32
0
def submit_extract_keywords_hit(note):
    """Create a Mechanical Turk HIT that asks a worker to
    choose keywords and definitions from the given note."""

    MTURK_HOST = run_mturk('submit_extract_keywords_hit')
    if not MTURK_HOST:
        return

    connection = MTurkConnection(settings.AWS_ACCESS_KEY_ID,
                                 settings.AWS_SECRET_ACCESS_KEY,
                                 host=MTURK_HOST)

    if note.course.school:
        title = KEYWORDS_HIT_TITLE_TEMPLATE.format(
            course=note.course.name, school=note.course.school.name)
    else:
        title = KEYWORDS_HIT_TITLE_TEMPLATE.format(
            course=note.course.name, school=note.course.department.school.name)

    overview = Overview()
    overview.append(
        FormattedContent(
            KEYWORDS_HIT_OVERVIEW_TEMPLATE.format(
                domain=Site.objects.get_current(),
                link=note.get_absolute_url())))

    keyword_fta = FreeTextAnswer()
    keyword_fta.num_lines = 1

    definition_fta = FreeTextAnswer()
    definition_fta.num_lines = 3

    question_form = QuestionForm()
    question_form.append(overview)

    for i in range(
            min(len(KEYWORDS_HIT_KEYWORD_FIELDS),
                len(KEYWORDS_HIT_DEFINITION_FIELDS))):
        keyword_content = QuestionContent()
        keyword_content.append_field('Title',
                                     KEYWORDS_HIT_KEYWORD_FIELDS[i][1])
        keyword_question = Question(
            identifier=KEYWORDS_HIT_KEYWORD_FIELDS[i][0],
            content=keyword_content,
            answer_spec=AnswerSpecification(keyword_fta),
            is_required=True if i <= 10 else False)
        question_form.append(keyword_question)

        definition_content = QuestionContent()
        definition_content.append_field('Title',
                                        KEYWORDS_HIT_DEFINITION_FIELDS[i][1])
        definition_question = Question(
            identifier=KEYWORDS_HIT_DEFINITION_FIELDS[i][0],
            content=definition_content,
            answer_spec=AnswerSpecification(definition_fta),
            is_required=False)
        question_form.append(definition_question)

    hit = connection.create_hit(questions=question_form,
                                max_assignments=1,
                                title=title,
                                description=KEYWORDS_HIT_DESCRIPTION,
                                keywords=KEYWORDS_HIT_KEYWORDS,
                                duration=KEYWORDS_HIT_DURATION,
                                reward=KEYWORDS_HIT_REWARD,
                                qualifications=KEYWORDS_HIT_QUALIFICATION,
                                annotation=str(note.id))[0]

    KeywordExtractionHIT.objects.create(HITId=hit.HITId,
                                        note=note,
                                        processed=False)
 html_code += '</tr>'
 html_code += '<tr>'
 html_code += '<td><a href="' + str(row[5]) + '" target="_blank">Link to full size image 1 (new window)</a></td>'
 html_code += '<td><a href="' + str(row[6]) + '" target="_blank">Link to full size image 2 (new window)</a></td>'
 html_code += '<td><a href="' + str(row[7]) + '" target="_blank">Link to full size image 3 (new window)</a></td>'        
 html_code += '</tr></table>'
 html_code += '<hr />'
 html_code += '<h3><b>Descriptions</b></h3>'
 html_code += '<table border="1" frame="void" cellspacing="5">'
 html_code += '<tr><td></td><td width="50%"><b>Option A</b></td><td width="50%"><b>Option B</b></td></tr>'
 html_code += '<tr><td><b>Title</b></td><td>' + options[rnd[0]][0] + '</td><td>' + options[rnd[1]][0] + '</td></tr>'
 html_code += '<tr><td><b>Description</b></td><td>' + options[rnd[0]][1] + '</td><td>' + options[rnd[1]][1] + '</td></tr>'
 html_code += '<tr><td><b>Category</b></td><td>' + options[rnd[0]][2] + '</td><td>' + options[rnd[1]][2] + '</td></tr>'
 html_code += '</table>'
 
 overview.append(FormattedContent(html_code))
  
 #---------------  BUILD QUESTION 1 -------------------
  
 qc1 = QuestionContent()
 qc1.append_field('Title','Select better description')
 
 html_code = ""
 html_code += '<b>Instructions:</b> Select the better description of the auction item'
 html_code += '<ul>'
 html_code += '<li>Read the descriptions of option A and B and take a look at the item(s) on the images (at the beginning of the HIT)</li>'
 html_code += '<li>Select the option (A or B) which provides a clear and accurate description of the auction item(s)</li>'
 html_code += '</ul>'
 
 qc1.append(FormattedContent(html_code))
 
Ejemplo n.º 34
0
def make_hit(image_url):
    title = 'Label image with its location'
    description = 'Answer questions about an image to label its location.'
    keywords = 'image categorization, locations, scene recognition'

    in_out = [('indoors', '0'), ('outdoors', '1')]
    nat_manmade = [('man-made', '0'), ('natural', '1')]
    functions = [('transportation/urban', '0'), ('restaurant', '1'),
                 ('recreation', '2'), ('domestic', '3'),
                 ('work/education', '4'), ('other/unclear', '5')]
    landscapes = [('body of water/beach', '0'), ('field', '1'),
                  ('mountain', '2'), ('forest/jungle', '3'),
                  ('other/unclear', '4')]

    #---------------  BUILD OVERVIEW -------------------

    overview = Overview()
    overview.append_field('Title', title)
    with open(INSTRUCTIONS_HTML) as html:
        instructions = html.read()
    overview.append(FormattedContent(instructions))

    image = Binary('image', None, image_url, 'image')
    overview.append(image)

    #---------------  BUILD QUESTION 1 -------------------

    qc1 = QuestionContent()
    qc1.append_field(
        'Text', 'Is the location shown in the image indoors or outdoors?')

    fta1 = SelectionAnswer(min=1,
                           max=1,
                           style='checkbox',
                           selections=in_out,
                           type='text',
                           other=False)

    q1 = Question(identifier='Question 1',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)

    #---------------  BUILD QUESTION 2 -------------------

    qc2 = QuestionContent()
    qc2.append_field(
        'Text', 'Is the location shown in the image man-made or ' +
        'natural? Examples of man-made locations include ' +
        'buildings and parks while examples of natural ' +
        'locations include mountains and rivers.')

    fta2 = SelectionAnswer(min=1,
                           max=1,
                           style='checkbox',
                           selections=nat_manmade,
                           type='text',
                           other=False)

    q2 = Question(identifier='Question 2',
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2),
                  is_required=True)

    #---------------  BUILD QUESTION 3 -------------------

    qc3 = QuestionContent()
    qc3.append_field(
        'Text', 'If the location in the image is man-made, what is the ' +
        'general function or type of the location? If the ' +
        'location is natural (not man-made), don\'t select ' +
        'anything here.')

    fta3 = SelectionAnswer(min=0,
                           max=1,
                           style='checkbox',
                           selections=functions,
                           type='text',
                           other=False)

    q3 = Question(identifier='Question 3',
                  content=qc3,
                  answer_spec=AnswerSpecification(fta3),
                  is_required=False)

    #---------------  BUILD QUESTION 4 -------------------

    qc4 = QuestionContent()
    qc4.append_field(
        'Text', 'If the location in the picture is natural, what ' +
        'kind of natural location is it? If the location ' +
        'man-made (not natural), don\'t select anything here.')

    fta4 = SelectionAnswer(min=0,
                           max=1,
                           style='checkbox',
                           selections=landscapes,
                           type='text',
                           other=False)

    q4 = Question(identifier='Question 4',
                  content=qc4,
                  answer_spec=AnswerSpecification(fta4),
                  is_required=False)

    #--------------- BUILD THE QUESTION FORM -------------------

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
    question_form.append(q3)
    question_form.append(q4)

    #-------------- QUALIFICATIONS -------------------

    percent = PercentAssignmentsApprovedRequirement('GreaterThanOrEqualTo', 95)
    number = NumberHitsApprovedRequirement('GreaterThanOrEqualTo', 200)
    quals = Qualifications()
    quals.add(percent)
    quals.add(number)

    #--------------- CREATE THE HIT -------------------

    mtc.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   qualifications=quals,
                   annotation=image_url,
                   duration=60 * 10,
                   reward=0.03)
Ejemplo n.º 35
0
def check_notes_mailbox():
    MTURK_HOST = run_mturk('get_extract_keywords_results')
    if not MTURK_HOST:
        return

    try:
        MAILBOX_USER = os.environ['NOTES_MAILBOX_USERNAME']
        MAILBOX_PASSWORD = os.environ['NOTES_MAILBOX_PASSWORD']
        FILEPICKER_API_KEY = os.environ['FILEPICKER_API_KEY']
    except:
        logger.warn(
            'Could not find notes mailbox secrets, not running check_notes_mailbox'
        )
        return

    connection = MTurkConnection(settings.AWS_ACCESS_KEY_ID,
                                 settings.AWS_SECRET_ACCESS_KEY,
                                 host=MTURK_HOST)

    mailbox = poplib.POP3_SSL('pop.gmail.com', 995)
    mailbox.user(MAILBOX_USER)
    mailbox.pass_(MAILBOX_PASSWORD)
    numMessages = len(mailbox.list()[1])
    for i in range(numMessages):
        # construct message object from raw message
        raw_message_string = '\n'.join(mailbox.retr(i + 1)[1])
        message = email.message_from_string(raw_message_string)

        if not message.is_multipart():
            logger.warn('Got an email with no attachments')
            continue

        attachments = []
        message_body = ''

        message_parts = message.get_payload()
        for part in message_parts:
            # Look for the message's plain text body
            if part.get_content_type(
            ) == 'text/plain' and part['Content-Disposition'] is None:
                message_body = part.get_payload()

            # Look for attachments
            elif part['Content-Disposition'] and 'attachment;' in part[
                    'Content-Disposition']:
                attachment_mimetype = part.get_content_type()
                attachment_filename = re.search(
                    CONTENT_DISPOSITION_REGEX,
                    part['Content-Disposition']).group('filename')

                if part['Content-Transfer-Encoding'] == 'base64':
                    attachment_data = base64.decodestring(part.get_payload())
                else:
                    attachment_data = part.get_payload()

                # Upload attachment to filepicker
                resp = requests.post('https://www.filepicker.io/api/store/S3?key={key}&policy={policy}&' \
                                     'signature={signature}&mimetype={mimetype}&filename={filename}'
                                     .format(key=FILEPICKER_API_KEY, policy=FP_POLICY_READ_WRITE,
                                             signature=FP_SIGNATURE_READ_WRITE, mimetype=attachment_mimetype,
                                             filename=attachment_filename),
                                      data=attachment_data)

                if resp.status_code == 200:
                    url = json.loads(resp.text)['url']
                    url = url + '?policy={policy}&amp;signature={signature}'\
                        .format(policy=FP_POLICY_READ, signature=FP_SIGNATURE_READ)
                    attachments.append((url, attachment_filename))
                else:
                    logger.warn('Could not upload an attachment to filepicker')

        message_subject = message['Subject']

        overview = Overview()
        overview.append(
            FormattedContent(
                EMAIL_HIT_OVERVIEW_TEMPLATE.format(subject=message_subject,
                                                   body=message_body,
                                                   attachments='')))

        single_line_answer = FreeTextAnswer()
        single_line_answer.num_lines = 1

        question_form = QuestionForm()
        question_form.append(overview)

        course_spam_content = QuestionContent()
        course_spam_content.append_field(
            'Title',
            'Does the email contain course notes (check attachments below)?')
        answer = SelectionAnswer(style='dropdown',
                                 selections=[('No', 'no'), ('Yes', 'yes')])
        course_spam = Question(identifier=COURSE_SPAM_QID,
                               content=course_spam_content,
                               answer_spec=AnswerSpecification(answer),
                               is_required=True)
        question_form.append(course_spam)

        course_name_content = QuestionContent()
        course_name_content.append_field('Title', 'Course Name')
        course_name = Question(
            identifier=COURSE_NAME_QID,
            content=course_name_content,
            answer_spec=AnswerSpecification(single_line_answer),
            is_required=True)
        question_form.append(course_name)

        instructor_names_content = QuestionContent()
        instructor_names_content.append_field('Title', 'Instructor Name(s)')
        instructor_names = Question(
            identifier=INSTRUCTOR_NAMES_QID,
            content=instructor_names_content,
            answer_spec=AnswerSpecification(single_line_answer),
            is_required=False)
        question_form.append(instructor_names)

        school_name_content = QuestionContent()
        school_name_content.append_field('Title', 'School Name')
        school_name = Question(
            identifier=SCHOOL_NAME_QID,
            content=school_name_content,
            answer_spec=AnswerSpecification(single_line_answer),
            is_required=True)
        question_form.append(school_name)

        department_name_content = QuestionContent()
        department_name_content.append_field('Title', 'Department Name')
        department_name = Question(
            identifier=DEPARTMENT_NAME_QID,
            content=department_name_content,
            answer_spec=AnswerSpecification(single_line_answer),
            is_required=False)
        question_form.append(department_name)

        for i in range(len(attachments)):
            overview = Overview()
            overview.append(
                FormattedContent(
                    EMAIL_HIT_ATTACHMENT_OVERVIEW_TEMPLATE.format(
                        link=attachments[i][0], name=attachments[i][1])))

            question_form.append(overview)

            note_title_content = QuestionContent()
            note_title_content.append_field('Title', 'Note Title')
            note_title = Question(
                identifier=NOTE_TITLE_QID_TEMPLATE + str(i),
                content=note_title_content,
                answer_spec=AnswerSpecification(single_line_answer),
                is_required=True)
            question_form.append(note_title)

            note_category_content = QuestionContent()
            note_category_content.append_field('Title', 'Note Category')
            answer = SelectionAnswer(style='dropdown',
                                     selections=NOTE_CATEGORIES_FOR_MTURK)
            note_category = Question(identifier=NOTE_CATEGORY_QID_TEMPLATE +
                                     str(i),
                                     content=note_category_content,
                                     answer_spec=AnswerSpecification(answer),
                                     is_required=True)
            question_form.append(note_category)

        hit = connection.create_hit(questions=question_form,
                                    max_assignments=1,
                                    title=EMAIL_HIT_TITLE,
                                    description=EMAIL_HIT_DESCRIPTION,
                                    keywords=EMAIL_HIT_KEYWORDS,
                                    duration=EMAIL_HIT_DURATION,
                                    reward=EMAIL_HIT_REWARD,
                                    qualifications=EMAIL_HIT_QUALIFICATION)[0]
Ejemplo n.º 36
0
def create_crop_hit(mturk,
                    URLs,
                    num_assignment,
                    qualification=Qualifications()):
    # Constant data for HIT generation
    hit_title = "Photo Quality Assessment"
    hit_description = "This task involves viewing pairs of pictures and judging which picture among the image pair is more beautiful."
    lifetime = 259200
    keywords = ["photo", "quality", "ranking"]
    duration = 30 * 60
    reward = 0.05
    #approval_delay = 86400

    # Question form for the HIT
    question_form = QuestionForm()

    overview = Overview()
    overview.append_field('Title', 'Photo Quality Assessment')
    overview.append(
        FormattedContent(
            'For each question, please choose either the left or right image which you think is more beautiful in terms of its <u>composition</u>.'
        ))
    overview.append(
        FormattedContent(
            '<b>Hints: Please make your decision based on several "rules of thumb" in photography, such as rule of thirds, visual balance and golden ratio.</b>'
        ))
    #overview.append(FormattedContent('<b>You may also make your decision by judging which image contains less unimportant or distracting contents</b>.'))
    overview.append(
        FormattedContent(
            'For those hard cases, please just select your preferred image based on your sense of aesthetics.'
        ))
    question_form.append(overview)

    ratings = [('Left', '0'), ('Right', '1')]
    for i in xrange(len(URLs)):
        qc = QuestionContent()
        qc.append_field('Title', 'Question')
        qc.append_field(
            'Text',
            'Please indicate which one of the following images is more beautiful.'
        )
        qc.append(
            FormattedContent('<img src="' + URLs[i] +
                             '" alt="Image not shown correctly!"></img>'))
        #URLs[i]
        fta = SelectionAnswer(min=1,
                              max=1,
                              style='radiobutton',
                              selections=ratings,
                              type='text',
                              other=False)
        q = Question(identifier='photo_pair_' + str(i),
                     content=qc,
                     answer_spec=AnswerSpecification(fta),
                     is_required=True)
        question_form.append(q)

    hit_res = mturk.create_hit(
        title=hit_title,
        description=hit_description,
        reward=Price(amount=reward),
        duration=duration,
        keywords=keywords,
        #approval_delay=approval_delay,
        question=question_form,
        #lifetime=lifetime,
        max_assignments=num_assignment,
        qualifications=qualification)
    # return HIT ID
    return hit_res[0].HITId
Ejemplo n.º 37
0
def new_rate_hit(PIN_IMAGE_URL, PIN_IMAGE_TITLE, MACYS_IMAGE_URL,
                 MACYS_IMAGE_TITLE):
    mtc = MTurkConnection(aws_access_key_id=AWS_ACCESS_KEY_ID,
                          aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                          host=HOST)

    if debug: print mtc.get_account_balance()

    title = 'Match these Pictures to Macy\'s Products'
    description = 'Look at this photo and match it to Macy\'s products'
    keywords = 'clothing, rating, opinions, easy, quick, macys'

    ratings = [('Very Bad', '1'), ('Bad', '2'), ('OK', '3'), ('Good', '4'),
               ('Very Good', '5')]

    #make overview

    overview = Overview()
    overview.append_field('Title', 'Rank how these two images match.')
    overview.append(
        FormattedContent('<table border="1">><tr><td width="50%"><img src="' +
                         PIN_IMAGE_URL + '" alt="Pintrest Image" /></td>'
                         '<td width="50%"><img src="' + MACYS_IMAGE_URL +
                         '" alt="Macys Image" /></td></tr><tr>'
                         '<td width="50%">' + PIN_IMAGE_TITLE +
                         '</td><td width="50%">' + MACYS_IMAGE_TITLE +
                         '</td></tr></table>'))
    #make q1

    qc1 = QuestionContent()
    qc1.append_field('Title', 'Rank the match between these two')

    fta1 = SelectionAnswer(min=1,
                           max=1,
                           style='dropdown',
                           selections=ratings,
                           type='text',
                           other=False)

    q1 = Question(identifier='rating',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)

    #make q2

    qc2 = QuestionContent()
    qc2.append_field('Title', 'Comments about the HIT (Optional)')

    fta2 = FreeTextAnswer()

    q2 = Question(identifier="comments",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))

    #make question form

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)

    #--------------- CREATE THE HIT -------------------

    mtc.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration=60 * 5,
                   reward=0.05)
Ejemplo n.º 38
0
                      aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                      host=HOST)

if debug: print mtc.get_account_balance()

title = 'Match these Pictures to Macy\'s Products'
description = 'Look at this photo and match it to Macy\'s products'
keywords = 'clothing, rating, opinions, easy, quick, macys'

#make overview

overview = Overview()
overview.append_field('Title',
                      'Find three Macys.com Product Web IDs That Match')
overview.append(
    FormattedContent('<img src="' + PIN_IMAGE_URL + '" alt="Pintrest Image" />'
                     '<br />' + PIN_IMAGE_TITLE))

#make webid1

qc1 = QuestionContent()
qc1.append_field('Title', 'First WebID Code')

fta1 = FreeTextAnswer(num_lines=1)

q1 = Question(identifier="FirstWebCode",
              content=qc1,
              answer_spec=AnswerSpecification(fta1))

#make webid2
Ejemplo n.º 39
0
def check_notes_mailbox():
    try:
        MAILBOX_USER = os.environ['NOTES_MAILBOX_USERNAME']
        MAILBOX_PASSWORD = os.environ['NOTES_MAILBOX_PASSWORD']
        FILEPICKER_API_KEY = os.environ['FILEPICKER_API_KEY']
        MTURK_HOST = os.environ['MTURK_HOST']
    except:
        logger.warn('Could not find notes mailbox secrets, not running check_notes_mailbox')
        return

    connection = MTurkConnection(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY,
                                 host=MTURK_HOST)

    mailbox = poplib.POP3_SSL('pop.gmail.com', 995)
    mailbox.user(MAILBOX_USER)
    mailbox.pass_(MAILBOX_PASSWORD)
    numMessages = len(mailbox.list()[1])
    for i in range(numMessages):
        # construct message object from raw message
        raw_message_string = '\n'.join(mailbox.retr(i+1)[1])
        message = email.message_from_string(raw_message_string)

        if not message.is_multipart():
            logger.warn('Got an email with no attachments')
            continue

        attachments = []
        message_body = ''

        message_parts = message.get_payload()
        for part in message_parts:
            # Look for the message's plain text body
            if part.get_content_type() == 'text/plain' and part['Content-Disposition'] is None:
                message_body = part.get_payload()

            # Look for attachments
            elif part['Content-Disposition'] and 'attachment;' in part['Content-Disposition']:
                attachment_mimetype = part.get_content_type()
                attachment_filename = re.search(CONTENT_DISPOSITION_REGEX, part['Content-Disposition']).group('filename')

                if part['Content-Transfer-Encoding'] == 'base64':
                    attachment_data = base64.decodestring(part.get_payload())
                else:
                    attachment_data = part.get_payload()

                # Upload attachment to filepicker
                resp = requests.post('https://www.filepicker.io/api/store/S3?key={key}&policy={policy}&' \
                                     'signature={signature}&mimetype={mimetype}&filename={filename}'
                                     .format(key=FILEPICKER_API_KEY, policy=FP_POLICY_READ_WRITE,
                                             signature=FP_SIGNATURE_READ_WRITE, mimetype=attachment_mimetype,
                                             filename=attachment_filename),
                                      data=attachment_data)

                if resp.status_code == 200:
                    url = json.loads(resp.text)['url']
                    url = url + '?policy={policy}&amp;signature={signature}'\
                        .format(policy=FP_POLICY_READ, signature=FP_SIGNATURE_READ)
                    attachments.append((url, attachment_filename))
                else:
                    logger.warn('Could not upload an attachment to filepicker')

        message_subject = message['Subject']

        overview = Overview()
        overview.append(FormattedContent(
            EMAIL_HIT_OVERVIEW_TEMPLATE.format(subject=message_subject, body=message_body, attachments='')))

        single_line_answer = FreeTextAnswer()
        single_line_answer.num_lines = 1

        question_form = QuestionForm()
        question_form.append(overview)

        course_spam_content = QuestionContent()
        course_spam_content.append_field('Title', 'Does the email contain course notes (check attachments below)?')
        answer = SelectionAnswer(style='dropdown', selections=[('No', 'no'), ('Yes', 'yes')])
        course_spam = Question(identifier=COURSE_SPAM_QID,
                               content=course_spam_content,
                               answer_spec=AnswerSpecification(answer),
                               is_required=True)
        question_form.append(course_spam)

        course_name_content = QuestionContent()
        course_name_content.append_field('Title', 'Course Name')
        course_name = Question(identifier=COURSE_NAME_QID,
                               content=course_name_content,
                               answer_spec=AnswerSpecification(single_line_answer),
                               is_required=True)
        question_form.append(course_name)

        instructor_names_content = QuestionContent()
        instructor_names_content.append_field('Title', 'Instructor Name(s)')
        instructor_names = Question(identifier=INSTRUCTOR_NAMES_QID,
                                    content=instructor_names_content,
                                    answer_spec=AnswerSpecification(single_line_answer),
                                    is_required=False)
        question_form.append(instructor_names)

        school_name_content = QuestionContent()
        school_name_content.append_field('Title', 'School Name')
        school_name = Question(identifier=SCHOOL_NAME_QID,
                               content=school_name_content,
                               answer_spec=AnswerSpecification(single_line_answer),
                               is_required=True)
        question_form.append(school_name)

        department_name_content = QuestionContent()
        department_name_content.append_field('Title', 'Department Name')
        department_name = Question(identifier=DEPARTMENT_NAME_QID,
                                   content=department_name_content,
                                   answer_spec=AnswerSpecification(single_line_answer),
                                   is_required=False)
        question_form.append(department_name)

        for i in range(len(attachments)):
            overview = Overview()
            overview.append(FormattedContent(
                EMAIL_HIT_ATTACHMENT_OVERVIEW_TEMPLATE.format(link=attachments[i][0], name=attachments[i][1])))

            question_form.append(overview)

            note_title_content = QuestionContent()
            note_title_content.append_field('Title', 'Note Title')
            note_title = Question(identifier=NOTE_TITLE_QID_TEMPLATE + str(i),
                                  content=note_title_content,
                                  answer_spec=AnswerSpecification(single_line_answer),
                                  is_required=True)
            question_form.append(note_title)

            note_category_content = QuestionContent()
            note_category_content.append_field('Title', 'Note Category')
            answer = SelectionAnswer(style='dropdown', selections=NOTE_CATEGORIES_FOR_MTURK)
            note_category = Question(identifier=NOTE_CATEGORY_QID_TEMPLATE + str(i),
                                     content=note_category_content,
                                     answer_spec=AnswerSpecification(answer),
                                     is_required=True)
            question_form.append(note_category)


        hit = connection.create_hit(questions=question_form, max_assignments=1,
                      title=EMAIL_HIT_TITLE, description=EMAIL_HIT_DESCRIPTION,
                      keywords=EMAIL_HIT_KEYWORDS, duration=EMAIL_HIT_DURATION,
                      reward=EMAIL_HIT_REWARD, qualifications=EMAIL_HIT_QUALIFICATION)[0]
Ejemplo n.º 40
0
def createhitsubmit(request):
    '''
    Submitting mkturk to amazon web service.
    @param request: Django http request containing keys and other task arguments.
    '''
    from boto.mturk.connection import MTurkConnection
    from boto.mturk.question import QuestionContent,Question,QuestionForm,Overview,AnswerSpecification,SelectionAnswer,FormattedContent,FreeTextAnswer
    print 'Ok'
    # Get request data from the front-end
    requestJson = json.loads(request.body)    
    
    user_aws_secret_key = requestJson['aws_secret_key']    
    user_aws_access_key_id = requestJson['aws_access_key_id']
    task_selected_docs = requestJson['task_selected_docs'] #id
    task_title = requestJson['task_title']
    #task_dataset = requestJson['task_dataset'] # id   
    task_description = requestJson['task_description']
    task_duration = requestJson['task_duration']
    task_max_assignment = requestJson['task_max_assignment']
    task_reward = requestJson['task_reward']
        
    # adjust host setting, depending on whether HIT is live (production) or in testing mode (sandbox)
    mode = "sandbox"
    #mode ="production"

    if mode=="production":
        HOST='mechanicalturk.amazonaws.com'
    else:
        HOST='mechanicalturk.sandbox.amazonaws.com'

    mtc = MTurkConnection(aws_access_key_id= user_aws_access_key_id,
                      aws_secret_access_key= user_aws_secret_key,
                      host=HOST)
                      
    overview = Overview()
    overview.append_field('Title', task_title)
    overview.append(FormattedContent('<b>' + task_description + '</b><p></p>'))
       
    tableStr = '<ul>'
    for docID in task_selected_docs:
        docText = Doc.objects.get(pk = docID)
        tableStr += '<li>' + docText.text + '</li>'
    tableStr += '</ul>' 
    overview.append(FormattedContent(tableStr))
    
    qc2 = QuestionContent()
    qc2.append_field('Title','What do you find?')
     
    fta2 = FreeTextAnswer()
     
    q2 = Question(identifier="comments",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))
     
    #--------------- BUILD THE QUESTION FORM -------------------
     
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q2)
    print 'Before create hit'
    #--------------- CREATE THE HIT -------------------
    
    try:
        creathitReturnValue = mtc.create_hit(questions=question_form,
                                                           max_assignments= task_max_assignment,
                                                           title=task_title,
                                                           description=task_description,
                                                           keywords='SomeKeywords',
                                                           duration = task_duration,
                                                           reward= task_reward)
    except Exception as e:
        print e

    print 'after crate hit'
    
    return HttpResponse(json.dumps({'data' : mtc.get_account_balance()}), content_type = "application/json")
Ejemplo n.º 41
0
print mtc.get_account_balance()

title = 'Give your opinion about categorizing shopping items'
description = ('Visit a website and mark the categories'
               ' that you think are relevant about the product shown to you')
keywords = 'categorization, amazon shopping, rating'

ratings = [('Very Bad', '-2'), ('Bad', '-1'), ('Not bad', '0'), ('Good', '1'),
           ('Very Good', '1')]

#---------------  BUILD OVERVIEW -------------------

overview = Overview()
overview.append_field('Title', 'Give your opinion on this website')
overview.append(
    FormattedContent('<a target="_blank"'
                     ' href="http://www.toforge.com">'
                     ' Mauro Rocco Personal Forge</a>'))

#---------------  BUILD QUESTION 1 -------------------

qc1 = QuestionContent()
qc1.append_field('Title', 'How looks the design ?')

fta1 = SelectionAnswer(min=1,
                       max=1,
                       style='dropdown',
                       selections=ratings,
                       type='text',
                       other=False)

q1 = Question(identifier='design',
Ejemplo n.º 42
0
def demo_create_favorite_color_hit():
    """A HIT to determine the Worker's favorite color"""

    TITLE = 'Tell me your favorite color'
    DESCRIPTION = ('This is a HIT that is created by a computer program '
                   'to demonstrate how Mechanical Turk works. This should '
                   'be a free HIT for the worker.')
    KEYWORDS = 'data collection, favorite, color'
    DURATION = 15 * 60  # 15 minutes (Time to work on HIT)
    MAX_ASSIGNMENTS = 1  # Number of assignments per HIT
    REWARD_PER_ASSIGNMENT = 0.00  # $0.00 USD (1 cent)

    #--------------- BUILD HIT container -------------------
    overview = Overview()
    overview.append_field('Title', TITLE)
    overview.append(
        FormattedContent(
            "<p>This is an experiment to learn Mechanical Turk</p>"))

    #---------------  BUILD QUESTION 1 -------------------
    question_content = QuestionContent()
    question_content.append(
        FormattedContent(
            "<b>What is your favorite color?</b> There isn't a financial "
            "reward for answering, but you will get an easy approval for your "
            "statistics."))

    free_text_answer = FreeTextAnswer(num_lines=1)

    q1 = Question(identifier='favorite_color',
                  content=question_content,
                  answer_spec=AnswerSpecification(free_text_answer),
                  is_required=True)

    #---------------  BUILD QUESTION 3 -------------------
    question_content = QuestionContent()
    question_content.append(
        FormattedContent("""<p>Give me a fun comment:</p>"""))

    q2 = Question(identifier="comments",
                  content=question_content,
                  answer_spec=AnswerSpecification(FreeTextAnswer()))

    #--------------- BUILD THE QUESTION FORM -------------------
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)

    #--------------- CREATE THE HIT -------------------
    mtc = get_connection()
    hit = mtc.create_hit(questions=question_form,
                         max_assignments=MAX_ASSIGNMENTS,
                         title=TITLE,
                         description=DESCRIPTION,
                         keywords=KEYWORDS,
                         duration=DURATION,
                         reward=REWARD_PER_ASSIGNMENT)

    #---------- SHOW A LINK TO THE HIT GROUP -----------
    base = get_worker_url()

    print "\nVisit this website to see the HIT that was created:"
    print "%s/mturk/preview?groupId=%s" % (base, hit[0].HITTypeId)

    return hit[0]
Ejemplo n.º 43
0
def new_sugg_hit(PIN_IMAGE_URL, PIN_IMAGE_TITLE):

    mtc = MTurkConnection(aws_access_key_id=AWS_ACCESS_KEY_ID,
                          aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                          host=HOST)

    if debug: print mtc.get_account_balance()

    title = 'Match these Pictures to Macy\'s Products'
    description = 'Look at this photo and match it to Macy\'s products'
    keywords = 'clothing, rating, opinions, easy, quick, macys'

    #make overview

    overview = Overview()
    overview.append_field('Title',
                          'Find three Macys.com Product Web IDs That Match')
    overview.append(
        FormattedContent('<img src="' + PIN_IMAGE_URL +
                         '" alt="Pintrest Image" />'
                         '<br />' + PIN_IMAGE_TITLE))

    #make webid1

    qc1 = QuestionContent()
    qc1.append_field('Title', 'First WebID Code')

    fta1 = FreeTextAnswer(num_lines=1)

    q1 = Question(identifier="FirstWebCode",
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1))

    #make webid2

    qc2 = QuestionContent()
    qc2.append_field('Title', 'Second WebID Code')

    fta2 = FreeTextAnswer(num_lines=1)

    q2 = Question(identifier="SecondWebCode",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))

    #make webid1

    qc3 = QuestionContent()
    qc3.append_field('Title', 'Third WebID Code')

    fta3 = FreeTextAnswer(num_lines=1)

    q3 = Question(identifier="ThirdWebCode",
                  content=qc3,
                  answer_spec=AnswerSpecification(fta3))

    #make question form

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
    question_form.append(q3)

    #--------------- CREATE THE HIT -------------------

    mtc.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration=60 * 5,
                   reward=0.05)
Ejemplo n.º 44
0
entire entry as one line.  Do hit enter between entries.
If there is a hyphen and the next line is available, then do not transcribe
the hypen; just merge the two lines.  If there is a phonetic pronounciation
listed in brackets (e.g. [kudg]) then do not transcribe it.  If there is a hypen on the last
line of the column, then transcribe it as a single dash ('-')"""


# 60 to 407
for i in range(60,61):
  for side in ( 'left', 'right' ):
    title = 'Transcribe Palauan Dictionary Page %d Column %s' % (i , side)
    #---------------  BUILD OVERVIEW -------------------
     
    overview = Overview()
    overview.append_field('Title', title)
    overview.append(FormattedContent(description))
    url="http://tekinged.com/png-halves/dict-%03d-%s.png" % (i,side)
    content="<a href='%s'><img alt='IMAGE TO TRANSCRIBE' src='%s' width='50%%' /></a>" % (url,url)
    print "Entering hit for %s" % url
    overview.append(FormattedContent("Use these links to see an example image and how it should be transcribed"))
    overview.append(FormattedContent('<a target="_blank"'
                                     ' href="http://tekinged.com/misc/mturk/image.png">'
                                     ' Example Image</a>'))
    overview.append(FormattedContent('<a target="_blank"'
                                     ' href="http://tekinged.com/misc/mturk/text.png">'
                                     ' Example Transcription</a>'))
    overview.append(FormattedContent("Here is the image to be transcribed:"))
    overview.append(FormattedContent(content))
   
     
    #--------------- BUILD THE QUESTION FORM -------------------
Ejemplo n.º 45
0
    def SubmitHIT(self, sandbox = 'false'):
        """
        Constructs a HIT from the HITGenerator's attributes, registers it with Amazon, and returns the HITId as a unicode string.

        If the sandbox flag is set to true then the hit will be registered with the Sandbox, otherwise it is registered to AWS
        directly.  All of the necessary data must have been submitted during the HITGenerator's initiation.
        """

        if sandbox is 'true':
            self.host = 'mechanicalturk.sandbox.amazonaws.com'

        conn = MTurkConnection(host = self.host, aws_access_key_id = self.AWS_KEY, aws_secret_access_key = self.AWS_SECRET)

        answer_specification = AnswerSpecification(SelectionAnswer(style = self.answer_style, selections = self.answer_options))
        
        overview_content = """<p>Your task is to translate the Urdu sentences into English.  Please make sure that your English translation:</p>
<ul>
    <li>Is faithful to the original in both meaning and style</li>
    <li>Is grammatical, fluent, and natural-sounding English</li>
    <li>Does not add or delete information from the original text</li>
    <li>Does not contain any spelling errors</li>
</ul>
<p>When creating your translation, please follow these guidelines:</p>
<ul>
    <li><b>Do not use any machine translation systems (like translation.babylon.com)</b></li>
    <li><b>You may</b> look up a word on <a href="http://www.urduword.com/">an online dictionary</a> if you do not know its translation</li></ul>
<p>Afterwards, we'll ask you a few quick questions about your language abilities.</p>
"""

        overview = Overview()
        overview.append('Title', 'Translate these sentences')
        overview.append('FormattedContent', overview_content) 
        
        qc = QuestionContent()
        the_text = "Some arabic Words."
        qc.append('FormattedContent', u'<table><tr><td></td><td align="right" width="538">%s</td></tr></table>' % the_text)

        
       # construct an answer field
        fta = FreeTextAnswer()
        ansp = AnswerSpecification(fta)
        
        q = Question(identifier=str(uuid.uuid4()),
                     content=qc,
                     answer_spec=ansp)
        
       # put question(s) in a list
        ql = [q,q,q,q] # repeat question four times

       # build question form with question list
        qf = QuestionForm(ql, overview=overview)
        
        self.hit_response = conn.create_hit(question = qf,
                                            lifetime = self.lifetime,
                                            max_assignments = self.assignment_count,
                                            title = self.title,
                                            description = self.description,
                                            keywords = self.keywords,
                                            reward = self.reward,
                                            )
        
        # Returns the HITId as a unicode string
        print self.hit_response
#        self.HITId = self.hit_response.HITId
#        return self.HITId
        return self.hit_response
Ejemplo n.º 46
0
description = ('Visit a website and give us your opinion about'
               ' the design and also some personal comments')
keywords = 'website, rating, opinions'
 
ratings =[('Very Bad','-2'),
         ('Bad','-1'),
         ('Not bad','0'),
         ('Good','1'),
         ('Very Good','1')]
 
#---------------  BUILD OVERVIEW -------------------
 
overview = Overview()
overview.append_field('Title', 'Give your opinion on this website')
overview.append(FormattedContent('<a target="_blank"'
                                 ' href="http://www.toforge.com">'
                                 ' Mauro Rocco Personal Forge</a>'))
 
#---------------  BUILD QUESTION 1 -------------------
 
qc1 = QuestionContent()
qc1.append_field('Title','How looks the design ?')
 
fta1 = SelectionAnswer(min=1, max=1,style='dropdown',
                      selections=ratings,
                      type='text',
                      other=False)
 
q1 = Question(identifier='design',
              content=qc1,
              answer_spec=AnswerSpecification(fta1),
Ejemplo n.º 47
0
title = 'Match these Pictures to Macy\'s Products'
description = 'Look at this photo and match it to Macy\'s products'
keywords = 'clothing, rating, opinions, easy, quick, macys'

ratings = [('Very Bad', '1'), ('Bad', '2'), ('OK', '3'), ('Good', '4'),
           ('Very Good', '5')]

#make overview

overview = Overview()
overview.append_field('Title', 'Rank how these two images match.')
overview.append(
    FormattedContent('<table border="1"><tr><td width="50%"><img src="' +
                     PIN_IMAGE_URL + '" alt="Pintrest Image" /></td>'
                     '<td width="50%"><img src="' + MACYS_IMAGE_URL +
                     '" alt="Macys Image" /></td></tr><tr>'
                     '<td width="50%">' + PIN_IMAGE_TITLE +
                     '</td><td width="50%">' + MACYS_IMAGE_TITLE +
                     '</td></tr></table>'))
#make q1

qc1 = QuestionContent()
qc1.append_field('Title', 'Rank the match between these two')

fta1 = SelectionAnswer(min=1,
                       max=1,
                       style='dropdown',
                       selections=ratings,
                       type='text',
                       other=False)
Ejemplo n.º 48
0
title = 'Match these Pictures to Macy\'s Products'
description = 'Look at this photo and match it to Macy\'s products'
keywords = 'clothing, rating, opinions, easy, quick, macys'

ratings =[('Very Bad','1'),
         ('Bad','2'),
         ('OK','3'),
         ('Good','4'),
         ('Very Good','5')]
 
#make overview
 
overview = Overview()
overview.append_field('Title', 'Rank how these two images match.')
overview.append(FormattedContent('<table border="1"><tr><td width="50%"><img src="'+PIN_IMAGE_URL+'" alt="Pintrest Image" /></td>'
                                 '<td width="50%"><img src="'+MACYS_IMAGE_URL+'" alt="Macys Image" /></td></tr><tr>'
                                 '<td width="50%">'+PIN_IMAGE_TITLE+'</td><td width="50%">'+MACYS_IMAGE_TITLE+'</td></tr></table>'))
#make q1
 
qc1 = QuestionContent()
qc1.append_field('Title','Rank the match between these two')
 
fta1 = SelectionAnswer(min=1, max=1,style='dropdown',
                      selections=ratings,
                      type='text',
                      other=False)
 
q1 = Question(identifier='rating',
              content=qc1,
              answer_spec=AnswerSpecification(fta1),
              is_required=True)
Ejemplo n.º 49
0
def create_hit(img_url):

    mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                          aws_secret_access_key=SECRET_KEY,
                          host=HOST)

    title = 'Handwriting Analysis'
    description = ('Describe the Hand Writing'
                   ' in Image Provided')

    keywords = 'transcribe, handwriting, opinion'

    #---------------  BUILD OVERVIEW -------------------

    overview = Overview()
    overview.append_field('Title', 'Give your opinion on the handwriting')
    binary_content = Binary('image', 'jpeg', img_url, alt_text='image is missing')
    overview.append(binary_content)

    #---------------  BUILD Appearance -------------------

    qc1 = QuestionContent()
    qc1.append_field('Title','Rate the overall appearance of the handwriting.' )

    fta1 = SelectionAnswer(min=1, max=1,style='dropdown',
                          selections=ratings,
                          type='text',
                          other=False)

    q1 = Question(identifier='design',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)

    #---------------  BUILD Transcription -------------------

    qc2 = QuestionContent()
    qc2.append_field('Title','Enter the Sentence above exactly how you see it. '
                     'Include the Case and Spacing Between Each Letter')

    fta2 = FreeTextAnswer()

    q2 = Question(identifier="comments",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))

    #--------------- BUILD THE QUESTION FORM -------------------

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)

    #--------------- CREATE THE HIT -------------------

    mtc.create_hit(questions=question_form,
                   max_assignments=20,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration = 60*5,
                   reward=0.10)