Skip to content

Instantly share code, notes, and snippets.

@msperlin
Last active March 21, 2021 18:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msperlin/ef1b93a8eb9026ba5e9a to your computer and use it in GitHub Desktop.
Save msperlin/ef1b93a8eb9026ba5e9a to your computer and use it in GitHub Desktop.
An example of a latex file for usage with RndTexExams
\documentclass[10pt]{examdesign}
% loads all necessary packages (feel free to customize for your needs)
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{pifont}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{totpages}
\usepackage[margin=0.9in]{geometry}
\renewcommand{\headrulewidth}{0.0pt}
\usepackage{framed}
\SectionFont{\large\sffamily}
\Fullpages
\ContinuousNumbering
\DefineAnswerWrapper{}{}
\NumberOfVersions{1}
%\ShortKey % shows a short key answer sheet
\NoKey % Print key ?
\NoRearrange % Random arrange with latex? (leave it UNCOMMENTED, R will do all of the dirty work)
\newcommand{\myversion}{} % this line is very important as it locates and allows the printed test to show the number of the test (DONT DELETE IT)
% You probably want to change the next lines
\newcommand{\UniName}{Name of my University}
\newcommand{\DeptName}{My Department}
\newcommand{\ClassName}{My Class Name}
\newcommand{\MyName}{Author: My name}
\newcommand{\ExamName}{Exam Name: Version \myversion}
\newcommand{\TermName}{Current Term}
\rfoot{Random test \# \myversion}
\begin{document}
\begin{examtop}
% detais of the exam (you should probably edit this!)
\begin{center}
\textbf{\Large \UniName} \\
\textbf{\Large \DeptName} \vspace{0.5cm} \\
\textbf{\Large \ClassName} \\
\textbf{\Large \MyName} \\
\textbf{\Large \ExamName } \\
\textbf{\Large \TermName}
\end{center}
\vspace{1cm}
Name: \rule{4in}{.4pt} \quad \noindent Card:\enspace\hrulefill
%\rule[1ex]{\textwidth}{2pt}
\vspace{1cm}
\small
\begin{framed}
Instructions for this test:
\begin{itemize}
\item Make sure you finish before the end of the exam time
\item There is only one correct answer in all multiple choice questions
\item Don't cheat!
\end{itemize}
\vspace{0.5cm}
{\large \emph{Good Luck!}}
\end{framed}
\begin{framed}
Instructions on how to use RndTexExams (DELETE THIS IN THE FINAL VERSION)
\begin{itemize}
\item The switch statements for the text of the questions, including main text and answers are defined as @{Text for version 1}|{Text for version 2}@. For each question, fell free to define as many versions as needed.
\item You can define the right answer in each version of the test by assigning the character [!] or [ver] in the right answer for version ver. See the rest of the file for examples.
\end{itemize}
\end{framed}
\end{examtop}
\vspace{1cm}
\begin{multiplechoice}[resetcounter=no, examcolumns=1]
\begin{question}
Which one is the correct answer in the next five alternatives?
\choice{Choice 1}
\choice{Choice 2}
\choice{Choice 3}
\choice{Choice 4}
\choice[!]{Choice 5 - CORRECT}
\end{question}
\begin{question}
Consider the following statements:
\begin{enumerate}[I]
\item The color of the sky is generally @{blue}|{red}@
\item R has a @{high}|{low}@ number of packages for empirical research in Finance
\item Microsoft word is @{better}|{worse}@ than latex for creating structured documents
\end{enumerate}
Are correct:
\choice{[1] I and II}
\choice{II and III}
\choice{I, II and III}
\choice{[2] Only III}
\choice{Only I}
\end{question}
\begin{question}
Which of the next answers do you think is the correct one? (there are three versions of this question. This is version @{1}|{2}|{3}@)
\choice{Choice 1 - Incorrect in all versions}
\choice{[1] Choice 2 - @{Correct in version 1}|{Incorrect in version 2}|{Incorrect in version 3}@}
\choice{[3] Choice 3 - @{Incorrect in version 1}|{Incorrect in version 2}|{Correct in version 3}@}
\choice{Choice 4 - Incorrect in all versions}
\choice{[2] Choice 5 - @{Incorrect in version 1}|{Correct in version 2}|{Incorrect in version 3}@}
\end{question}
\begin{question}
Consider the following statements:
\begin{enumerate}[I]
\item Latex is @{good}|{bad}@ for structured documents
\item Working with R and latex is a @{good}|{bad}@ choice for writing up and marking tests
\item We @{love}|{hate}@ R
\end{enumerate}
Which statements are true?
\choice{I e II}
\choice{[1] I, II e III}
\choice{Only III}
\choice{I e III}
\choice{[2] None of the other options}
\end{question}
\end{multiplechoice}
\end{document}
@Em-Fl
Copy link

Em-Fl commented Jun 4, 2019

Hi msperlin. I've been trying your code, and was wondering if it is possible to use it for questions with more than one correct answer (for examen true or false questions). Thank you

@msperlin
Copy link
Author

msperlin commented Jun 5, 2019

Hi Em-Fi,

This is an old project. I'm not even using it anymore.
Have a look at package exams. If offers everything you need, including TRUE/FALSE questions.

@davidrajm
Copy link

Hi msperlin. I've been trying your code, and was wondering if it is possible to use it for questions with more than one correct answer (for examen true or false questions). Thank you

May be a late answer. If you are interested in looking for the answer, the answer is "YES". But, there is a small bug in the definition while printing the answer key. If you use the following in preamble to redefine the same, you would get what is desired.

\makeatletter
\renewcommand{\exam@ShortKeyChoice}[2][]{%
	\if#1!%
	\ifOneCorrectAnswerAlreadyGiven
	, (\alph{choice})
	\else
	\exam@MultipleChoiceShortKeyPrefix
	(\alph{choice})%
	\OneCorrectAnswerAlreadyGiventrue
	\fi
	\fi
	\stepcounter{choice}%
	\ignorespaces}
\makeatother

Refs: https://tex.stackexchange.com/a/475982

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment