%20%E8%B3%AA%E5%95%8F%E3%82%92%E4%BF%AE%E6%AD%A3%E3%81%99%E3%82%8B.png)
私は複数のバージョンのMcExamパッケージを使用してMcExamを作成しています。最初の2つの質問は次のように書かれています。
\documentclass{article}
\usepackage{mcexam}
\begin{document}
\begin{mcquestions}
%%%% Header questions (not be included in randomization) %%%
\question What is the version of your question booklet?
\begin{mcanswerslist}
\answer[correct] Version A
\answer Version B
\end{mcanswerslist}
\question Your exam will be graded only if you write your version on top of the bubble
sheet provided. Did you write the version number on top of the bubble sheet?
\begin{mcanswerslist}
\answer[correct] Yes, I have written the version number on top of the bubble sheet.
\answer No, I have not yet written the version number on top of the bubble sheet.
\end{mcanswerslist}
%%%% Main test questions (starting with #3, included in randomization) %%%
\question What is 5 + 2?
\begin{mcanswerslist}
\answer[correct] 7
\answer 5
\answer 3
\end{mcanswerslist}
\question What is 1 + 3?
\begin{mcanswerslist}
\answer[correct] 4
\answer 6
\answer 2
\end{mcanswerslist}
\end{mcquestions}
\end{document}
ヘッダーの質問は、試験の両方のバージョンで質問 1 と質問 2 になるはずです。
しかし、ランダム化の際にこれら 2 つの質問を除外する方法がわかりません。
[follow] オプションを使用しようとしましたが、パッケージでは最初の質問に follow オプションを含めることができません。
また、mcexam.sty パッケージを改造して、最初の 2 つの質問をランダム化から除外するか、[fixposition] オプションを導入しようとしました。最初の 2 つの質問を常に質問 1 と 2 にすることはできましたが、ランダム化によって他の質問も #1 と #2 に割り当てられ、意図した質問 1 と 2 が上書きされてしまいました。
また、mcquestion 環境を開始する前に 2 つの質問を含めようとしましたが、mcquestion 環境にカウンターを 3 から開始するように指示する方法がわかりませんでした。\setcounter を使用しようとしましたが、どのカウンターを設定すればよいかわかりませんでした。
最後に、mcquestion 環境のセクションを 2 つだけにしようとしましたが、そうすると 2 番目の環境でカウンターが 1 にリセットされてしまいます。
ご意見やご提案はありますか?
答え1
.sty ファイルをいじってみた結果、うまく動作するものができました。
.styファイルのセクション3.1では、質問がランダム化されています。元のコードの978行目から1007行目を次のように置き換えました。
\def\mc@randomizeQuestions{{
% Make the mcquestionblock control sequences which include macro's to set the randomization question counters
% exclude first two questions from randomization by setting counter to 2 and assigning the first two questions the first two numbers
\setcounter{mc@counter}{2}
\foreach \v in {1,...,\mc@totalNumberOfVersions}{
\foreach \q in {1,...,2}{
\csxdef{mc@randomQuestionNumberV\v Q\q}{\q}
\csxdef{mc@originalQuestionNumberV\v Q\q}{\q}
}
} % For the randomization start at question q=3
\foreach \q in {3,...,\mc@totalNumberOfQuestions}{
\ifcsstring{mc@questionOption\q}{follow}{}{
\refstepcounter{mc@counter}
\csgdef{mc@questionblock\arabic{mc@counter}}{}
}
\csxappto{mc@questionblock\arabic{mc@counter}}{
\noexpand\refstepcounter{mc@counter}
\noexpand\csxdef{mc@randomQuestionNumberV\noexpand\v Q\q}{\noexpand\arabic{mc@counter}}
\noexpand\csxdef{mc@originalQuestionNumberV\noexpand\v Q\noexpand\arabic{mc@counter}}{\q}
}
}
% randomize question blocks
\numdef\@numberofswaps{\mc@totalNumberOfQuestionblocks-1}
\foreach \v in {1,...,\mc@totalNumberOfVersions}{
\foreach \q in {1,...,\@numberofswaps}{
\pgfmathrandominteger{\r}{\q}{\@numberofswaps}
\numdef\r{\r+1}
\global\letcs\@swap{mc@questionblock\r}
\global\csletcs{mc@questionblock\r}{mc@questionblock\q}
\global\cslet{mc@questionblock\q}{\@swap}
} % For the randomization question block 2
\setcounter{mc@counter}{2}
\foreach \q in {1,...,\mc@totalNumberOfQuestionblocks}{
\csuse{mc@questionblock\q}
}
}
}}
これは
- 最初の2つの質問を1番と2番に割り当て、
- ランダム化では、それぞれ mc@counter と開始カウンターを増加させます。
すべての MC 試験でヘッダー質問としてまったく同じ 2 つの質問があるため、これは私にとっては有効です。
しかし、これはあまりエレガントな解決策ではないので、私はもっと良い解決策に興味があります。