我怎样才能在文档开头的考试包中放置不同的成绩表?

我怎样才能在文档开头的考试包中放置不同的成绩表?

我想自己动手制作成绩表exam包,但我很难处理源代码。这是我的解决方案,但我必须把它放在文档的末尾。为了把它放在开头,我totcount在这个演示中使用了这个包,并借助我的 egreg上一个问题

该文件应该运行两次。

\documentclass[answers,12pt,addpoints]{exam}
\usepackage{xparse,expl3}
\usepackage{totcount,xinttools,xfp}
\usepackage{tabu}
%\newtotcounter{sumpoints}
\newtotcounter{examSection}

\ExplSyntaxOn
\clist_new:N \g_brooksexam_clist
\NewDocumentCommand{\makepart}{ m m m }{
    \clist_gput_right:Nn \g_brooksexam_clist {#3}
    \stepcounter{examSection}
    %\immediate\write\@mainaux{%
         %\string\gdef\string\pointsofsection@\roman{examSection}{#3}%
    }%

    %\addtocounter{sumpoints}{#3}
    \begin{EnvFullwidth}
        \textbf{\Roman{examSection} \quad #1(each~#2~points,total~#3~points)}
    \end{EnvFullwidth}
}

%% \NewDocumentCommand{\commlistOnEnd}{}{
%%    \begin{center}
%%        \begin{tabular}{*{\totvalue{examSection}}{c|}}
%%          \xintFor ##1 in \g_brooksexam_clist \do {\xintifForFirst{}{&}##1}
%%        \end{tabular}
%%    \end{center}    
%%}
\ExplSyntaxOff

\begin{document} 
%%%%%%%%%%%%I use the table by the package to see what is in the .aux file
\begin{center}
\gradetable[h][questions]
\end{center}


%\commlistOnEnd  %% not try this way

\begin{questions}
\makepart{Single Choices}{10}{20}
\question[10]
I love \hfill (\quad).

\begin{oneparchoices}
\choice he
\choice she
\CorrectChoice you
\choice my dog
\end{oneparchoices}

\question[10]
I love \hfill (\quad).

\begin{oneparchoices}
\choice he
\choice she
\CorrectChoice you
\choice my dog
\end{oneparchoices}

\makepart{Blank}{10}{30}
\question[10]
I love \fillin[You][1in].
\question[10]
I love \fillin[You][1in].
\question[10]
I love \fillin[You][1in].

\makepart{Computations}{20}{40}
\question[20]
Why you love me?
\begin{solution}
You are temperament and beautiful.
\end{solution}

\question[20]
Why you love me?
\begin{solution}
You are temperament and beautiful.
\end{solution}
\end{questions}

%\commlistOnEnd   %% neigher this way
\end{document}

编辑: 以下是.aux文件中的部分代码:

relax 
\gdef\pointsofq@i{10}
\gdef\bonuspointsofq@i{0}
\gdef\pointsofq@ii{10}
\gdef\bonuspointsofq@ii{0}
\gdef\pointsofq@iii{10}
\gdef\bonuspointsofq@iii{0}
\gdef\pointsofq@iv{10}
\gdef\bonuspointsofq@iv{0}
\gdef\pointsofq@v{10}
\gdef\bonuspointsofq@v{0}
\gdef\pointsofq@vi{20}
\gdef\bonuspointsofq@vi{0}
\gdef\pointsofq@vii{20}
\gdef\bonuspointsofq@vii{0}
\PgInfo{question@1}{1}
\PgInfo{question1@object1}{1}
\newlabel{question@1}{{1}{1}}
\newlabel{firstpoints@onpage@1}{{1}{1}}
\PgInfo{question1@object2}{1}
\PgInfo{question1@object3}{1}
\PgInfo{question1@object4}{1}
\PgInfo{question1@object5}{1}
\PgInfo{question@2}{1}

exam软件包的作者 Philip S. Hirschhorn 表示

% \gdef commands for exam@lastpage, exam@numpoints,
% exam@numbonuspoints, exam@numquestions, exam@numparts,
% exam@numsubparts and exam@numsubsubparts are written to the .aux
% file via \AtEndDocument.

 % We make sure the user said \addpoints, and then make sure
  % that this isn't the first run of LaTeX (by checking that
  % \exam@numpoints is defined).

然后

% When we get to \find@qrange, we know we're doing a table indexed by
% question numbers and that this is not the first run of latex.

最后构建表格。

因此,我想我可以尝试使用\@ifundefined{exam@numpoints}%\immediate\write\@mainaux {\string\gdef\string\exam@lastpage{\arabic{page}}}%% See if this has changed from the last run of LaTeX: \CheckIfChanged@hlf{numpoints}{exam@numpoints}%参考作者。具体来说,我可以使用etoolbox包将我的代码附加到 AtEndDocument。

相关内容