使用学生姓名列表创建数学考试

使用学生姓名列表创建数学考试

我是来自德国的数学老师。我想为我的学生创建测试。按照惯例,我将设计两个测试组:

  • 测试A
  • 测试 B

我还将提供一份名单:

  • 彼得
  • 朱丽叶
  • ...

我希望 Joe 获得测试 A,Peter 获得测试 B,Julie 获得测试 A,依此类推。因此伪代码如下:

for(i=0; i<names.size(); i++)
 if(i even)
  addpagewith(name(i), testA)
 else
   addpagewith(Name(i), testB)

其中 addpagewith 函数的工作方式如下

\include{head}
 Name: name(i)
\include{testA.tex}

这应该会生成一个包含.pdf与学生数量一样多的页面的文件。阻止我自己尝试的原因是:

  1. 我不知道容器(名称列表)在 LaTeX 中是否工作以及如何工作
  2. 我不知道 for 循环或替代方法在 Latex 中是否有效以及如何工作

有人可以指出我在哪里可以找到这个的正确方向,或者更好地提供一个最小的工作示例吗?

答案1

您可以使用包中的 foreach pgffor

\documentclass{article}
\usepackage{pgf,pgffor}

\begin{document}
\foreach \x [count=\xi] in {Joe,Peter,Julie} {
    \input{head}
    Name: $\mathrm{\x}$
  \ifodd\xi
     \input{testA}
  \else
    \input{testB}
  \fi
}
\end{document}

注意input而不是include以防止清除页面。测试文件:

head.tex

\section*{Today's test}

testA.tex

\section*{Test A}
Solve: 1+1
\clearpage

testB.tex

\section*{Test B}
Solve: 2+1
\clearpage

使用section*是为了防止章节编号。

答案2

改进版本——带有漂亮的标题

这定义了一个以逗号分隔的列表,并将学生姓名存储在该列表中;之后将其内容映射到一个\DoTheHeader宏,该宏显示页眉并包含来自的测试问题testXY.tex- XY 是大写字符的测试编号(因此它只允许 26 个不同的测试;-))

\documentclass{article}

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[ngerman]{babel}
\usepackage[tmargin=1cm,lmargin=1cm,rmargin=1cm,bmargin=1cm]{geometry}

\usepackage{xparse}

\newcounter{testgroup}

\NewDocumentCommand{\DoTheHeader}{O{2}m}{%
  \ifnum\value{testgroup} < #1%
  \stepcounter{testgroup}%
  \else%
  \setcounter{testgroup}{1}%
  \fi%
  \clearpage%
  {%
    \centering
    \bfseries
    \begin{tabularx}{\linewidth}{XXX}
      \toprule
      Name der Pappnase:  & Datum:  & Fach: Mathematik \tabularnewline
      #2 & \today & Testgruppe \Alph{testgroup} \tabularnewline
      \bottomrule
    \end{tabularx}
  }

  \bigskip%
  \InputIfFileExists{test\Alph{testgroup}.tex}{}{} % Load the content from disk
  \blindtext[2]
}




\ExplSyntaxOn
\clist_new:N \l_bjoern_studentnames_clist
\NewDocumentCommand{\FillStudentNames}{m}{%
  \clist_set:Nn \l_bjoern_studentnames_clist {#1}
}

\NewDocumentCommand{\AssignTestToStudents}{O{2}}{%
  \setcounter{testgroup}{0}  
  % loop through the clist 
  \clist_map_inline:Nn {\l_bjoern_studentnames_clist} {\DoTheHeader[#1]{##1}}  %##1 comes from from the list -> student name
}

\ExplSyntaxOff



\usepackage{blindtext}


\FillStudentNames{Janis Joplin, Grace Slick, John Lennon, 
  Paul McCartney, George Harrison, Ringo Starr, Groucho Marx, 
  Harpo Marx, Zeppo Marx,Chico Marx, Gummo Marx, Stan Laurel, Oliver Hardy, 
  Graham Chapman, John Cleese, Terry Jones, Terry Gilliam,
  Eric Idle, Cameron Diaz, Paulo Cereda, Other blokes on TeX.SX}

\begin{document}
\AssignTestToStudents % Uses 2 as maximal test group value A,B


\AssignTestToStudents[5] % Uses 5 as maximal test group value A,B,C,D,E

\end{document}

在此处输入图片描述

答案3

我和我的同事创建了一个程序,以使用我们的包esami和包来获取您想要的东西datatool

测试通过编译 tex 文件生成,该文件会生成一个 pdf,其中会自动插入学生的数据。数据是从 csv 文件中读取的。

每个学生可以有不同的测试,或者您可以为每个学生分配两个版本中的一个。

您可以在此链接中看到https://www.dropbox.com/s/oxgok5rx76xlhyr/prova-test.pdf?dl=0测试看起来的简单示例(示例是意大利语,但我们的包esami也本地化为德语并且文档文件也是英文的)。

如果您有兴趣,我们可以向您发送主文件和生成此类测试的说明。该包esami位于 CTAN 上(以及 Texlive 和 Miktex 中)。

答案4

这是一个使用(la)TeX 的解决方案\loop

\documentclass{article}
\newcounter{student}
\renewcommand{\thestudent}{%
\ifcase\value{student}\or
  Smith\or 
  John\or 
  Chriss\or 
  David\or 
  Black\or
  notstudent\fi
}
\def\notstudent{notstudent}
\begin{document}
\setcounter{student}{0}
\loop
\stepcounter{student}%
\edef\student{\thestudent}%
\unless\ifx\student\notstudent

Some unchanged stuff

Name: \student

\ifodd\value{student} 
Test A 
\else 
Test B
\fi
\repeat
\end{document}

相关内容