Learn R Programming

MTurkR (version 0.8.0)

GenerateAnswerKey: Generate AnswerKey Data Structure

Description

Generate an AnswerKey data structure for a Qualification test.

Usage

GenerateAnswerKey(questions, scoring = NULL)
AnswerKeyTemplate(xml.parsed = NULL)

Arguments

questions

A data frame containing QuestionIdentifiers, AnswerOptions, AnswerScores, and DefaultScores. See MTurk API Documentation.

scoring

An optional list containing QualificationValueMapping information. See MTurk API Documentation.

xml.parsed

A complete QuestionForm data structure parsed by xmlParse. Must specify this or the xml parameter.

Value

GenerateAnswerKey returns a list containing an AnswerKey data structure as a parsed XML tree, character string containing that tree, and a url-encoded character string.

AnswerKeyTemplate returns a list that can be used in the questions parameter of GenerateAnswerKey. Placeholders are left for AnswerScore values to be manually entered prior to using it in GenerateAnswerKey.

Details

GenerateAnswerKey creates an AnswerKey data structure (possibly from a template created by AnswerKeyTemplate from a QuestionForm data structure), which serves to automatically score a Qualification test, as specified in the test parameter of CreateQualificationType. An AnswerKey data structure is also returned by GetQualificationType.

References

API Reference

See Also

CreateQualificationType

Examples

Run this code
# NOT RUN {
# generate an AnswerKey from a list of arguments
qs <- list(list(QuestionIdentifier = "Question1",
                AnswerOption = list(SelectionIdentifier="A", AnswerScore=15),
                AnswerOption = list(SelectionIdentifier="B", AnswerScore=10),
                DefaultScore = 5),
           list(QuestionIdentifier = "Question2",
                AnswerOption = list(SelectionIdentifier="D", AnswerScore=10) ) )

scoring1 <- list(PercentageMapping=5)

scoring2 <- list(RangeMapping=list(list(InclusiveLowerBound=0,
                                        InclusiveUpperBound=20,
                                        QualificationValue=5),
                                   list(InclusiveLowerBound=21,
                                        InclusiveUpperBound=100,
                                        QualificationValue=10)),
                 OutOfRangeQualificationValue=0)

ak1 <- GenerateAnswerKey(qs, scoring1)
ak2 <- GenerateAnswerKey(qs, scoring2)

# generate an AnswerKey template from a QualificationTest
qt <- system.file("templates", "qualificationtest1.xml", package = "MTurkR")
akt <- AnswerKeyTemplate(xmlParse(qt))
# use the template to generate an AnswerKey
ak <- GenerateAnswerKey(ak)
# }

Run the code above in your browser using DataLab