Function to randomize a Document, as created by
It Randomizes each layer according to the prescriptions involved in the internal function
GetLayerSampleIndexes. Which, in summary, randomizes each section inside, and then randomizes the orders of the sections.
Important note: One must provide to this function the document part of the structure. Since
StructureDocument provides as the outer most layer a split between the preamble and the document, one must just supply the document part to this function, (or a subsection of it).
RandomizeDocument(Document, isSectionReordered.vector, isLayerRandomized.vector)
Document to randomize, as generated by
Logical vector, specifying if the order of sections should be also randomized at a certain depth level.
Note that if
Logical vector, specifying if you should randomize the order of the items, (denoted by
This vector should have the same length as the depth at most, otherwise it will raise an error if you try to "dig deeper than it can". And isSectionReordered.vector should have matching elements for each element of isLayerRandomized.vector
(Maybe we could change this to a warning instead? To allow for structures with different depths within different branches of the tree)
It keeps randomizing recursively inner layers of the structure until it runs out of elements on the logical vectors
A "section" denotes the content within a begin-end environment in the document.
Each section is then assumed to be divided in a beginning and end parts, that should be fixed in place, and the parts denoted by the command
\cmdName as explained on
We will denote those parts as "items." Analogously to itemize environments in 'LaTeX'.
The purpose of this function is therefore to randomize the items from the structure, fixing the begin and end parts within a section. And then to reorder each section while keeping the pre- and post- parts fixed, and to do so recursively until we exhaust the
isSectionReordered.vector specifies whether to order sections for a certain depth, while
isLayerRandomized.vector specifies whether to order the items within a section of that same depth.
In some cases you may want to reorder the sections, for example, using the examdesign class. Over there, questions use the begin-end question format.
In others cases you may want to preserve the order of sections while still modifying the order of the items, like when you are using the exam class, or when creating your own list of questions with an
For efficiency, if you don't want to randomize to the full depth of your tree, just make those logical vectors of your desired length, rather than making them of length n and then setting every layer after the last one you want to randomize to false. That will prevent the program from walking down the whole tree checking everything.
A document structure, as provided by
However, the names of the structure will no longer be sequential, the naming convention in the new structure will refer to the original structure that was inputted into this function. Which is very useful when you want to keep track of where things have moved.
StructureDocument, TODO: Add reference to extracting info functions
1 2 3 4 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.