AssembleHITHTML: Assemble HIT parts into complete HTML

Description Usage Arguments Details Value

View source: R/assembleHITHTML.R

Description

Takes parameterized inputs from multiple script and HTML files to make one complete file. This function has two main uses: 1) Filling in all parameters, and making the HTML for a complete external HIT on MTurk. This includes filling in all content data (e.g., filling in titles, abstracts, questions, urls, or any other parameters that change in a series of HITs). 2) Assembling the script and HTML files together, leaving select parameters in tact, thus creating a template. This use would be useful for making the full shell for the content to be incorporated dynamically. Options in this function also allow for the creation of 'honey pot' hits with known answers.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  AssembleHITHTML(honeyPot=FALSE,
                  honeyPotVars=NULL,
                  inputLoc="input",
                  content=NULL,
                  quiet=TRUE,
                  write.to=NULL,
                  sandbox=TRUE,
                  innerHTML.html=NULL,
                  skipPattern.js=NULL,
                  outerScript.js=NULL,
                  honeyScript.js=NULL,
                  hitShell.html =NULL,
                  honeyShell.html=NULL,
                  honeyButton.html=NULL,
                  hitButton.html=NULL)

Arguments

honeyPot

logical. Default is FALSE. TRUE tells the function to create a honey pot with known answers.

honeyPotVars

the variable names to use for the honey pot. Required is honeyPot = TRUE. These must match the column names of known answers in the content object.

inputLoc

the input file location for the input files. Not needed if files or code is directly entered into the function. Directory name should be only the string with no terminal slash (e.g., the default is \"input\".

content

named array or data.frame. Names are passed in to replace parameterized values in the imported data (e.g., ${annotation}). The required content depends on the content of the HIT. If content has more than one row, only the first row of data will be used, with a warning.

quiet

logical. Default is TRUE. Determines whether additional information about the file assembly should be displayed and whether the final HTML should be output to the console. If this is TRUE and write.to is FALSE, a warning will display that no output method has been selected.

write.to

a string of where to write the html file (e.g., \"output/HIT.html\").

sandbox

logical. Default is TRUE. Sets the external HIT submit code to the live MTurk site or the workersandbox.

innerHTML.html

HTML containing the inner body of the HIT. This code will be the same as used for intsance in MakeTrainingTabs. It should have parameterized values for content, such as ${Title} or ${Abstract} to be able to programmatically fill in HIT content. See details below.

skipPattern.js

Javascript or jQuery that defines a skip pattern for questions. Optional. This is useful if some questions are irrelevant if a particular answer is given (e.g., if a study is not a randomized controlled trial, questions on randomization would be irrelevant). See details below.

outerScript.js

Javascript or jQuery for overall behavior of the HIT. The default script comes with helper functions for selecting cells in tables, enabling Bootstrap popovers, and enabling Bootstrap tooltips. See details below.

honeyScript.js

Javascript or jQuery that enables answer checking and dynamic form controls when a honey pot is uploaded. Required if honeyPot is TRUE. See details below.

hitShell.html

HTML containing additional content for the HIT, such as instructions and buttons. This is the backbone into which the submit buttons, script, and innerHTML will be assembled. See details below.

honeyShell.html

HTML containing additional content for the HIT for honey pots, replacing the hitShell.html. Required if honeyPot is TRUE. See details below.

hitButton.html

Short HTML code to define the HIT submit button. See details below.

honeyButton.html

Dynamic HTML code that interacts with honeyScript.js to change the submit button based on honey pot answers. Required if honeyPot is TRUE. See details below.

Details

For any of the required files, input can take three forms.

The default is NULL, which signals to the function that all required files will be found in the folder specified by inputLoc (e.g., honeyButton.html is expected, by default, to be in the subfolder input).

Files can be specified if defined in with the file function. For instance, if the innerHTML.html file was named hitHTML.txt in the current working directory, the input would be innerHTML.html = file("hitHTML.txt").

Finally, the input can be created and inserted as objects. This is particularly useful for the content object. For instance, if one wanted to input the content from a file as well as additional parameters, one could assemble the content object and pass it to the function (e.g., one could read an file with gold-standard answers in to R, append additional columns containing the title and abstract, and pass this complete object to the function).

Value

The returned object is either a long string that contains the assembled HTML code (if quiet is FALSE), or is output to a file if write.to is defined.


andrewbrownphd/MetaTurkR documentation built on Nov. 23, 2019, 4:17 p.m.