
exam
私は、図に示すように、さまざまなファイルからランダムに選択された質問を作成しようとしました。ここ。
私が使用したコードは動作しますが、ランダムにのみランダム化されます。つまり、第 1 ラウンドでは一連の質問が提供され、第 2 ラウンドから第 4 ラウンドでは変更されず、第 5 ラウンドと第 6 ラウンドでは新しい順序が提供され、その後のいくつかのコンパイルでは再び変更されません。
エラーはなく、コンパイル時にランダム化が失敗するだけです。おそらく、単なる偶然でしょう。私は 9 つのファイルしか使用していませんが、それでも少なくとも 1 つの変更があるはずです (確率論によると)。
使っていますTeXLive v1.17
。
以下に、「Photochem」、「Photophys」、「Quenching 」という3 つのフォルダーがあります。これらの各フォルダーにはPC1.tex
、、、; 、、、; 、、、PC2.tex
という3 つのファイルがあります。PC3.tex
PP1.tex
PP2.tex
PP3.tex
Quench1.tex
Quench2.tex
Quench3.tex
各ファイルにはファイル名がテキストとして含まれているだけなので (Hello World
例のように)、どのファイルが選択されているかがわかります。
他にもこのシナリオを再現できる人はいますか?もしできるなら、それを克服する方法について何かアドバイスはありますか?
\documentclass{article}
%\usepackage[paperheight=3.0cm, paperwidth=12.0cm, margin=0.1cm]{geometry}% Simplify image capture
\usepackage{enumitem}
\usepackage{tikz}% Easy way to get all the pgf functions
% The list of topics determines how many questions will be in the quiz
% since it appears that you want one question per topic in a quiz.
% This could be auto generated.
\newcommand*{\ListOfTopics}{%
Photochem,% MUST have trailing % here
Photophys,%
Quenching%
}%
% These list of files names from each question can be auto generated
% but for example purposes I am just using the file names as the
% content in the file. The number of questions in each topic do not
% need to be the same. I would create directories with the topic
% names and auto generate this based on the directory and file names.
\pgfmathdeclarerandomlist{Photochem}{%
{PC1}%
{PC2}%
{PC3}%
}%
\pgfmathdeclarerandomlist{Photophys}{%
{PP1}%
{PP2}%
{PP3}%
}%
\pgfmathdeclarerandomlist{Quenching}{%
{Quench1}%
{Quench2}%
{Quench3}%
}%
\newcommand*{\NumberOfQuizes}{4}%
\begin{document}
\foreach \QuizNumber in {1,...,\NumberOfQuizes} {%
\clearpage% Start each quiz on a new page
\noindent\textbf{\Large Quiz Number \QuizNumber}%
\begin{enumerate}
\foreach \Topic in \ListOfTopics {%
% Determine random question to use form list
\pgfmathrandomitem{\RandomQuestion}{\Topic}
% The following should import the file named in \RandomQuestion
\item Random Question from Topic='\Topic':
\textbf{\Large\RandomQuestion}%
}%
\end{enumerate}
}%
\end{document}
答え1
問題はおそらくランダム シードですが、tikz
ライブラリ内は調べていません。私の解決策では、ランダム シードを現在の時刻の値に設定しています。
\documentclass{article}
\usepackage{datetime} % Needed for \currentsecond,\currentminute commands
\usepackage{calculator} % Needed for some calc, but perhaps can be done with tikz too
%\usepackage[paperheight=3.0cm, paperwidth=12.0cm, margin=0.1cm]{geometry}% Simplify image capture
\usepackage{enumitem}
\usepackage{tikz}% Easy way to get all the pgf functions
% The list of topics determines how many questions will be in the quiz
% since it appears that you want one question per topic in a quiz.
% This could be auto generated.
\newcommand*{\ListOfTopics}{%
Photochem,% MUST have trailing % here
Photophys,%
Quenching%
}%
% These list of files names from each question can be auto generated
% but for example purposes I am just using the file names as the
% content in the file. The number of questions in each topic do not
% need to be the same. I would create directories with the topic
% names and auto generate this based on the directory and file names.
\pgfmathdeclarerandomlist{Photochem}{%
{PC1}%
{PC2}%
{PC3}%
}%
\pgfmathdeclarerandomlist{Photophys}{%
{PP1}%
{PP2}%
{PP3}%
}%
\pgfmathdeclarerandomlist{Quenching}{%
{Quench1}%
{Quench2}%
{Quench3}%
}%
\newcommand*{\NumberOfQuizes}{8}%
\begin{document}
\def\TotalSecondsMinute{}
\def\TotalSeconds{}
\MULTIPLY{\currentminute}{60.0}{\TotalSecondsMinute}
\ADD{\TotalSecondsMinute}{\currentsecond}{\TotalSeconds}
\TotalSeconds
\pgfmathsetseed{\TotalSeconds}% Uses the number of seconds since the hour started
\foreach \QuizNumber in {1,...,\NumberOfQuizes} {%
%\clearpage% Start each quiz on a new page
\noindent\textbf{\Large Quiz Number \QuizNumber}%
\begin{enumerate}
\foreach \Topic in \ListOfTopics {%
% Determine random question to use form list
\pgfmathrandomitem{\RandomQuestion}{\Topic}
% The following should import the file named in \RandomQuestion
\item Random Question from Topic='\Topic':
\textbf{\Large\RandomQuestion}%
}%
\end{enumerate}
}%
\end{document}
質問が変わります。これはあなたのニーズに合っているでしょうか?
編集 不要なコード行があったので削除しました。