Skip to content
This repository was archived by the owner on May 24, 2019. It is now read-only.

BulkCreate

Thomas J. Leeper edited this page May 17, 2015 · 6 revisions

The CreateHIT function allows a requester to create a single HIT. As of MTurkR v0.6.4, it is also possible to create multiple HITs in a single function call using BulkCreate. This function takes multiple question values and creates one HIT for each value, using a fixed set of other parameters. While this does not create a "batch" in the sense used by the Requester User Interface, BulkCreate requires an annotation argument so that all of the HITs can easily be operated on using functions such as ExpireHIT, ExtendHIT, etc.

In addition to BulkCreate, three additional bulk creation wrapper functions have been added:

  1. BulkCreateFromURLs is an easy way to create ExternalQuestion HITs, by simply supplying a vector of HIT URLs. This will create one HIT for each URL, and group them under a common title, description, etc. The annotation field is required:

    ```R
    BulkCreateFromURLs(url = paste0("https://www.example.com/",1:3,".html"),
                       frame.height = 400,
                       annotation = paste("Bulk From URLs", Sys.Date()),
                       title = "Categorize an image",
                       description = "Categorize this image",
                       reward = ".05",
                       expiration = seconds(days = 4),
                       duration = seconds(minutes = 5),
                       keywords = "categorization, image, moderation, category")
    ```
    
  2. BulkCreateFromTemplate can be used to create a set of HITs from a template HTML file, in the style of the Requester User Interface (i.e., the CSV upload feature of the RUI). If you (a) create an HTML file with placeholders for a set of variables (e.g., ${varname}) and (b) create a data.frame of variable values, this function will create a HIT structure from the template for each row of the data.frame and then create a HIT from each of those completed templates. Here's an example of an HTML template:

    ```HTML
    <!DOCTYPE html>
    <html>
     <head>
      <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
      <script type='text/javascript' src='https://s3.amazonaws.com/mturk-public/externalHIT_v1.js'></script>
     </head>
     <body>
      <form name='mturk_form' method='post' id='mturk_form' action='https://www.mturk.com/mturk/externalSubmit'>
      <input type='hidden' value='' name='assignmentId' id='assignmentId'/>
      <h1>${hittitle}</h1>
      <p>${hitvariable}</p>
      <p>What do you think?</p>
      <p><textarea name='comment' cols='80' rows='3'></textarea></p>
      <p><input type='submit' id='submitButton' value='Submit' /></p></form>
      <script language='Javascript'>turkSetAssignmentID();</script>
     </body>
    </html>
    ```
    

    And here's MTurkR code:

    ```R
    temp <- system.file("template.html", package = "MTurkR")
    a <- data.frame(hittitle = c("HIT title 1", "HIT title 2", "HIT title 3"),
                    hitvariable = c("HIT text 1", "HIT text 2", "HIT text 3"), 
                    stringsAsFactors = FALSE)
    BulkCreateFromTemplate(template = temp,
                           input = a,
                           annotation = paste("Bulk From Template", Sys.Date()),
                           title = "Categorize an image",
                           description = "Categorize this image",
                           reward = ".05",
                           expiration = seconds(days = 4),
                           duration = seconds(minutes = 5),
                           keywords = "categorization, image, moderation, category")
    ```
    
  3. The final BulkCreateFromHITLayout uses the same logic of a template HTML file and an input data.frame. In this workflow, however, the template is created in the Requester User Interface (RUI), the "HITLayoutId" for that template is retrieved from the RUI, and the variable values are passed to the BulkCreateFromHITLayout function. You can find an example of this workflow here, which closely mirrors the previous example.

Clone this wiki locally