파일 문제의 무작위 선택

파일 문제의 무작위 선택

exam다음과 같이 다른 파일에서 선택된 무작위 질문을 만들려고 했습니다 .여기.

내가 사용한 코드는 작동하지만 무작위로 무작위로 추출됩니다. 즉, 1라운드에서는 일련의 질문을 제공하고, 2~4라운드에서는 변경 사항이 없으며, 5라운드 및 6라운드에서는 새로운 순서가 제공되고, 다른 몇 가지 편집에서는 다시 변경되지 않습니다.

오류는 없으며 컴파일 시 무작위화가 실패합니다. 어쩌면 그것은 단지 우연일지도 모릅니다. 나는 9개의 파일만 사용하지만 (확률 이론에 따라) 최소한 1개의 변경 사항이 있어야 합니다.

을 사용하고 있습니다 TeXLive v1.17.

아래에는 'Photochem', 'Photophys' 및 'Quenching'이라는 3개의 폴더가 있습니다. 각 폴더에는 PC1.tex, PC2.tex, PC3.tex; 라는 이름의 파일이 3개 있습니다. 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}

질문이 바뀌었습니다. 이것이 귀하의 요구 사항에 맞습니까?

편집하다 불필요한 코드가 있어서 삭제했습니다.

관련 정보