試験クラス: 質問を印刷しない

試験クラス: 質問を印刷しない

試験クラスを使用しているとします。解答を印刷するオプションがあります\printanswersが、そうでない場合は解答は印刷されません。質問を抑制し、解答のみを印刷したいのですが、これは可能ですか?

編集

基本的な回避策を追加しましたが、おそらくもっと良い方法があるでしょう。以下は、修正された試験クラスを使用したデモです。ここ

% Document
\documentclass[12pt]{exam2}

\usepackage[margin=1.0in]{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath}

\pagestyle{fancy}
\lhead{The author}
\rhead{The assignment}

\setcounter{section}{1}
\unframedsolutions

% Preamble
\printquestions
\printanswers

\begin{document}
\numberwithin{question}{section}

\begin{questions}

\begin{quest}
What is $\int_{0}^{5} x^2 dx$?

\end{quest}

\begin{solution}

This integral can be calculated as

\begin{align}
\int_{0}^{5} x^3 &= \Big[ \frac{x^3}{3} \Big|_{0}^{5} \notag \\
&= \frac{5^{3}}{3}
\end{align}

\end{solution}

\begin{quest} 
The next question would go here

\questp{a}{Part a of the question}
\questsp{i}{Subpart of a}
\questspnob{More information}

\end{quest}

\begin{solution}
The next answer would go here

\begin{parts}
\part Parts works in solution environment
\begin{subparts}
\subpart Here is a subpart
\end{subparts}
\end{parts}

\end{solution}

\end{questions}

\end{document}

質問と回答

% Preamble: 
\printquestions
\printanswers

質問と回答

質問のみ

% Preamble:
\printquestions
%\printanswers

質問

回答のみ

% Preamble:
%\printquestions
\printanswers

回答

答え1

exam.cls に次の変更を加えました。

まず、\printquestions オプションを追加しました。

\newif\ifprintanswers
\printanswersfalse
\DeclareOption{answers}{\printanswerstrue}
\DeclareOption{noanswers}{\printanswersfalse}

% BEGIN EDIT %
\newif\ifprintquestions
\printquestionsfalse
\DeclareOption{yesquestions}{\printquestionstrue}
\DeclareOption{noquestions}{\printquestionsfalse}
% END EDIT %

その後

\def\printanswers{\printanswerstrue}
\def\noprintanswers{\printanswersfalse}

\def\printquestions{\printquestionstrue}

次に、ソリューション環境を変更します。質問を印刷しない場合は、ソリューション環境を \question として動作させたいと考えました。

\newenvironment{solution}[1][0pt]{%
  \ifprintquestions % act as a solution
    \@insolutiontrue % cancelled by the end of the environment
    \@addpointsfalse % cancelled by the end of the environment
    \ifprintanswers
      \begingroup
      \Solution@Emphasis
      \begin{TheSolution}%
    \else
      \ifcancelspace
        % Do nothing
      \else
        \par
        \penalty 0
        \vspace*{#1}%
      \fi
      \setbox\z@\vbox\bgroup
    \fi
  \else %act as a question
    \question
  \fi
  }{%
  \ifprintquestions %act as a solution
    \ifprintanswers
      \end{TheSolution}%
      \endgroup
    \else
      \egroup
    \fi
    \fi
  }%

次に、非表示にできるクエスト環境を追加します。ただし、これは \question の代わりに使用する必要があります。

\newenvironment{quest}[1][0pt]%
  {%
    \ifprintquestions % act as a question
        \question
    \else % don't show the question
        %\par
        %\vspace*{-9mm} %
      \setbox\z@\vbox\bgroup
    \fi
  }{%
    \ifprintquestions
        % don't do anything
    \else % hide the group
      \egroup
    \fi
  }%

厄介なことの 1 つは、itemize リスト、パーツ、サブパーツが、私が定義した環境では機能しないことです (これは、初期化していないいくつかの変数を \question 呼び出しで初期化するためだと考えています)。そのため、tabular 環境を使用して基本的な itemize リスト コマンドをいくつか作成しました。

% PART
\newcommand{\questp}[2]{%
\begin{tabular}{R{0.25cm} p{14.75cm}}
(#1) & #2 \\ 
\end{tabular}

{}
}

\usepackage{array,booktabs,ragged2e}
\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash}p{#1}}
\newcommand{\questsp}[2]{%
 \hspace*{2em}\begin{tabular}{R{1cm} p{13.15cm}}
(#1) & #2 \\
\end{tabular}

{}
}

% SUBPART
\newcommand{\questssp}[1]{%
\hspace*{8em}\begin{tabular}{p{10.75cm}}
#1 \\ 
\end{tabular}

{}
}

さらにいくつかのパーツコマンドを次のように定義できます。

\newcommand{\questpnob}[1]{%
\begin{tabular}{R{0.25cm} p{13.15cm}}
 & #1 \\
\end{tabular}

{}
}

\newcommand{\questspnob}[1]{%
 \hspace*{2em}\begin{tabular}{R{1cm} p{13.15cm}}
& #1 \\
\end{tabular}

{}
}

関連情報