1

mcexam doesn't appear to allow \input commands within the mcquestions environment. This MWE uses the mcexam package to create an exam with three mc questions. The \input line reads the content of a question from file q1.tex, but LaTeX indicates that the top line of that file (i.e., \question ...) is an undefined control sequence. It then combines the answerlists from the first and second questions.

You can comment out the \input line to confirm the MWE works without the external input. And you can copy the content of q1.tex to test.tex to replace the input line and confirm that the content of q1 is good.

% test.tex
\documentclass{article}
\usepackage[output=exam,numberofversions=1,version=1,seed=1,randomizeanswers=false,randomizequestions=false]{mcexam}

\begin{document}

\begin{mcquestions}

\question The sky is \begin{mcanswerslist} \answer green. \answer yellow. \answer[correct] blue. \end{mcanswerslist}

\input{q1.tex}

\question $1+1$ equals \begin{mcanswerslist} \answer 1. \answer[correct] 2. \answer 3. \end{mcanswerslist}

\end{mcquestions}

\end{document}

Here's the external file.

% q1.tex
\question Who was in the Beatles?
\begin{mcanswerslist}
  \answer[correct] John Lennon
  \answer Elton John
  \answer Buddy Holly
\end{mcanswerslist}

And here's a screen shot of the compiled doc.

mcexam_error

Why do I want to read questions from external files with one input line for each question? I'm developing a 1300-question test bank for a text book. I hope there's a simple solution because a complicated solution won't work when we roll this out to instructors.

Ken McL
  • 13

1 Answers1

0

The package scans for \question and saves them all up, probably to support randomising the order, even when randomising is disabled.

The easiest way is to move \question outside:

\documentclass{article}
\usepackage[output=exam,numberofversions=1,version=1,seed=1,randomizeanswers=false,randomizequestions=false]{mcexam}

\begin{document}

\begin{mcquestions}

\question The sky is \begin{mcanswerslist} \answer green. \answer yellow. \answer[correct] blue. \end{mcanswerslist}

\question \input{q1.tex}

\question $1+1$ equals \begin{mcanswerslist} \answer 1. \answer[correct] 2. \answer 3. \end{mcanswerslist}

\end{mcquestions}

\end{document}

with q1.tex

Who was in the Beatles?
\begin{mcanswerslist}
  \answer[correct] John Lennon
  \answer Elton John
  \answer Buddy Holly
\end{mcanswerslist}
David Carlisle
  • 757,742