tinkelman@ccavax.camb.com (06/11/90)
Has anyone done a LaTeX style file for tests/questionnaires? I'm doing some questionnaires and need to support the traditional types of questions, including yes-no, multiple-choice and check-all-that-apply. I'll post a summary of any responses I receive. Thanks. -- Bob Tinkelman, Cambridge Computer Associates, Inc., 212-425-5830 bob@camb.com or ...!{uupsi,uunet}!camb.com!bob
grunwald@foobar.colorado.edu (Dirk Grunwald) (06/12/90)
Here's something I whipped together last semester. Example included. Please let me know if you improve on it, because it's pretty bare-bones right now. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: class-example.tex class.sty # Wrapped by grunwald@foobar on Mon Jun 11 11:17:25 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'class-example.tex' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'class-example.tex'\" else echo shar: Extracting \"'class-example.tex'\" \(924 characters\) sed "s/^X//" >'class-example.tex' <<'END_OF_FILE' X\documentstyle[class]{article} X\def\ClassName{Csci} X\def\ClassNumber{2555} X\def\ClassExam{Final~Exam} X\handedout{whenver} %% included in headers/footers X\Solutions %% optionally include solutions X %% can also say \answerstrue X\begin{document} X X\begin{center} XExample of Class Style: X X\listofproblems %% a table of problems & point values X\end{center} X X\begin{problems} X\problem \Points{20} X This is the question X\begin{answer} XThis is the answer X\end{answer} X X\problem X\begin{enumerate} X \item\Points{10}[labelname] X X This ia a sub-probem with an optional label name for reference X X \begin{answer}[3in] X This is an answer that will leave 3in of space when answers X aren't being printed. X \end{answer} X X \item\Points{5} X \ifanswers include some non-boxed in answer X \else \vskip 2in \fi X X X \item\Points{3} X This problem refers to the label in problem \ref{labelname}. X\end{enumerate} X\end{problems} X\end{document} END_OF_FILE if test 924 -ne `wc -c <'class-example.tex'`; then echo shar: \"'class-example.tex'\" unpacked with wrong size! fi # end of 'class-example.tex' fi if test -f 'class.sty' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'class.sty'\" else echo shar: Extracting \"'class.sty'\" \(7398 characters\) sed "s/^X//" >'class.sty' <<'END_OF_FILE' X%% X%% class.sty: Homework & Exam Style: X%% X%% X%% This style is used for homeworks and exams. You should X%% define \ClassName to be the class name and X%% \ClassNumber to be the class number. If this is an X%% exam, you should define \ClassExam to be the kind of X%% exam (final, midterm, whatever). If you're making an X%% exam, you should also say \pagestyle{examheaders} X%% and \thispagestyle{firstexamheader} in your document preamble. X%% X%% \listofproblems will print a table listing the problem X%% numbers, the page they appear on and the number of X%% points they're worth. You're also left with space for X%% to enter the final problem score. Points information X%% is recorded in the file \currentjob.lop, much like X%% table of contents and list of figures data. X%% X%% The ``problems'' environment is currently an alias for X%% ``enumerate''; however, you should you \problem rather X%% than \item for the top level problems. This will add X%% formatting info to the list-of-problems. X%% X%% Before each problem, \Points{<value>} will print X%% ``[Points <value>]'' and record the points in the .lop X%% file. An optional argument, \Points{<value>}[<label>] X%% labels the current problem so you can refer to it X%% later using \ref. X%% X%% Answers are boxed, and only printed if \answerstrue X%% has been declared, or if you've say \Solutions. You X%% can use \ifanswers if you want to do conditional X%% answers outside of an answer box. X%% X%% Otherwise, \begin{answer} ... \end{answer} passes the X%% answer through to TeX only if \ifanswers is true. You X%% can specify an optional dimension; that much space is X%% left when printing without answers. You can also X%% specify 'p' to say you want a page eject when answers X%% aren't being printed. I.e. X%% \begin{answer}[3in] foo \end{answer} will pass 'foo' X%% to TeX if printing with answers, otherwise, it'll leave X%% 3 inches of room for the student to write down an answer. X%% X%% You can also say \TrueFalse{true}{your text} or X%% \TrueFalse{false}{your text} to make a true false X%% question. The 'true' or 'false' (must be one of the X%% two) is the correct answer X%% X%% example: X%% X%% \documentstyle[class]{article} X%% \def\ClassName{Csci} X%% \def\ClassNumber{2555} X%% \def\ClassExam{Final~Exam} X%% \handedout{whenver} %% included in headers/footers X%% \Solutions %% optionally include solutions X%% %% can also say \answerstrue X%% \listofproblems %% a table of problems & point values X%% \begin{problems} X%% \problem \Points{20} X%% This is the question X%% \begin{answer} X%% This is the answer X%% \end{answer} X%% X%% \problem X%% \begin{enumerate} X%% \item\Points{10}[labelname] X%% X%% This ia a sub-probem with an optional label name for reference X%% X%% \begin{answer}[3in] X%% This is an answer that will leave 3in of space when answers X%% aren't being printed. X%% \end{answer} X%% X%% \item\Points{5} X%% \ifanswers include some non-boxed in answer X%% \else \vskip 2in \fi X%% X%% \end{enumerate} X%% \end{problems} X X\def\ClassName{CSci} X\def\ClassNumber{} X\def\ClassExam{} X X\newif\ifanswers X\answersfalse X\def\Solutions{\answerstrue} X X\def\handedout#1{\gdef\thehandedout{#1}} X\handedout{\today} X% X\def\ps@classheaders{ X \def\@oddhead{\hbox to \textwidth{ X \ClassName-\ClassNumber \hfill -\thepage- \hfill \thehandedout}} X \def\@oddfoot{\hbox to \textwidth{ X \ClassName-\ClassNumber \hfill -\thepage- \hfill \thehandedout}} X \def\@evenhead{} X \def\@evenfoot{} X} X\pagestyle{classheaders} X X\def\ps@firstclassheaders{ X \def\@oddhead{\hbox to \textwidth{ X \ClassName-\ClassNumber \hfill \thehandedout}} X \def\@oddfoot{\hbox to \textwidth{ X \ClassName-\ClassNumber \hfill -\thepage- \hfill \thehandedout}} X \def\@evenhead{} X \def\@evenfoot{} X} X X\def\ps@examheaders{ X \def\@oddhead{ X \ClassName-\ClassNumber \hfill -\thepage- X \hfill Id\# X \ifanswers X \underline{\Large Solutions} X \else X \underline{\hbox to 2in{}}\fi} X \def\@oddfoot{ X \ClassName-\ClassNumber \hfill -\thepage- \hfill \thehandedout} X \def\@evenhead{} X \def\@evenfoot{} X} X X\def\ps@firstexamheaders{ X \def\@oddhead{% X \hfill X {\Large\bf \ClassName-\ClassNumber~\ClassExam~\Answersp} X \hfill} X \def\@oddfoot{} X \def\@evenhead{} X \def\@evenfoot{} X} X X\pagestyle{classheaders} X\thispagestyle{firstclassheaders} X X\def\Answersp{\ifanswers {\bf Solutions}\fi} X X\newdimen\BAwidth X\def\answerwidth{\textwidth} X X\begingroup X\catcode`\{= 12 \catcode`\}= 12 X \catcode`\[=1 \catcode`]=2 X \catcode`\|=0 \catcode`\\=12 X |global|long|def|@gobbleanswer #1\end{answer}[|end[answer]]% X|endgroup X X\global\def\answer{\@ifnextchar [{\@answer}{\@answer[0pt]}} X X\global\def\@answer[#1]{% X%% X%% Did they specify 'p' for a new page? X%% X\if p#1% X \@tempswatrue X\else X \@tempswafalse X \@tempdima=#1 \relax X\fi X\ifanswers X \def\next{% X \par X \begin{tabular}{|p{\linewidth}|}% X \hline X {\bf Answer:}\\% X } X\else X \def\next{% X \if@tempswa X \clearpage X \else X \ifdim\@tempdima=0pt% X \vfil X \else X \vskip\@tempdima X \fi X \fi X \let\do\@makeother\dospecials\@gobbleanswer}% X\fi \next} X\def\endanswer{\ifanswers \\ \hline \end{tabular}\fi} X X\parindent=0pt X\parskip=6pt X\textheight=9.25in X\textwidth=6.75in X\voffset=-0.5in X\hoffset=-0.25in X\marginparwidth 0pt X\oddsidemargin 0pt X\evensidemargin 0pt X X\def\answerpage{\ifanswers\clearpage\fi} X X%% X%% For true false exams X%% X%% usage: X%% \TrueFalse{false}{text} X%% \TrueFalse{true}{text} X%% X%% first arg is correct answer, only printed \ifanswers is true X%% X X\long\def\TrueFalse#1#2{ X\begingroup X \dimen0=\linewidth X \advance\dimen0 by -10em X \advance\dimen0 by -2\tabcolsep X \def\tfstruct{{\vrule width 0pt height 2.5ex depth 1ex}} X \begin{tabular}{ccp{\dimen0}} X {\bf TRUE} & {\bf FALSE} & \\ X% X \framebox[5em]{\tfstruct X \expandafter\ifanswers\csname if#1\endcsname {$\surd$}\else{}\fi\fi} X & X \framebox[5em]{\tfstruct X \expandafter\ifanswers\csname if#1\endcsname {}\else{$\surd$}\fi\fi} X & {#2} X \end{tabular} X\endgroup X} X X%% X%% points tracking X%% X\newcount\@totalpoints X X\def\listofproblems{% X\makeatletter X\openin1 \jobname.lop X\ifeof1 X \typeout{No list of problems file \jobname.lop, omitting table}% X {\em List of Problems goes here} X \else X \@totalpoints=0 X \begin{tabular}{|l|r|r|p{0.75in}|} X \hline X Problem & Page & Possible & Score\\% X \hline\hline X %%%% X %%%% the body of \@starttoc w/o the outer begingroup...endgroup X %%%% X \@input{\jobname.lop}% X \multicolumn{2}{|c|}{{\bf Total}} & \the\@totalpoints & \\ X \hline X \end{tabular} X \makeatother X\fi X \if@filesw \expandafter\newwrite\csname tf@lop\endcsname X \expandafter\openout \csname tf@lop\endcsname \jobname.lop\relax X \fi \global\@nobreakfalse X} X X X\def\problems{\begin{enumerate}} X\def\problem{\addtocontents{lop}{\protect{\@PointSpacer}}\item} X\def\endproblems{\end{enumerate}} X X\newcount\@pointCount X\@pointCount=0 X X\def\@pointLabel#1[#2]{% X \label{#2} X {\bf [~#1~Points~]~} X \addtocontents{lop}{\protect{\@PointItem}{#2}{#1}} X} X\def\Points#1{% X \@ifnextchar [% X {\@pointLabel#1}% X {\global\advance\@pointCount by 1% X \@pointLabel#1[p@l@\the\@pointCount]% X } X} X X\def\@PointItem #1#2 {% X\global\advance\@totalpoints by #2\relax% X\ref{#1} & \pageref{#1} & #2 &\\% X\hline} X X\def\@PointSpacer {\gdef\@PointSpacer{\hline\hline}} X X\def\PointsItem#1#2{ X \global\@namedef{@p:#1}{#2} X} X X\def\PointsRef#1{% X \@ifundefined{@p:#1}{\hbox{??}}{\csname @p:#1\endcsname} X} X END_OF_FILE if test 7398 -ne `wc -c <'class.sty'`; then echo shar: \"'class.sty'\" unpacked with wrong size! fi # end of 'class.sty' fi echo shar: End of shell archive. exit 0