我可以为每位学生制作不同的自动考试副本吗?

我可以为每位学生制作不同的自动考试副本吗?

如果我出了一份包含十道多项选择题的考试,而我有 20 名学生,那么我可以通过打乱问题顺序来做一个不同的自动考试副本(每个学生一份)吗?

\documentclass{exam}
\begin{document}
    
\begin{questions} 
        
\question Which of these famous physicists invented time?   
\begin{choices}
    \choice John
    \choice Pau
    \CorrectChoice Ringo
    \choice Socrates
\end{choices}

\question Which of these famous physicists invented time?   
\begin{oneparchoices} 
    \choice Stephen Hawking 
    \choice Albert Einstein
    \correctchoice  Emmy Noether
\end{oneparchoices} 

\question Which of these famous physicists published a paper on Brownian Motion?
\begin{oneparcheckboxes} 
    \choice Stephen Hawking 
    \choice Albert Einstein
    \choice Emmy Noether
    \choice This makes no sense
\end{oneparcheckboxes}  

\question Which of these famous physicists published a paper on Brownian Motion?
\begin{checkboxes}
    \correctchoice  Emmy Noether
    \choice Albert Einstein
    \choice Emmy Noether  H
\end{checkboxes}        
        
\end{questions}
    
\end{document}

答案1

这是一种基于 LaTeX 的方法,可生成按每次编译顺序选择的问题。关键是使用\randomize_env:nn以下命令:

\randomize_env:nn {choices} {choice,CorrectChoice}

第一个参数指定我们想要随机化choices环境;第二个参数表示-like 命令对于此环境item\choice和。实现实际上很简单:捕获随机化命令的主体并根据-like 命令将其拆分为多个段。这些段按顺序存储,随后将使用 进行混洗。结果,输出中引入了随机性。\CorrectChoiceitem\seq_shuffle:N

在此处输入图片描述

\documentclass[answers]{exam}
\usepackage[T1]{fontenc}
\usepackage{expl3}
\usepackage{amsmath}
\usepackage{xparse}

\ExplSyntaxOn

\seq_new:N \l_curenv_seq
\seq_new:N \l_item_cmd_seq
\tl_new:N \l_curitem_tl
\tl_new:N \l_tmpc_tl

\cs_set:Nn \push_curitem: {
  \tl_if_empty:NF \l_curitem_tl {
    \seq_push:NV \l_curenv_seq \l_curitem_tl
  }
}

% randomize an environment
% #1: environment name
% #2: item command names
\cs_set:Npn \randomize_env:nn #1#2 {
  % definitions of the old environment
  \cs_gset_eq:cc {old_#1_e} {#1}
  \cs_gset_eq:cc {old_end#1_e} {end#1}
  
  % redefine the environment
  \RenewDocumentEnvironment{#1}{+b}{
    \tl_set:Nn \l_tmpa_tl {##1}
    % replace all space characters with explicit space command
    \regex_replace_all:nnN {\s} {\c{space}} \l_tmpa_tl
    
    %\tl_show:N \l_tmpa_tl
    % process item commands
    \clist_set:Nn \l_tmpa_clist {#2}
    \seq_clear:N \l_item_cmd_seq
    \clist_map_variable:NNn \l_tmpa_clist \l_tmpb_tl {
      \exp_args:NNo \tl_set:No \l_tmpc_tl {\use:c {\l_tmpb_tl}}
      \seq_push:NV \l_item_cmd_seq \l_tmpc_tl
    }
    %\seq_show:N \l_item_cmd_seq
    
    % analyze content and form sequence
    \seq_clear:N \l_curenv_seq
    \tl_clear:N \l_curitem_tl
    
    \bool_do_while:nn {!\tl_if_empty_p:N \l_tmpa_tl} {
      % add space if space is found
      % pop first item
      \tl_set:Nx \l_tmpb_tl {\tl_head:N \l_tmpa_tl}
      \tl_set:Nx \l_tmpa_tl {\tl_tail:N \l_tmpa_tl}
      
      \seq_if_in:NVTF \l_item_cmd_seq \l_tmpb_tl {
        % if an item command is found
        % update variables
        \push_curitem:
        \tl_clear:N \l_curitem_tl
        \tl_put_right:NV \l_curitem_tl \l_tmpb_tl
      } {
        \tl_put_right:NV \l_curitem_tl \l_tmpb_tl
      }
      
    }
    % if the last item is not empty, push it into the sequence
    \push_curitem:
  }{
    % shuffle the sequence
    \seq_shuffle:N \l_curenv_seq
    \use:c {old_#1_e}
    \seq_use:Nn \l_curenv_seq {}
    \use:c {old_end#1_e}
  }
}

\randomize_env:nn {choices} {choice,CorrectChoice}
\randomize_env:nn {oneparchoices} {choice,correctchoice}
\randomize_env:nn {oneparcheckboxes} {choice,correctchoice}
\randomize_env:nn {checkboxes} {choice,correctchoice}
\ExplSyntaxOff

\begin{document}

\begin{questions} 
        
\question Which of these famous physicists invented time?   
\begin{choices}
    \choice John
    \choice Pau
    \CorrectChoice Ringo
    \choice Socrates
\end{choices}

\question Which of these famous physicists invented time?   
\begin{oneparchoices} 
    \choice Stephen Hawking 
    \choice Albert Einstein
    \correctchoice  Emmy Noether
\end{oneparchoices} 

\question Which of these famous physicists published a paper on Brownian Motion?
\begin{oneparcheckboxes} 
    \choice Stephen Hawking 
    \choice Albert Einstein
    \choice Emmy Noether
    \choice This makes no sense
\end{oneparcheckboxes}  

\question Which of these famous physicists published a paper on Brownian Motion?
\begin{checkboxes}
    \correctchoice  Emmy Noether
    \choice Albert Einstein
    \choice Emmy Noether  H
\end{checkboxes}        
        
\end{questions}
    
\end{document}


相关内容