Skip to main content

Creating Examination Question Banks for ESL Civics Students based on U.S. Form M-638

R and Latex Code in the Service of Exam Questions  

The following webpage is under development and will grow with more information. The author abides by the GPL (>= 2) license provided by the "ProfessR" package by showing basic code, but not altering it. The code that is provided here is governed by the MIT license, copyright 2018, while respecting the GPL (>=2) license.


Apart from the limited choices of open sourced, online curriculum building for adult ESL students (viz., there is a current need to create open-sourced assessments for various levels of student understandings of the English language. While the U.S. Citizenship and Immigration Services ( has valuable lessons for beginning and intermediate ESL civics learners, there exists a need to provide more robust assessments, especially for individuals repeating ESL-based civics courses. This is because the risks and efforts involved in applying for U.S. citizenship serve as a motivating factor for some permanent residents and others to come into an ESL civics class with many hours of preparation prior to any seat work. This is true especially when dealing with the 100 questions listed in U.S. form M-638 (revised 1-17) (If you are not familiar with M-638, you may type the term into a web browser for more information). Therefore, solving the problem of creating large question banks for multiple versions of tests is of paramount importance. The problem can be solved easily with highly reliable open sourced software.

Installing Tex and R

The final test outputs require an installation of BasicTex, a smaller distribution of MacTeX. You can find more about installing BasicTex here: For more information, see CTAN at

The other prerequisite is to install R. To do this, go to the CRAN network You will also need to install the ProfessR package. Go to and read subsection 6.3. It is highly advised that you install packages from within the R terminal.

Getting Started

To the end of providing quick, summative assessments, this page shows the reader how to incorporate the “ProfessR” package in R to generate a PDF exam file (and multiple variations thereof). A copy of the "ProfessR" package description may be found on, but useRs will find that it is not a seamless approach from start to PDF generation. The underlying aim of the "ProfessR" package is to read in UTF-8 .txt files, generate a question bank object, and create an exam from one or more question banks, with the option of randomly assigning questions to tests that are generated in a LaTeX file. As the "ProfessR" documentation is scant, this page will fill in missing details to guide the reader.

The example below shows the formatting for the .txt file that will be loaded up into the R environment to become an object readable by the ProfessR package.
Sample test item in a .txt file prepared for ProfessR in R

QUESTION: What is one capital of your state?

a) Houston
ANSWER: b) Austin
c) Dallas
d) San Antonio
You can find files for Unit 1 and 2 to generate the civics exam here.

QB1 <-  ProfessR::Get.testbank("~/Desktop/Civics/civics_unit_two.txt")


## $Q
## [1] "What did the Declaration of Independence do?"
## $A
## [1] "a)\tdeclared that the colonies owed thanks to Britain "
## [2] "b) announced the colonies' independence"              
## [3] "c)\tstated that the colonies were well represented"   
## [4] "d)\tdiscussed that the colonies needed more troops."  
## $a
## [1] "ANSWER: b) announced the colonies' independence"
## $numANS
## [1] 2
## $FIG


The code returns a print out of the first part of the list returned by the algorithm. 1. The first indexed list item includes the $Q (question) and the $A (answer) components of the sublist 2. The correct answer is included, 3. The number of correct answers is also included.
For more information on the structure of the object, call the structure command on QB1.

ProfessR::make.exam(QB1, ofile = "~/Desktop/Civics/examS.tex") 

This code creates the file “exam1.tex” in the designated folder. In this stage, the document will look like this:

Fig 1. Exam 5
Next, the following latex code should be sandwiched between the raw text on both sides

\documentclass[12pt, oneside]{article} \usepackage{geometry}        \geometry{letterpaper}                                        \usepackage{multicol}                                        \usepackage{amssymb}

\title{Civics: Unit 1 Exam}
\author{Name:         }
%\date{}  % Activate to display a given date or no date

\subsubsection*{Directions} Fill in the answer sheet with the 
letter that best answers the question. In some cases there will 
be more than one correct answer. 


Notes on the Latex Code    

The raw code provided by the ProfessR package does not include the general parameters for the enumerate function. The enumerate function is essential to set the code in place.


The code must then be inserted into a general document template. For ease of use, the raw code has been inserted into the LaTeX article class. The raw data should be inserted over the “PUT THE RAW OUTPUT HERE” line. To do this, simply copy and paste from the raw file.
To run the code in LaTeX, simply typeset in LaTeX.

Popular posts from this blog

Digital Humanities Methods in Educational Research

Digital Humanities based education Research This is a backpost from 2017. During that year, I presented my latest work at the 2017  SERA conference in Division II (Instruction, Cognition, and Learning). The title of my paper was "A Return to the Pahl (1978) School Leavers Study: A Distanced Reading Analysis." There are several motivations behind this study, including Cheon et al. (2013) from my alma mater .   This paper accomplished two objectives. First, I engaged previous claims made about the United States' equivalent of high school graduates on the Isle of Sheppey, UK, in the late 1970s. Second, I used emerging digital methods to arrive at conclusions about relationships between unemployment, participants' feelings about their  (then) current selves, their possible selves, and their  educational accomplishm ents. I n the image to the left I show a Ward Hierarchical Cluster reflecting the stylometrics of 153 essay

Getting past the two column PDF to extract text into RQDA: Literature reviews await

One of the great promises of working with RQDA is conceiving of it as computer assisted literature review software. This requires balancing the right amount of coding with text that can be used as warrants and backing in arguments. In theory it is a great idea--using computer assisted qualitative data analysis software (CAQDAS) for literature reviews, but how do you get the article PDFs into R and RQDA in a human readable format? By this I mean that many empirical articles are written in two column formats, and text extraction with standard tools produces text on the diagonal. Extracting PDF texts under this circumstance can be daunting when using some R packages such as 'pdftools', either with or without the assistance of  the 'tesseract' package. If you are working on a windows based computer, you can install three packages and Java to do the trick. First gather the literature articles that you would like to mark up in RQDA. Put them into a folder, and away you go.