Skip to contents

Constructs an answer sheet given a document as generated by StructureDocument by finding in the items the correct and wrong tags and describing where it found them.

Note that you must provide the document part only, StructureDocument gives back a $preamble and $document.

If wrongTag is left NULL, the answer sheet only shows information of the correct answers.

This answer sheet provides information for what answers are correct or incorrect, as well as their position within the original document, before any shuffling was done. (It uses the names of the document to decide whether the document was shuffled or not, since subsetting a list removes all attributes except for the names, this is the "safest" way to do it)

The intent of this function is to make it easy to find the answers for a randomized version of an exam.

Usage

ConstructAnswerSheet(Document, correctTag, wrongTag = NULL)

Arguments

Document

Document, as defined in StructureDocument. Remember however that the function StructureDocument returns the document and the preamble together in a list.

correctTag

Tag to identify the correct items.

wrongTag

Tag that identifies the wrong items.

Value

Data Frame. With the following columns

index

Just an index running from 1 to \(n\), where \(n\) is the numbe of rows

For each layer of depth in the document:

Four columns,

<name of section>_original

Contains an integer identifying the numbering of this section in the original layer, as identified by the naming convention

<name of section command>_original

Contains an integer identifying the numbering of this item in the original section, as identified by the naming convention

<name of section>

Contains an integer identifying the numbering of this section in the current layer, as identified by the ordering of the document inputted on this function

<name of section command>

Contains an integer identifying the numbering of this item in the current section, as identified by the ordering of the document inputted on this function

For the last layer of depth

5 columns if the wrongTag is not NULL, 4 columns otherwise,

<name of section>_original

Contains an integer identifying the numbering of this section in the original layer, as identified by the naming convention

<name of section command>_original

Contains an integer identifying the numbering of this item in the original section, as identified by the naming convention

<name of section>

Contains an integer identifying the numbering of this section in the current layer, as identified by the ordering of the document inputted on this function

<correctTag>

Contains an integer identifying the numbering of this item in the current section, , as identified by the ordering of the document inputted on this function

If the correctTag wasn't found in this item, it will show NA instead. (This will only happen if wrongTag is not NULL, since otherwise this elements are omitted)

<wrongTag>

Contains an integer identifying the numbering of this item in the current section, as identified by the ordering of the document inputted on this function

If the wrongTag wasn't found in this item, it will show NA instead. (This will only happen if wrongTag is not NULL, since otherwise this elements are omitted)

Details

The tags are just command of the type "\Tag" that must be found somewhere that is not commented out inside the last item at the end of the tree structure. Usually you will want to use the tags that already identify the document items for this.

(For example, in the exam class, the tags \choice and \CorrectChoice could be used naturally, without having to introduce extra commands in the document)

See also

FindExamAnswers for the exact underlying messy algorithm that controls how the table is created.

Other Extracting information: CountNumberOfSections(), FindExamAnswers(), GenerateShortAnswerSheet()

Examples


ConstructAnswerSheet(
    TexExamRandomizer::testdoc$document,
    "CorrectChoice",
    "choice"
)
#>     index questions_original question_original questions question
#> 1       1                  1                 1         1        1
#> 2       2                  1                 1         1        1
#> 3       3                  1                 1         1        1
#> 4       4                  1                 1         1        1
#> 5       5                  1                 2         1        2
#> 6       6                  1                 2         1        2
#> 7       7                  1                 2         1        2
#> 8       8                  1                 2         1        2
#> 9       9                  1                 3         1        3
#> 10     10                  1                 3         1        3
#> 11     11                  1                 3         1        3
#> 12     12                  1                 3         1        3
#> 13     13                  1                 4         1        4
#> 14     14                  1                 4         1        4
#> 15     15                  1                 4         1        4
#> 16     16                  1                 4         1        4
#> 17     17                  1                 5         1        5
#> 18     18                  1                 5         1        5
#> 19     19                  1                 5         1        5
#> 20     20                  1                 5         1        5
#> 21     21                  1                 6         1        6
#> 22     22                  1                 6         1        6
#> 23     23                  1                 6         1        6
#> 24     24                  1                 6         1        6
#> 25     25                  1                 7         1        7
#> 26     26                  1                 7         1        7
#> 27     27                  1                 7         1        7
#> 28     28                  1                 7         1        7
#> 29     29                  1                 8         1        8
#> 30     30                  1                 8         1        8
#> 31     31                  1                 8         1        8
#> 32     32                  1                 8         1        8
#> 33     33                  2                 1         2        9
#> 34     34                  2                 1         2        9
#> 35     35                  2                 1         2        9
#> 36     36                  2                 1         2        9
#> 37     37                  2                 2         2       10
#> 38     38                  2                 2         2       10
#> 39     39                  2                 2         2       10
#> 40     40                  2                 2         2       10
#> 41     41                  2                 3         2       11
#> 42     42                  2                 3         2       11
#> 43     43                  2                 3         2       11
#> 44     44                  2                 3         2       11
#> 45     45                  2                 4         2       12
#> 46     46                  2                 4         2       12
#> 47     47                  2                 4         2       12
#> 48     48                  2                 4         2       12
#> 49     49                  2                 5         2       13
#> 50     50                  2                 5         2       13
#> 51     51                  2                 5         2       13
#> 52     52                  2                 5         2       13
#> 53     53                  2                 6         2       14
#> 54     54                  2                 6         2       14
#> 55     55                  2                 6         2       14
#> 56     56                  2                 6         2       14
#> 57     57                  2                 7         2       15
#> 58     58                  2                 7         2       15
#> 59     59                  2                 7         2       15
#> 60     60                  2                 7         2       15
#> 61     61                  2                 8         2       16
#> 62     62                  2                 8         2       16
#> 63     63                  2                 8         2       16
#> 64     64                  2                 8         2       16
#> 65     65                  2                 9         2       17
#> 66     66                  2                 9         2       17
#> 67     67                  2                 9         2       17
#> 68     68                  2                 9         2       17
#> 69     69                  2                10         2       18
#> 70     70                  2                10         2       18
#> 71     71                  2                10         2       18
#> 72     72                  2                10         2       18
#> 73     73                  2                11         2       19
#> 74     74                  2                11         2       19
#> 75     75                  2                11         2       19
#> 76     76                  2                11         2       19
#> 77     77                  2                12         2       20
#> 78     78                  2                12         2       20
#> 79     79                  2                12         2       20
#> 80     80                  2                12         2       20
#> 81     81                  2                13         2       21
#> 82     82                  2                13         2       21
#> 83     83                  2                13         2       21
#> 84     84                  2                13         2       21
#> 85     85                  2                14         2       22
#> 86     86                  2                14         2       22
#> 87     87                  2                14         2       22
#> 88     88                  2                14         2       22
#> 89     89                  2                15         2       23
#> 90     90                  2                15         2       23
#> 91     91                  2                15         2       23
#> 92     92                  2                15         2       23
#> 93     93                  2                16         2       24
#> 94     94                  2                16         2       24
#> 95     95                  2                16         2       24
#> 96     96                  2                16         2       24
#> 97     97                  2                17         2       25
#> 98     98                  2                17         2       25
#> 99     99                  2                17         2       25
#> 100   100                  2                17         2       25
#> 101   101                  2                18         2       26
#> 102   102                  2                18         2       26
#> 103   103                  2                18         2       26
#> 104   104                  2                18         2       26
#> 105   105                  3                 1         3       27
#> 106   106                  3                 1         3       27
#> 107   107                  3                 1         3       27
#> 108   108                  3                 1         3       27
#> 109   109                  3                 2         3       28
#> 110   110                  3                 2         3       28
#> 111   111                  3                 2         3       28
#> 112   112                  3                 2         3       28
#> 113   113                  3                 3         3       29
#> 114   114                  3                 3         3       29
#> 115   115                  3                 3         3       29
#> 116   116                  3                 3         3       29
#> 117   117                  3                 4         3       30
#> 118   118                  3                 4         3       30
#> 119   119                  3                 4         3       30
#> 120   120                  3                 4         3       30
#> 121   121                  3                 5         3       31
#> 122   122                  3                 5         3       31
#> 123   123                  3                 5         3       31
#> 124   124                  3                 5         3       31
#> 125   125                  3                 6         3       32
#> 126   126                  3                 6         3       32
#> 127   127                  3                 6         3       32
#> 128   128                  3                 6         3       32
#> 129   129                  3                 7         3       33
#> 130   130                  3                 7         3       33
#> 131   131                  3                 7         3       33
#> 132   132                  3                 7         3       33
#> 133   133                  3                 8         3       34
#> 134   134                  3                 8         3       34
#> 135   135                  3                 8         3       34
#> 136   136                  3                 8         3       34
#> 137   137                  3                 9         3       35
#> 138   138                  3                 9         3       35
#> 139   139                  3                 9         3       35
#> 140   140                  3                 9         3       35
#> 141   141                  4                 1         4       36
#> 142   142                  4                 1         4       36
#> 143   143                  4                 1         4       36
#> 144   144                  4                 1         4       36
#> 145   145                  4                 2         4       37
#> 146   146                  4                 2         4       37
#> 147   147                  4                 2         4       37
#> 148   148                  4                 2         4       37
#> 149   149                  4                 3         4       38
#> 150   150                  4                 3         4       38
#> 151   151                  4                 3         4       38
#> 152   152                  4                 3         4       38
#> 153   153                  4                 4         4       39
#> 154   154                  4                 4         4       39
#> 155   155                  4                 4         4       39
#> 156   156                  4                 4         4       39
#> 157   157                  4                 5         4       40
#> 158   158                  4                 5         4       40
#> 159   159                  4                 5         4       40
#> 160   160                  4                 5         4       40
#> 161   161                  4                 6         4       41
#> 162   162                  4                 6         4       41
#> 163   163                  4                 6         4       41
#> 164   164                  4                 6         4       41
#> 165   165                  4                 7         4       42
#> 166   166                  4                 7         4       42
#> 167   167                  4                 7         4       42
#> 168   168                  4                 7         4       42
#> 169   169                  5                 1         5       43
#> 170   170                  5                 1         5       43
#> 171   171                  5                 1         5       43
#> 172   172                  5                 1         5       43
#> 173   173                  6                 1         6       44
#> 174   174                  6                 1         6       44
#> 175   175                  6                 1         6       44
#> 176   176                  6                 1         6       44
#> 177   177                  6                 2         6       45
#> 178   178                  6                 2         6       45
#> 179   179                  6                 2         6       45
#> 180   180                  6                 2         6       45
#> 181   181                  6                 3         6       46
#> 182   182                  6                 3         6       46
#> 183   183                  6                 3         6       46
#> 184   184                  6                 3         6       46
#> 185   185                  6                 4         6       47
#> 186   186                  6                 4         6       47
#> 187   187                  6                 4         6       47
#> 188   188                  6                 4         6       47
#>     choices_original (choice|CorrectChoice)_original choices choice
#> 1                  1                               1       1      1
#> 2                  1                               2       1      2
#> 3                  1                               3       1      3
#> 4                  1                               4       1     NA
#> 5                  1                               1       1      1
#> 6                  1                               2       1      2
#> 7                  1                               3       1      3
#> 8                  1                               4       1     NA
#> 9                  1                               1       1      1
#> 10                 1                               2       1      2
#> 11                 1                               3       1      3
#> 12                 1                               4       1     NA
#> 13                 1                               1       1      1
#> 14                 1                               2       1      2
#> 15                 1                               3       1      3
#> 16                 1                               4       1     NA
#> 17                 1                               1       1      1
#> 18                 1                               2       1      2
#> 19                 1                               3       1      3
#> 20                 1                               4       1     NA
#> 21                 1                               1       1      1
#> 22                 1                               2       1      2
#> 23                 1                               3       1      3
#> 24                 1                               4       1     NA
#> 25                 1                               1       1      1
#> 26                 1                               2       1      2
#> 27                 1                               3       1      3
#> 28                 1                               4       1     NA
#> 29                 1                               1       1      1
#> 30                 1                               2       1      2
#> 31                 1                               3       1      3
#> 32                 1                               4       1     NA
#> 33                 1                               1       1      1
#> 34                 1                               2       1      2
#> 35                 1                               3       1      3
#> 36                 1                               4       1     NA
#> 37                 1                               1       1      1
#> 38                 1                               2       1      2
#> 39                 1                               3       1      3
#> 40                 1                               4       1     NA
#> 41                 1                               1       1      1
#> 42                 1                               2       1     NA
#> 43                 1                               3       1      3
#> 44                 1                               4       1      4
#> 45                 1                               1       1     NA
#> 46                 1                               2       1      2
#> 47                 1                               3       1      3
#> 48                 1                               4       1      4
#> 49                 1                               1       1      1
#> 50                 1                               2       1     NA
#> 51                 1                               3       1      3
#> 52                 1                               4       1      4
#> 53                 1                               1       1      1
#> 54                 1                               2       1      2
#> 55                 1                               3       1      3
#> 56                 1                               4       1     NA
#> 57                 1                               1       1      1
#> 58                 1                               2       1      2
#> 59                 1                               3       1      3
#> 60                 1                               4       1     NA
#> 61                 1                               1       1      1
#> 62                 1                               2       1      2
#> 63                 1                               3       1     NA
#> 64                 1                               4       1      4
#> 65                 1                               1       1      1
#> 66                 1                               2       1      2
#> 67                 1                               3       1      3
#> 68                 1                               4       1     NA
#> 69                 1                               1       1      1
#> 70                 1                               2       1      2
#> 71                 1                               3       1      3
#> 72                 1                               4       1     NA
#> 73                 1                               1       1      1
#> 74                 1                               2       1      2
#> 75                 1                               3       1      3
#> 76                 1                               4       1     NA
#> 77                 1                               1       1      1
#> 78                 1                               2       1      2
#> 79                 1                               3       1      3
#> 80                 1                               4       1     NA
#> 81                 1                               1       1      1
#> 82                 1                               2       1     NA
#> 83                 1                               3       1      3
#> 84                 1                               4       1      4
#> 85                 1                               1       1      1
#> 86                 1                               2       1      2
#> 87                 1                               3       1      3
#> 88                 1                               4       1     NA
#> 89                 1                               1       1      1
#> 90                 1                               2       1      2
#> 91                 1                               3       1      3
#> 92                 1                               4       1     NA
#> 93                 1                               1       1     NA
#> 94                 1                               2       1      2
#> 95                 1                               3       1      3
#> 96                 1                               4       1      4
#> 97                 1                               1       1      1
#> 98                 1                               2       1      2
#> 99                 1                               3       1      3
#> 100                1                               4       1     NA
#> 101                1                               1       1      1
#> 102                1                               2       1      2
#> 103                1                               3       1      3
#> 104                1                               4       1     NA
#> 105                1                               1       1      1
#> 106                1                               2       1      2
#> 107                1                               3       1      3
#> 108                1                               4       1     NA
#> 109                1                               1       1      1
#> 110                1                               2       1      2
#> 111                1                               3       1      3
#> 112                1                               4       1     NA
#> 113                1                               1       1      1
#> 114                1                               2       1      2
#> 115                1                               3       1      3
#> 116                1                               4       1     NA
#> 117                1                               1       1      1
#> 118                1                               2       1      2
#> 119                1                               3       1      3
#> 120                1                               4       1     NA
#> 121                1                               1       1      1
#> 122                1                               2       1      2
#> 123                1                               3       1      3
#> 124                1                               4       1     NA
#> 125                1                               1       1      1
#> 126                1                               2       1      2
#> 127                1                               3       1      3
#> 128                1                               4       1     NA
#> 129                1                               1       1      1
#> 130                1                               2       1     NA
#> 131                1                               3       1      3
#> 132                1                               4       1      4
#> 133                1                               1       1      1
#> 134                1                               2       1      2
#> 135                1                               3       1      3
#> 136                1                               4       1     NA
#> 137                1                               1       1      1
#> 138                1                               2       1      2
#> 139                1                               3       1      3
#> 140                1                               4       1     NA
#> 141                1                               1       1      1
#> 142                1                               2       1      2
#> 143                1                               3       1      3
#> 144                1                               4       1     NA
#> 145                1                               1       1      1
#> 146                1                               2       1      2
#> 147                1                               3       1      3
#> 148                1                               4       1     NA
#> 149                1                               1       1      1
#> 150                1                               2       1      2
#> 151                1                               3       1      3
#> 152                1                               4       1     NA
#> 153                1                               1       1      1
#> 154                1                               2       1      2
#> 155                1                               3       1     NA
#> 156                1                               4       1      4
#> 157                1                               1       1      1
#> 158                1                               2       1      2
#> 159                1                               3       1      3
#> 160                1                               4       1     NA
#> 161                1                               1       1      1
#> 162                1                               2       1      2
#> 163                1                               3       1      3
#> 164                1                               4       1     NA
#> 165                1                               1       1      1
#> 166                1                               2       1      2
#> 167                1                               3       1      3
#> 168                1                               4       1     NA
#> 169                1                               1       1      1
#> 170                1                               2       1      2
#> 171                1                               3       1      3
#> 172                1                               4       1     NA
#> 173                1                               1       1      1
#> 174                1                               2       1      2
#> 175                1                               3       1      3
#> 176                1                               4       1     NA
#> 177                1                               1       1      1
#> 178                1                               2       1      2
#> 179                1                               3       1      3
#> 180                1                               4       1     NA
#> 181                1                               1       1      1
#> 182                1                               2       1      2
#> 183                1                               3       1      3
#> 184                1                               4       1     NA
#> 185                1                               1       1      1
#> 186                1                               2       1      2
#> 187                1                               3       1      3
#> 188                1                               4       1     NA
#>     CorrectChoice
#> 1              NA
#> 2              NA
#> 3              NA
#> 4               4
#> 5              NA
#> 6              NA
#> 7              NA
#> 8               4
#> 9              NA
#> 10             NA
#> 11             NA
#> 12              4
#> 13             NA
#> 14             NA
#> 15             NA
#> 16              4
#> 17             NA
#> 18             NA
#> 19             NA
#> 20              4
#> 21             NA
#> 22             NA
#> 23             NA
#> 24              4
#> 25             NA
#> 26             NA
#> 27             NA
#> 28              4
#> 29             NA
#> 30             NA
#> 31             NA
#> 32              4
#> 33             NA
#> 34             NA
#> 35             NA
#> 36              4
#> 37             NA
#> 38             NA
#> 39             NA
#> 40              4
#> 41             NA
#> 42              2
#> 43             NA
#> 44             NA
#> 45              1
#> 46             NA
#> 47             NA
#> 48             NA
#> 49             NA
#> 50              2
#> 51             NA
#> 52             NA
#> 53             NA
#> 54             NA
#> 55             NA
#> 56              4
#> 57             NA
#> 58             NA
#> 59             NA
#> 60              4
#> 61             NA
#> 62             NA
#> 63              3
#> 64             NA
#> 65             NA
#> 66             NA
#> 67             NA
#> 68              4
#> 69             NA
#> 70             NA
#> 71             NA
#> 72              4
#> 73             NA
#> 74             NA
#> 75             NA
#> 76              4
#> 77             NA
#> 78             NA
#> 79             NA
#> 80              4
#> 81             NA
#> 82              2
#> 83             NA
#> 84             NA
#> 85             NA
#> 86             NA
#> 87             NA
#> 88              4
#> 89             NA
#> 90             NA
#> 91             NA
#> 92              4
#> 93              1
#> 94             NA
#> 95             NA
#> 96             NA
#> 97             NA
#> 98             NA
#> 99             NA
#> 100             4
#> 101            NA
#> 102            NA
#> 103            NA
#> 104             4
#> 105            NA
#> 106            NA
#> 107            NA
#> 108             4
#> 109            NA
#> 110            NA
#> 111            NA
#> 112             4
#> 113            NA
#> 114            NA
#> 115            NA
#> 116             4
#> 117            NA
#> 118            NA
#> 119            NA
#> 120             4
#> 121            NA
#> 122            NA
#> 123            NA
#> 124             4
#> 125            NA
#> 126            NA
#> 127            NA
#> 128             4
#> 129            NA
#> 130             2
#> 131            NA
#> 132            NA
#> 133            NA
#> 134            NA
#> 135            NA
#> 136             4
#> 137            NA
#> 138            NA
#> 139            NA
#> 140             4
#> 141            NA
#> 142            NA
#> 143            NA
#> 144             4
#> 145            NA
#> 146            NA
#> 147            NA
#> 148             4
#> 149            NA
#> 150            NA
#> 151            NA
#> 152             4
#> 153            NA
#> 154            NA
#> 155             3
#> 156            NA
#> 157            NA
#> 158            NA
#> 159            NA
#> 160             4
#> 161            NA
#> 162            NA
#> 163            NA
#> 164             4
#> 165            NA
#> 166            NA
#> 167            NA
#> 168             4
#> 169            NA
#> 170            NA
#> 171            NA
#> 172             4
#> 173            NA
#> 174            NA
#> 175            NA
#> 176             4
#> 177            NA
#> 178            NA
#> 179            NA
#> 180             4
#> 181            NA
#> 182            NA
#> 183            NA
#> 184             4
#> 185            NA
#> 186            NA
#> 187            NA
#> 188             4