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.

Rationale

Apart from the limited choices of open sourced, online curriculum building for adult ESL students (viz. elcivics.com), 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 (https://www.uscis.gov/citizenship) 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: http://www.tug.org/mactex/. For more information, see CTAN at https://www.ctan.org/pkg/latex.

The other prerequisite is to install R. To do this, go to the CRAN network https://cran.r-project.org/. You will also need to install the ProfessR package. Go to https://cran.r-project.org/doc/manuals/r-release/R-admin.html 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 https://cran.r-project.org/web/packages/ProfessR/ProfessR.pdf, 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.


pacman::p_load(ProfessR,magrittr)
QB1 <-  ProfessR::Get.testbank("~/Desktop/Civics/civics_unit_two.txt")
        head(QB1[[1]])

Output

## $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
## NULL

Results

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
\begin{document}
\maketitle

\begin{multicols}{2}
[
\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. 
]

\begin{enumerate}
PUT THE RAW OUTPUT HERE. 
\end{enumerate}
\end{multicols}
\end{document}


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.

\begin{enumerate}
\end{enumerate}

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

Survey Validation based on Synthetic Data with the Help of Claude

survey creation and validation survey creation and validation Author dr. mario martinez Published August 18, 2025 Introduction This code was generated with the help of Claude Set up synthetic data # Load necessary libraries library (survey) library (lavaan) library (psych) library (dplyr) library (ggplot2) library (missMethods) # Set seed for reproducibility set.seed ( 123 ) # Create simulated survey data n <- 500 survey_data <- data.frame ( id = 1 : n, q1 = sample ( 1 : 5 , n, replace = TRUE ), q2 = sample ( 1 : 5 , n, replace = TRUE ), q3 = sample ( 1 : 5 , n, replace = TRUE ), q4 = sample ( 1 : 5 , n, replace = TRUE ), q5 = sample ( 1 : 5 , n, replace = TRUE ), q6 = sample ( 1 : 5 , n, replace = TRUE ) ) survey_data1 <- impute_median (survey_data) # Round to whole numbers an...

The "Cram" Method of Validation for Machine learning

Our department at the University of Houston has a paper that is accepted and will be presented at the 2026 conference of the American Educational Research Association (AERA) in Los Angeles, CA. Without getting too deep into the purpose of the paper, while simultaneously aiming for the purpose of this writing, which is showcasing our use of novel methodology in action, we used machine learning ML algorithms to make our case. As a result, we needed to validate the machine learning outcomes. Traditionally this is done with an 80/20 holdout reservation of part of the data. Indeed, one of our critics asked us to use a holdout method in a particular way. However, as a data scientist, I am always championing the newest methodologies out there available in the R coding sphere (read as a linguistic sphere altogether). As I was looking out during the break for newest releases, I came across the work of Jia, Imai, and Li (2024/2025). Their methods turn the traditional 80/20 holdout and cross va...

Striking a Balance: How Much Should I Cast My own Site Variables, Versus Referring to the Literature When Doing Predictive Machine Learning as a Data Scientist?

 Recently I came back from the TAIR 2025 conference and I was struck by the number of presenters that focused on using either auto machine learning or artificial intelligence in creating models for predictive analytics in higher education. One of the striking things about the works presented is that the independent variables were somewhat similar to each other but yet different from each other enough to raise the question. How much should there be consistency between predictive machine learning models? Or, how generalizable should any given model be? These two questions strike at the limits of what local work should aim towards. One way to look at the issue is the pressing need to look at all available variables locally and use them to forage a way forward at predictions about issues like retention, enrollment, and so forth at the university level. To a certain degree this is a moot point, as some would argue that data science is about creating actionable insights.  That is, u...