CreateRandomExams: CreateRandomExams

Description Usage Arguments Details Value See Also

View source: R/Wrappers.R


This function creates a series of randomized exams from a tex document and personalizes the information from a table (if a table is given) and a series of command names where thae information shoudl be replaced.


CreateRandomExams(x, layersNames = c("questions", "choices"),
  layersCmd = c("question", "(choice|CorrectChoice)"), outputBaseName,
  outputDirectory, cmdReorder = rep_len(TRUE, length(layersNames)),
  sectionReorder = FALSE, infoTable = NULL, colNames = NULL,
  cmdNames = NULL, nOutputVersions = nrow(infoTable),
  nOutputQuestions = "max", answerSheetCorrectTag = NULL,
  answerSheetWrongTag = NULL, optionList = NULL)



A character vector, each element represents one line of the latex document


A character vector, with each element representating the environment name to be searched as cmdName as describe in FindBegin and FindEnd


A character vector, with the same length as layersNames. with each element representing the environment command to be serached as cmdName as described in FindCommand.


String, The basename for the output files.


String, The output directory.

cmdReorder, sectionReorder

Logical vector, the length of cmdReorder determines how many layers deep are we going to dig and randomize. For that reason, if sectionReorder is just a scalar, it will assume that it repeats for every cmdReorder that is given. See RandomizeDocument for extra details on these parameters.


Table with information, if NULL, no information is added to the exams


Character vector, Column names from the infoTable from which we will extract the information.

It first tries to find the column names literally, if ti couldn't find them like that, it will try to use them as a regular expression to find a column that matches the column.


Character vector, Names of the commands on the tex file, \<cmdNames[i]>, that are to be matched with the columns to replace the information from the table in those commands. For extra info see also ReplaceFromTable


Number of different random versions of the exam to be outputted


Number of "questions" on the output exams. If the input is a scalar, the program will decide how to more evenly split the questions between all the sections, otherwise one can directly provide an integer vector specifying how many questions from each section are needed. (this only searches the "items" of the outermost layer)

answerSheetCorrectTag, answerSheetWrongTag

If the tags are not given, the output answersheet will be NULL. In other cases, these tags can be regular expressions


Instead of writing the options on the function. Options could be given to optionList, and it will add those options. As long as the names are correct


All the output exams are named with outputBaseName followed by 00i identifying the number of the exam (The number of zeros is the minimum that allows for all the exams to have a different number) and "_Version_" followed by the version number of the exam and ".tex". That is:


The number of exams outputted will always be the same as the number of versions if no table is given. However, if a table is added as input. It will create one exam for each row of the table, and it will try to divide as evenly as possible how to give the versions between the different rows. (Having one exam for each row, which will probably represent a student)


A list that contains


The output directory


A character vector that contains all the output names


The full answer sheet of all the exams.

Each answer sheet is created as described by ConstructAnswerSheet, and all the answer sheets are joined together with a version number in front as an added column to bind them all together. The original version has the number 0, all the output versions have sequential numbers as Version

This wrapper function assumes equal depth on all branches of the tree structure, so that the number of columns is always identical in the answer sheet

See Also

ConstructAnswerSheet, ReplaceFromTable, RandomizeDocument for extra details. . To see examples of how to use it, look at the code in jsonhwparser

TexExamRandomizer documentation built on May 2, 2019, 3:18 a.m.