Learn R Programming

MTurkR (version 0.8.0)

GenerateHITLayoutParameter: Generate a HITLayout Parameter

Description

Generate a HITLayout parameter based upon the names of HIT template variables and the values to substitute for those variables in a single HIT. Used in collaboration with a HIT Layout ID from https://requester.mturk.com/create/projects in the CreateHIT operation.

Usage

GenerateHITLayoutParameter(names, values)

Arguments

names

A character string containing the name of a HIT template variable or a vector of character strings containing the names of multiple HIT template variables. This is optional if values has a non-empty names attribute.

values

A character string containing the value of a HIT template variable to be inserted for a specific HIT or a vector of character strings containing the values of multiple HIT template variables to be inserted for a specific HIT. If values has a non-empty names attribute and names is missing, the names attribute is used.

Value

A character string containing URL query parameter-formatted HITLayout parameters, to be used in the hitlayoutparameters parameter of CreateHIT.

Details

This function provides the content for the hitlayoutparameters option of CreateHIT. Specifically, a HIT Template created in the MTurk Requester User Interface (RUI) has a number of placeholder variables for content to be inserted. This fucntion supplies the content to be inserted into the template for one HIT. If multiple HITs are being created from one template, then GenerateHITLayoutParameter should be run once for each HIT.

Analogous functionality for producing .html files on the local workstation (e.g., to create multiple external HITs from the same template) is provided by GenerateHITsFromTemplate.

References

API Reference

See Also

CreateHIT

GenerateExternalQuestion

GenerateHITsFromTemplate

Examples

Run this code
# NOT RUN {
# examples of specifying 'names' and 'values'
a <- GenerateHITLayoutParameter(names = "hitvariable", 
                                values = "Text for HIT 1")
b <- GenerateHITLayoutParameter(names = "hitvariable", 
                                values = "Text for HIT 2")
c <- GenerateHITLayoutParameter(names = c("hitvariable1","hitvariable2"),
                                values = c("Headline for HIT1","Text for HIT 1"))

# example using a named character string in lieu of specifying 'names'
d <- GenerateHITLayoutParameter(values = c(hitvariable1 = "Headline for HIT1", 
                                           hitvariable2 = "Text for HIT 1"))

# create HIT using layout parameter
hit1 <- 
CreateHIT(title = "Survey",
          description = "5 question survey",
          reward = ".10",
          expiration = seconds(days=4),
          duration = seconds(hours = 1),
          keywords = "survey, questionnaire",
            # retrieved from MTurk web interface:
          hitlayoutid = "23ZGOOGQSCM61T1H5H9U0U00OQWFFU", 
          hitlayoutparameters = a)

# cleanup
DisableHIT(hit1$HITId)
# }

Run the code above in your browser using DataLab