From 269b1c9908928f061e4df669f46ce885ff9b4730 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 18 Dec 2023 20:56:13 +0000 Subject: jnuexam (18dec23) git-svn-id: svn://tug.org/texlive/trunk@69161 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls | 125 +++++++++++++++++++----- 1 file changed, 99 insertions(+), 26 deletions(-) (limited to 'Master/texmf-dist/tex/latex/jnuexam') diff --git a/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls b/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls index 5b25fa01d69..c70cee0fd94 100644 --- a/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls +++ b/Master/texmf-dist/tex/latex/jnuexam/jnuexam.cls @@ -2,11 +2,11 @@ % ---------------------------------------------------------------------------- % Author: Jianrui Lyu % Website: https://lvjr.bitbucket.io/jnuexam.html -% License: The LaTeX Project Public License 1.3 +% License: The LaTeX Project Public License 1.3c % ---------------------------------------------------------------------------- \NeedsTeXFormat{LaTeX2e} -\ProvidesClass{jnuexam}[2023/12/11 v2.0 An exam class for Jinan University] +\ProvidesClass{jnuexam}[2023/12/18 v2.1 An exam class for Jinan University] %% 旧版本的 LaTeX 不能识别 2022-11-01 这种日期格式 %\@ifl@t@r\fmtversion{2022-11-01}{}{ @@ -396,12 +396,32 @@ \pagestyle{fancy} \fi +%% --------------------------------------------------------------------------- +%% 乱序排列选项 random +%% 随机种子选项 seed +%% --------------------------------------------------------------------------- + +%% 随机数种子不能超过 2147483647 = "7FFFFFFF +\def\my@random@seed{19061116} +\define@key{jnuexam@setup}{seed}[19061116]{\def\my@random@seed{#1}} + +\ifrandom + \RequirePackage{pgf} + \RequirePackage{pgffor} + \newcommand*\exam@set@seed{% + %% 当\pgfmathrandom的参数为3的倍数时,对相邻种子生成的多个随机数分布不均匀 + %\pgfmathsetseed{\numexpr\my@random@seed+\value{section}-1\relax}% + %% 因此我们改用下面的方法,用随机数种子生成下一个随机数种子 + \pgfmathsetseed{\my@random@seed}% + \pgfmathrandominteger\my@random@seed{1}{2147483647}% + } +\fi + %% --------------------------------------------------------------------------- %% 题型命令 \makepart %% 附录命令 \makedata %% 题目环境 problem %% 解答环境 solution -%% 乱序选项 random %% --------------------------------------------------------------------------- \newif\ifonlyoneproblem \onlyoneproblemfalse % 此部分仅有一道题时不显示题目编号 @@ -418,11 +438,6 @@ \colorlet{problem number}{blue!80!black} \colorlet{solution name}{blue!80!black} -\ifrandom - \RequirePackage{pgf} - \RequirePackage{pgffor} -\fi - \newcounter{my@shuffle@temp@cnt} \newcounter{my@list@temp@cnt} @@ -448,16 +463,8 @@ \dolistloop\my@tmpa@list } -%% 随机数种子不能超过 2147483647 = "7FFFFFFF -\def\my@random@seed{19061116} -\define@key{jnuexam@setup}{seed}[19061116]{\def\my@random@seed{#1}} - \newcommand\my@shuffle@problems{% - %% 当\pgfmathrandom的参数为3的倍数时,对相邻种子生成的多个随机数分布不均匀 - %\pgfmathsetseed{\numexpr\my@random@seed+\value{section}-1\relax}% - %% 因此我们改用下面的方法,用随机数种子生成下一个随机数种子 - \pgfmathsetseed{\my@random@seed}% - \pgfmathrandominteger\my@random@seed{1}{2147483647}% + \exam@set@seed \ifnumgreater{\value{problem}}{2}{% \gdef\my@shuffle@list{}% \foreach \i in {1,...,\value{problem}} {\listxadd\my@shuffle@list{\i}}% @@ -715,9 +722,6 @@ \newcommand*{\tick@text@F}{\sffamily F} \newcommand*{\tickin}[1]{\tick@box{\csname tick@text@#1\endcsname}} \newcommand*{\tickout}[1]{\unskip\nobreak\cdotfill\tick@box{\csname tick@text@#1\endcsname}} -% 过时命令,不要再使用 -%\newcommand*{\true}{\tickout{t}} -%\newcommand*{\false}{\tickout{f}} \newcommand*{\ulinefill}[1]{\xleaders\hbox{\underline{\vphantom{#1}\kern1pt}}\hfill\kern0pt} \newcommand*{\minwidthbox}[2]{\makebox[{\ifdim#1<\width\width\else#1\fi}]{#2}} @@ -725,8 +729,55 @@ \newcommand*{\fillout}[1]{\allowbreak\hbox{}\nobreak\ulinefill{#1}\underline{\color{blue}\answer{#1}}\ulinefill{#1}} \newcommand*{\fillin}[1]{\underline{\hspace{1em}\color{blue}\minwidthbox{2em}{\answer{#1}}\hspace{1em}}} -\newcommand*{\pickout}[1]{\unskip\nobreak\cdotfill(\makebox[1.5em]{\color{blue}\answer{#1}})} -\newcommand*{\pickin}[1]{\unskip\nobreak\hspace{0.3em}(\makebox[1.5em]{\color{blue}\answer{#1}})\hspace{0.3em}\ignorespaces} +\newcommand*\pickoutreal[1]{% + \unskip\nobreak\cdotfill(\makebox[1.5em]{\color{blue}\answer{#1}})% +} +\newcommand*\pickinreal[1]{% + \unskip\nobreak + \hspace{0.3em}(\makebox[1.5em]{\color{blue}\answer{#1}})\hspace{0.3em}% + \ignorespaces +} + +%% 选择题四个选项打乱顺序,用三种方法即可保证答案不同 +%% 1:ABCD -> CDAB; 2:ABCD -> BADC; 3: ABCD -> DCBA +%% 即在两行排列时仅用到上下交换以及左右交换,这样可以保持两行长度不变 + +\csdef{my@shuffle@1@A}{C} \csdef{my@shuffle@2@A}{B} \csdef{my@shuffle@3@A}{D} +\csdef{my@shuffle@1@B}{D} \csdef{my@shuffle@2@B}{A} \csdef{my@shuffle@3@B}{C} +\csdef{my@shuffle@1@C}{A} \csdef{my@shuffle@2@C}{D} \csdef{my@shuffle@3@C}{B} +\csdef{my@shuffle@1@D}{B} \csdef{my@shuffle@2@D}{C} \csdef{my@shuffle@3@D}{A} + +\def\@my@choice@random{0} +\newcommand\my@shuffle@abcd[1]{\csuse{my@shuffle@\@my@choice@random @#1}} + +\newcommand*\pickout[1]{% + \ifbool{random}{% + \exam@set@seed + \pgfmathrandominteger\@my@choice@random{1}{3}% + %\@my@choice@random + \pickoutreal{\my@shuffle@abcd{#1}}% + }{% + \pickoutreal{#1}% + }% +} +\newcommand*\pickoutfixed[1]{% + \pickoutreal{#1}% + \randomfalse +} +\newcommand*\pickin[1]{% + \ifbool{random}{% + \exam@set@seed + \pgfmathrandominteger\@my@choice@random{1}{3}% + %\@my@choice@random + \pickinreal{\my@shuffle@abcd{#1}}% + }{% + \pickinreal{#1}% + }% +} +\newcommand*\pickinfixed[1]{% + \pickinreal{#1}% + \randomfalse +} %% --------------------------------------------------------------------------- %% 选择题四个选项排版环境,根据四个选项的长度自动排成一行、两行或四行 @@ -753,7 +804,7 @@ \my@label@text\ignorespaces } -\NewEnviron{abcd}{ +\NewEnviron{abcdreal}{ \unskip \setlength{\parindent}{0pt}% \setlength{\parskip}{0pt}% @@ -787,7 +838,7 @@ \stepcounter{choice}(\Alph{choice})\ % } -\NewEnviron{abcd*}{ +\NewEnviron{abcd*real}{ \unskip \setlength{\parindent}{0pt}% \setlength{\parskip}{0pt}% @@ -814,6 +865,30 @@ \fi } +\ifbool{random}{% + \csdef{my@swap@items@1}#1#2#3#4{\item#3\item#4\item#1\item#2} + \csdef{my@swap@items@2}#1#2#3#4{\item#2\item#1\item#4\item#3} + \csdef{my@swap@items@3}#1#2#3#4{\item#4\item#3\item#2\item#1} + \long\def\my@swap@items#1\item#2\item#3\item#4\item#5\@my@stop@mark{% + #1\csuse{my@swap@items@\@my@choice@random}{#2}{#3}{#4}{#5}% + } +}{} + +\NewDocumentEnvironment{abcd}{+b}{% + \ifbool{random}{% + \begin{abcdreal}\my@swap@items#1\@my@stop@mark\end{abcdreal}% + }{% + \begin{abcdreal}#1\end{abcdreal}% + }% +}{} +\NewDocumentEnvironment{abcd*}{+b}{% + \ifbool{random}{% + \begin{abcd*real}\my@swap@items#1\@my@stop@mark\end{abcd*real}% + }{% + \begin{abcd*real}#1\end{abcd*real}% + }% +}{} + %% --------------------------------------------------------------------------- %% 设定有序列表使用悬挂缩进,并指定前两级有序列表的标签格式 %% 标签宽度按最宽者自动设定,左边距自动计算,竖直空白全部去掉 @@ -914,7 +989,6 @@ \pointstext{#1}% }% } -%\let\score=\points % \score 命令已经废弃,不要再使用 %% --------------------------------------------------------------------------- %% 载入个人定制文件 jnuexam.cfg @@ -1128,7 +1202,6 @@ \let\my@saved@sum=\sum \def\sum{\my@saved@sum\limits}% \let\my@saved@prod=\prod \def\prod{\my@saved@prod\limits}% } -%\newcommand{\limit}{\lim\limits} % 废弃命令,不要再使用 \newcommand{\e}{\mathrm{e}} \newcommand{\R}{\mathbb{R}} -- cgit v1.2.3