Learn R Programming

MTurkR (version 0.8.0)

GenerateHTMLQuestion: Generate HTMLQuestion

Description

Generate an HTMLQuestion data structure for use in the ‘Question’ parameter of CreateHIT.

Usage

GenerateHTMLQuestion(character = NULL, file = NULL, frame.height = 450)

Arguments

character

An optional character string from which to construct the HTMLQuestion data structure.

file

An optional character string containing a filename from which to construct the HTMLQuestion data structure.

frame.height

A character string containing the integer value (in pixels) of the frame height for the HTMLQuestion iframe.

Value

A list containing xml.parsed, an XML data structure, string, xml formatted as a character string, and url.encoded, character string containing a URL query parameter-formatted HTMLQuestion data structure for use in the question parameter of CreateHIT.

Details

Must specify either character or file.

To be valid, an HTMLQuestion data structure must be a complete XHTML document, including doctype declaration, head and body tags, and a complete HTML form (including the form tag with a submit URL, the assignmentId for the assignment as a form field, at least one substantive form field (can be hidden), and a submit button that posts to the external submit URL; see GenerateExternalQuestion.). If you fail to include a complete form, workers will be unable to submit the HIT. See the API Documentation for a complete example.

MTurkR comes pre-installed with several simple examples of HTMLQuestion HIT templates, which can be found by examining the templates directory of the installed package directory. These examples include simple HTMLQuestion forms, as well as templates for categorization, linking to off-site surveys, and sentiment analysis. Note that the examples, while validated complete, do not include CSS styling.

References

API Reference

See Also

CreateHIT

GenerateExternalQuestion

GenerateHITLayoutParameter

Examples

Run this code
# NOT RUN {
f <- system.file("templates/htmlquestion1.xml", package = "MTurkR")
a <- GenerateHTMLQuestion(file=f)

hit1 <- 
CreateHIT(title = "Survey",
          description = "5 question survey",
          reward = ".10",
          expiration = seconds(days = 4),
          duration = seconds(hours = 1),
          keywords = "survey, questionnaire",
          question = a$string)

ExpireHIT(hit1$HITId)
DisposeHIT(hit1$HITId)
# }

Run the code above in your browser using DataLab