AssembleMultiTab: Assemble HIT parts into complete HTML with multiple tabs

Description Usage Arguments Details Value

View source: R/assembleMultiTab.R

Description

Takes parameterized inputs from multiple script and HTML files to make one complete file containing multiple tabs. This function is great for making multiple training HITs within one file to be placed on a server. Answers are scored but grades are not retained, and feedback can be given with the dynamic checkAnswers.js script and answer justification elements users can add to the HTML.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  AssembleMultiTab(ansVars=NULL,
                   inputLoc="input/",
                   quiet=TRUE,
                   write.to=NULL,
                   content=NULL,
                   innerHTML.html=NULL,
                   exampleShell.html=NULL,
                   exampleTab.html=NULL,
                   multiTabShell.html=NULL,
                   checkAnswers.js=NULL,
                   outerScript.js=NULL,
                   skipPattern.js=NULL)

Arguments

ansVars

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\".

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\").

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.

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.

exampleShell.html

HTML containing the code that surrounds the HIT within a given tab. This is useful for locating check answers button, as well as navigation buttons. See details below.

exampleTab.html

Simple HTML code to add Bootstrap tabs for each separate training HIT. See details below.

multiTabShell.html

HTML containing the outer shell the HIT. This serves as the backbone into which all of the other code is assembled. 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.

checkAnswers.js

Javascript or jQuery that enables answer checking and instant feedback. 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.