
\documentclass{article}
\usepackage{amsmath} %Never write a paper without using amsmath for its many new commands
\usepackage{amssymb} %Some extra symbols
\usepackage{makeidx} %If you want to generate an index, automatically
\usepackage{graphicx} %If you want to include postscript graphics
%%%  \usepackage{mystyle} 
%Create your own file, mystyle.sty where you put all your own \newcommand statements
%%%
%%%
\usepackage{amscd}

\usepackage{Sweave}


%%\VignetteIndexEntry{Examples of ExamMaker from package:ProfessR}

%%% \usepackage{Sweave}

\begin{document}

%%%\renewcommand\floatpagefraction{.9}
%%%\renewcommand\topfraction{.9}
%%%\renewcommand\bottomfraction{.9}
%%%\renewcommand\textfraction{.1}
%%%\setcounter{totalnumber}{50}
%%%\setcounter{topnumber}{50}
%%%\setcounter{bottomnumber}{50}

\setkeys{Gin}{width=0.9\textwidth}



\numberwithin{equation}{section}

%%%   
%%%\SweaveOpts{prefix.string=rseis}
\SweaveOpts{prefix=TRUE,prefix.string=rseis,include=FALSE}


\author{Jonathan M. Lees\\
University of North Carolina, Chapel Hill\\
Department of Geological Sciences\\
CB \#3315, Mitchell Hall\\
Chapel Hill, NC  27599-3315\\
email: jonathan.lees@unc.edu\\
ph: (919) 962-0695
}
%%  \address{University of North Carolina, Chapel Hill}
%% \contact{Jonathan M. Lees}
%% \contactaddress{Department of Geological Sciences, CB #3315, Mitchell Hall, Chapel Hill, NC  27599-3315}
%% \contactemail{jonathan.lees@unc.edu}
%% \contactphone{(919) 962-0695}
\title{ExamMaker Analysis in R}
\date{September, 2007}

\maketitle


\begin{abstract}
This vignette is intended to instruct users on how to set up
and manipulate routines that design multiple choice exams 
for large classes where several versions are required to 
avoid the temptation to cheat.
The program reads question banks from ASCII text files and
creates latex files that are suitable for distribution in class.
Answer keys are also created.
The main power of ProfessR is the ability to
randomize questions as well as in the answer choices,
to set up multiple versions of a test.
Once a large data bank of questions 
has been created, any number of tests can be generated,
different every year or scrambled in a variety of ways.

\end{abstract}


\section{Test DataBank}




The test databanks in the ProfessR package are 
organized as ASCII text files.  The format is relatively rigid at this stage but
these restrictions may be relaxed int he future.
At this time the questions are all multilple choice.
But true/fals questions could easily be incorporated by 
have a two choice question.

The TEXT format of the data is stored
in the following manner:
\begin{verbatim}
QUESTION: Sandstone cliffs in Montana are categorized as:
ANSWER: a) sedimentary rocks
b) metamorphic rocks
c) igneous rocks
d) intrusives
e) extrusives
\end{verbatim}

The program parses this out by search for the key words 'QUESTION:' and 'ANSWER:'
Severl question can be stacked on top of each other,
and in the event that there is a figure associated 
with the question, it is signaled by the key word, ``Fig:''.
For example here we have 2 questions,
the second one includes a previous generated figure
located on disk and referenced in the question via
the standard latex implementation.
\begin{verbatim}
QUESTION: Convection in the mantle is indicated by
a) hot slab descending at subduction and cold ridges rising
b) cold slabs descending and hot spots rotating
c) voluminous lava flows at transform faults
ANSWER: d) hot magma rising at ridges, cold slabs descending at subduction zones
e) hot spots drifting to the northwestern Pacific
QUESTION: From the follwowing figure (Figure~\ref{fig:faults1}) which is the normal fault:
a) A
b) B
ANSWER: c) C
d) D
e) E
FIG: /home/lees/Class/TESTBANK/faults_4_test.eps fig:faults1

\end{verbatim}
The FIG tag indicates a file pointer and latex tag name to refer
to the figure in the subsequent exam.

Any number of questions/answers can be in the databank.
Once they are read in via the parsing program,
questins can be selected in R 
and a specific Exam is generated.
<<>>=
library("ProfessR")

QB1 = Get.testbank('climate_change_abbott.txt') 
QB2 = Get.testbank('tsunami_abbot_web.txt') 
@ 
Here we have two data banks installed and we want to select a
random sample of 
12 questions from the first and 9 from the second.
<<>>=

L1 = length(QB1)
L2 = length(QB2)

isel1 = sample(1:L1)
QBfinal =  list()
for(i in 1:12) { QBfinal[[i]] = QB1[[isel1[i]]] }
isel2 = sample(1:L2)
for(i in 1:9) { QBfinal[[i+12]] = QB2[[isel2[i]]] }

@ 

To insure that there is no order to the questions
the exam can be randomized with simple calls to
<<>>=
QA1 = ran.exam(QBfinal)
@ 

On the other hand we may wish to create 2 versions of the same exam with 
questions mixed up to reduce the possibility of cheating:

<<>>=
examdate="TUES OCT 30 2007"

version.exam(QBfinal, "exam2A" , exnumber="Exam 2", seqnum="1", examdate=examdate)

version.exam(QBfinal, "exam2B" , exnumber="Exam 2", seqnum="2", examdate=examdate)

@ 



The output of these two calls includes tex files 
of the two tests, and solution files for printing and distributing
to students after the test is over.
Of course these should be processed 
with calls to Latex
\begin{verbatim}
latex exam2AMAST
latex exam2AMAST
\end{verbatim}
and
\begin{verbatim}
latex exam2BMAST
latex exam2BMAST
\end{verbatim}
Note that we call latex twice to rectify all the references
to figures in the latex file.

Finally the dvi output should processed 
to make a printable version.  I 
typically use the calls,

\begin{verbatim}
dvips -Ppdf exam2AMAST.dvi  > exam2AMAST.ps
ps2pdf exam2AMAST.ps   > exam2AMAST.pdf
\end{verbatim}
and similarly for the B test and the solution files.
I then can post the solutions on a web site and
students can read them using Windows.




\subsection{Latex Notes}

The Latex header in prep.exam
is generated autometically in 
the R-code.  For some users this
style may be too primitive and
they will want to replace the 
cover sheet with other more attractive
options.  Originally I used
a style sheet provided by
the University of Texas, UOFTEXAM.sty.
If the user wants to 
use this it should be installed in the 
proper place in
the users latex repository, /usr/share/texmf/tex/latex
or some such equivalent so
the latex program can make the final copy of the 
test.

Other changes should be made in that 
file to reflect the user's set up,
college, etc.

\subsection{Cleanup}

As a side effect of the ProfessR routines we have created
several files to be used later.  For this vignette, however,
we will delete these files.


%%%   <<>>=
\begin{verbatim}
file.remove("exam2AMAST.tex")

file.remove("exam2AMAST.tex" )
file.remove("exam2Asolutions.tex" )
file.remove("exam2A.tex" )
file.remove("exam2BMAST.tex" )
file.remove("exam2Bsolutions.tex" )
file.remove("exam2B.tex" )
file.remove("ExamMaker.tex" )
file.remove("Rplots.ps")
file.remove("ExamMaker.dvi" )
file.remove("ExamMaker.log" )
file.remove("ExamMaker.aux" )
\end{verbatim}

%%   @ 



\end{document}



