继续使用 FPeval 的问题

继续使用 FPeval 的问题

我想创建一个模板来标准化我所在机构的试卷。我之前曾问过这个问题但没有得到任何答复。最近,我尝试了下面 MWE 中所示的方法。在那里,我遇到了以下问题:

  1. 在我的尝试中,问题及其部分的不同知识水平的计数器工作正常。然而,一段时间后,个人知识水平的分数计数器出现问题。在编译 MWE 后,我发现在 Qn 16.a 中,分析并没有增加,更令人惊讶的是,评估分数计数器值已减少!其余的都乱了,问题 17 以后。
  2. 标记计数器值被刷新到question环境之外。因此,我\printRBTtable最后无法成功使用该命令。
  3. tabular在 的最后一行里面\printRBTtable,命令\FPeval不起作用,但是,\fpeval工作正常。

请在此处指出问题。我也愿意接受任何解决相关问题的替代解决方案。

\documentclass[a5paper, 11pt]{exam}
\usepackage{fp}
\usepackage{array, siunitx}
%
\newcounter{rem}
\newcounter{und}
\newcounter{app}
\newcounter{ana}
\newcounter{eva}
\newcounter{cre}
%
\edef\rem{0}
\edef\und{0}
\edef\app{0}
\edef\ana{0}
\edef\eva{0}
\edef\cre{0}
\edef\x{0}
%
\newcommand{\rqn}[1]{\question[#1]\emph{(Remembering)}%
    \let\x\rem%
    \FPeval{\rem}{clip(\x+#1)}%
    \refstepcounter{rem}
}
\newcommand{\rpart}[1]{\part[#1]\emph{(Remembering)}%
    \let\x\rem%
    \FPeval{\rem}{clip(\x+#1)}%
    \refstepcounter{rem}
}
\newcommand{\rsubpart}[1]{\subpart[#1]\emph{(Remembering)}%
    \let\x\rem%
    \FPeval{\rem}{clip(\x+#1)}%
    \refstepcounter{rem}
}
%
\newcommand{\uqn}[1]{\question[#1]\emph{(Understanding)}%
    \let\x\und%
    \FPeval{\und}{clip(\x+#1)}%
    \refstepcounter{und}
}
\newcommand{\upart}[1]{\part[#1]\emph{(Understanding)}%
    \let\x\und%
    \FPeval{\und}{clip(\x+#1)}%
    \refstepcounter{und}
}
\newcommand{\usubpart}[1]{\subpart[#1]\emph{(Understanding)}%
    \let\x\und%
    \FPeval{\und}{clip(\x+#1)}%
    \refstepcounter{und}
}
%
\newcommand{\aqn}[1]{\question[#1]\emph{(Applying)}%
    \let\x\app%
    \FPeval{\app}{clip(\x+#1)}%
    \refstepcounter{app}
}
\newcommand{\apart}[1]{\part[#1]\emph{(Applying)}%
    \let\x\app%
    \FPeval{\app}{clip(\x+#1)}%
    \refstepcounter{app}
}
\newcommand{\asubpart}[1]{\subpart[#1]\emph{(Applying)}%
    \let\x\app%
    \FPeval{\app}{clip(\x+#1)}%
    \refstepcounter{app}
}
%
\newcommand{\bqn}[1]{\question[#1]\emph{(Analysing)}%
    \let\x\ana%
    \FPeval{\ana}{clip(\x+#1)}%
    \refstepcounter{ana}
}
\newcommand{\bpart}[1]{\part[#1]\emph{(Analysing)}%
    \let\x\ana%
    \FPeval{\ana}{clip(\x+#1)}%
    \refstepcounter{ana}
}
\newcommand{\bsubpart}[1]{\subpart[#1]\emph{(Analysing)}%
    \let\x\ana%
    \FPeval{\ana}{clip(\x+#1)}%
    \refstepcounter{ana}
}
%
\newcommand{\evqn}[1]{\question[#1]\emph{(Evaluating)}%
    \let\x\eva%
    \FPeval{\eva}{clip(\x+#1)}%
    \refstepcounter{eva}
}
\newcommand{\evpart}[1]{\part[#1]\emph{(Evaluating)}%
    \let\x\eva%
    \FPeval{\eva}{clip(\x+#1)}%
    \refstepcounter{eva}
}
\newcommand{\evsubpart}[1]{\subpart[#1]\emph{(Evaluating)}%
    \let\x\eva%
    \FPeval{\eva}{clip(\x+#1)}%
    \refstepcounter{eva}
}
%
\newcommand{\cqn}[1]{\question[#1]\emph{(Creating)}%
    \let\x\eva%
    \FPeval\cre{clip(\x+#1)}%
    \refstepcounter{cre}
}
\newcommand{\cpart}[1]{\part[#1]\emph{(Creating)}%
    \let\x\eva%
    \FPeval\cre{clip(\x+#1)}%
    \refstepcounter{cre}
}
\newcommand{\csubpart}[1]{\subpart[#1]\emph{(Creating)}%
    \let\x\eva%
    \FPeval\cre{clip(\x+#1)}%
    \refstepcounter{cre}
}
%
\newcommand{\printRBTtable}[1]{%
    \begin{center}%
        \def\arraystretch{#1}%
        \begin{tabular}{|l|S|S|}%
            \hline%
            \multicolumn{1}{|c|}{\small\textbf{Knowledge levels}}   &   \multicolumn{1}{c}{\small\textbf{Number of questions}}  &   \multicolumn{1}{|c|}{\small\textbf{Marks}}\\%
            \hline%
            Remembering &   \therem &   \rem\\%
            \hline%
            Understanding   &   \theund &   \und\\%
            \hline%
            Applying    &   \theapp &   \app\\%
            \hline%
            Analysing   &   \theana &   \ana\\%
            \hline
            Evaluating  &   \theeva &   \eva\\%
            \hline
            Creating    &   \thecre &   \cre\\%
            \hline%
            \textbf{Total}  &   \fpeval{\therem+\theund+\theapp+\theana+\theeva+\thecre}    &   \fpeval{\rem+\und+\app+\ana+\eva+\cre} \\%
            \hline
        \end{tabular}
    \end{center}
}
%
\begin{document}
%
\subsubsection*{\centering{GROUP -- A\\ \small Answer any FIVE questions.\normalsize}}\vspace{1ex}
%
\begin{questions}
%
%Qn 1
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 2
%
\evqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 3
%
\aqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 4
%
\rqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 5
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 6
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 7
%
\aqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 8
%
\rqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%
\subsubsection*{\centering{GROUP -- B\\ \small Answer any FOUR questions.\normalsize}}\vspace{1ex}
%
%
%
%Qn 9
%
\evqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 10
%
\uqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 11
%
\aqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 12
%
\bqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 13
%
\bqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 14
%
\uqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%
\subsubsection*{\centering{GROUP -- C\\ \small Answer any TWO questions.\normalsize}}\vspace{1ex}
%
%
%
%Qn 15
%
\question
\begin{parts}
%15.a
\bpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%15.b
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
%Qn 16
%
\question
\begin{parts}
%Qn 16.a
\bpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%16.b
\apart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
% Qn 17
%
\question
\begin{parts}
%17.a
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%17.b
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
%Qn 18
%
\question
\begin{parts}
%18.a
\apart{3}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%18.b
\bpart{7}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{5ex}
%
\printRBTtable{1.25}
%
%
\end{questions}

\printRBTtable{1.25}
%
%
%
%
\begin{center}
\vspace{3ex}
\rule{6cm}{0.4pt}
\end{center}
\end{document}

编辑:

直到 cfr 评论后我才意识到附加的 MWE 太大了。为了尽量减少理解我的过程的努力,这里是代码片段的分步描述。

  1. 我为不同的 k 级别声明了六个计数器来计算每个级别的问题数量\newcounter{rem}
  2. 我为不同的 k 级别声明了六个变量,以计算每个级别的总分之和\edef\rem{0}
  3. 声明了一个临时变量\edef\x{0}
  4. 对于每个k级,定义三个宏\rqn\rpart和,分别\rsubpart表示questionpartsubpart
  5. 上述每个宏都执行以下操作:
    • 以题目的总分作为论据。

    • 在问题开头打印相应的k级。 \newcommand{\rqn}[1]{\question[#1]\emph{(Remembering)}

    • 将对应k级分数变量的先前值存储在临时变量中\x,将当前问题的分数添加到\x并存储到同一个k级分数变量中。\let\x\rem% \FPeval{\rem}{clip(\x+#1)}

    • 增加了相应的k级问题计数器。\refstepcounter{rem}

    • 整个宏的片段:

\newcommand{\rqn}[1]{\question[#1]\emph{(Remembering)}%
    \let\x\rem%
    \FPeval{\rem}{clip(\x+#1)}%
    \refstepcounter{rem}
}
  1. 我已经准备好了具有不同定义宏组合的整个 QP,并且在每个问题之后打印出与每个 k 级相对应的总分的当前值:R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre

  2. 最后,我打印了环境\printRBTtable的内部和外部questions

答案1

要使现有代码正常工作,您只需将\rem等的定义设为全局的。由于parts创建了一个本地组并且\FPeval只在本地更改值,因此使用时点不会累积parts。它们在组内增加,但当组结束时会重置为开始时的值。

例如,

\newcommand{\rqn}[1]{\question[#1]\emph{(Remembering)}%
  \let\x\rem
  \FPeval{\remtmp}{clip(\x+#1)}%
  \global\let\rem\remtmp
  \refstepcounter{rem}%
}

这是\rem全局变化的,因此增加的点数会保留下来\end{parts}

该问题不会影响计数器,因为 LaTeX 总是全局设置计数器。

完整代码:

\documentclass[a5paper, 11pt]{exam}
\usepackage{fp}
\usepackage{array, siunitx}
%
\newcounter{rem}
\newcounter{und}
\newcounter{app}
\newcounter{ana}
\newcounter{eva}
\newcounter{cre}
%
\newcommand\rem{0}
\newcommand\und{0}
\newcommand\app{0}
\newcommand\ana{0}
\newcommand\eva{0}
\newcommand\cre{0}
\newcommand\x{0}
\edef\rem{0}
\edef\und{0}
\edef\app{0}
\edef\ana{0}
\edef\eva{0}
\edef\cre{0}
\edef\x{0}
%
\newcommand{\rqn}[1]{\question[#1]\emph{(Remembering)}%
  \let\x\rem
  \FPeval{\remtmp}{clip(\x+#1)}%
  \global\let\rem\remtmp
  \refstepcounter{rem}%
}
\newcommand{\rpart}[1]{\part[#1]\emph{(Remembering)}%
  \let\x\rem
  \FPeval{\remtmp}{clip(\x+#1)}%
  \global\let\rem\remtmp
  \refstepcounter{rem}%
}
\newcommand{\rsubpart}[1]{\subpart[#1]\emph{(Remembering)}%
  \let\x\rem
  \FPeval{\remtmp}{clip(\x+#1)}%
  \global\let\rem\remtmp
  \refstepcounter{rem}%
}
%
\newcommand{\uqn}[1]{\question[#1]\emph{(Understanding)}%
  \let\x\und
  \FPeval{\undtmp}{clip(\x+#1)}%
  \global\let\und\undtmp
  \refstepcounter{und}%
}
\newcommand{\upart}[1]{\part[#1]\emph{(Understanding)}%
  \let\x\und
  \FPeval{\undtmp}{clip(\x+#1)}%
  \global\let\und\undtmp
  \refstepcounter{und}%
}
\newcommand{\usubpart}[1]{\subpart[#1]\emph{(Understanding)}%
  \let\x\und
  \FPeval{\undtmp}{clip(\x+#1)}%
  \global\let\und\undtmp
  \refstepcounter{und}%
}
%
\newcommand{\aqn}[1]{\question[#1]\emph{(Applying)}%
  \let\x\app
  \FPeval{\apptmp}{clip(\x+#1)}%
  \global\let\app\apptmp
  \refstepcounter{app}%
}
\newcommand{\apart}[1]{\part[#1]\emph{(Applying)}%
  \let\x\app
  \FPeval{\apptmp}{clip(\x+#1)}%
  \global\let\app\apptmp
  \refstepcounter{app}%
}
\newcommand{\asubpart}[1]{\subpart[#1]\emph{(Applying)}%
  \let\x\app
  \FPeval{\apptmp}{clip(\x+#1)}%
  \global\let\app\apptmp
  \refstepcounter{app}%
}
%
\newcommand{\bqn}[1]{\question[#1]\emph{(Analysing)}%
  \let\x\ana
  \FPeval{\anatmp}{clip(\x+#1)}%
  \global\let\ana\anatmp
  \refstepcounter{ana}%
}
\newcommand{\bpart}[1]{\part[#1]\emph{(Analysing)}%
  \let\x\ana
  \FPeval{\anatmp}{clip(\x+#1)}%
  \global\let\ana\anatmp
  \refstepcounter{ana}%
}
\newcommand{\bsubpart}[1]{\subpart[#1]\emph{(Analysing)}%
  \let\x\ana
  \FPeval{\anatmp}{clip(\x+#1)}%
  \global\let\ana\anatmp
  \refstepcounter{ana}%
}
%
\newcommand{\evqn}[1]{\question[#1]\emph{(Evaluating)}%
  \let\x\eva
  \FPeval{\evatmp}{clip(\x+#1)}%
  \global\let\eva\evatmp
  \refstepcounter{eva}%
}
\newcommand{\evpart}[1]{\part[#1]\emph{(Evaluating)}%
  \let\x\eva
  \FPeval{\evatmp}{clip(\x+#1)}%
  \global\let\eva\evatmp
  \refstepcounter{eva}%
}
\newcommand{\evsubpart}[1]{\subpart[#1]\emph{(Evaluating)}%
  \let\x\eva
  \FPeval{\evatmp}{clip(\x+#1)}%
  \global\let\eva\evatmp
  \refstepcounter{eva}%
}
%
\newcommand{\cqn}[1]{\question[#1]\emph{(Creating)}%
  \let\x\cre
  \FPeval\cretmp{clip(\x+#1)}%
  \global\let\cre\cretmp
  \refstepcounter{cre}%
}
\newcommand{\cpart}[1]{\part[#1]\emph{(Creating)}%
  \let\x\cre
  \FPeval\cretmp{clip(\x+#1)}%
  \global\let\cre\cretmp
  \refstepcounter{cre}%
}
\newcommand{\csubpart}[1]{\subpart[#1]\emph{(Creating)}%
  \let\x\cre
  \FPeval\cretmp{clip(\x+#1)}%
  \global\let\cre\cretmp
  \refstepcounter{cre}%
}
%
\newcommand{\printRBTtable}[1]{%
  \begin{center}%
    \def\arraystretch{#1}%
    \begin{tabular}{|l|S|S|}%
      \hline%
      \multicolumn{1}{|c|}{\small\textbf{Knowledge levels}}   &   \multicolumn{1}{c}{\small\textbf{Number of questions}}  &   \multicolumn{1}{|c|}{\small\textbf{Marks}}\\%
      \hline%
      Remembering &   \therem &   \rem\\%
      \hline%
      Understanding   &   \theund &   \und\\%
      \hline%
      Applying    &   \theapp &   \app\\%
      \hline%
      Analysing   &   \theana &   \ana\\%
      \hline
      Evaluating  &   \theeva &   \eva\\%
      \hline
      Creating    &   \thecre &   \cre\\%
      \hline%
      \textbf{Total}  &   \fpeval{\therem+\theund+\theapp+\theana+\theeva+\thecre}    &   \fpeval{\rem+\und+\app+\ana+\eva+\cre} \\%
      \hline
    \end{tabular}
  \end{center}
}
%
\begin{document}
%
\subsubsection*{\centering{GROUP -- A\\ \small Answer any FIVE questions.\normalsize}}\vspace{1ex}
%
\begin{questions}
%
%Qn 1
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 2
%
\evqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 3
%
\aqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 4
%
\rqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 5
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 6
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 7
%
\aqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 8
%
\rqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%
\subsubsection*{\centering{GROUP -- B\\ \small Answer any FOUR questions.\normalsize}}\vspace{1ex}
%
%
%
%Qn 9
%
\evqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 10
%
\uqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 11
%
\aqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 12
%
\bqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 13
%
\bqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 14
%
\uqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%
\subsubsection*{\centering{GROUP -- C\\ \small Answer any TWO questions.\normalsize}}\vspace{1ex}
%
%
%
%Qn 15
%
\question
\begin{parts}
%15.a
\bpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%15.b
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
%Qn 16
%
\question
\begin{parts}
%Qn 16.a
\bpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%16.b
\apart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
% Qn 17
%
\question
\begin{parts}
%17.a
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%17.b
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
%Qn 18
%
\question
\begin{parts}
%18.a
\apart{3}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%18.b
\bpart{7}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{5ex}
%
\printRBTtable{1.25}
%
%
\end{questions}

但请注意,将格式放入分段命令的参数中并不是一个好习惯。最好使用 make\subsubsection或任何其他命令来执行您想要的操作。

使用非拉伸垂直间距也会使分页效果更差。您似乎想取消所有段落分隔。我不确定为什么,但可能有一种更简单、更有效的方法。(从编码和易读性的角度来看,这种方法在这里并不完全有效,也不是特别容易。

但是,我可能会使用 LaTeX 3 中的内容来做一些事情,尤其是如果这是供其他人使用的(但即使不是),我也会避免使用命令的神秘缩写。即使你确定这些是安全的,它们也会使代码更难阅读等。无论如何,我不知道你到底在做什么,但这里有一个例子。

\documentclass[a5paper, 11pt]{exam}
\usepackage{array, siunitx}
\usepackage{booktabs}
\usepackage[T1]{fontenc}
\ExplSyntaxOn
\prop_new:N \l__subhajitpaul_qntypes_prop
\seq_new:N \l__subhajitpaul_qntypes_seq
\prop_set_from_keyval:Nn \l__subhajitpaul_qntypes_prop
{
  ana = Analysing,
  app = Applying,
  cre = Creating,
  eva = Evaluating,
  rem = Remembering,
  und = Understanding,
}
\prop_map_inline:Nn \l__subhajitpaul_qntypes_prop
{
  \int_gzero_new:c { g__subhajitpaul_#1_int }
  \int_gzero_new:c { g__subhajitpaul_#1pts_int }
  \tl_set:cn { l__subhajitpaul_#1_tl } { #2 }
  \cs_new_protected:cpn { #1 } { \int_to_arabic:v { g__subhajitpaul_#1pts_int } }
  \seq_put_right:Nn \l__subhajitpaul_qntypes_seq { #1 }
}

\NewDocumentCommand \typequestion { mm }
{
  \question[#1]\emph{ \tl_use:c { l__subhajitpaul_#2_tl } }
  \int_gincr:c { g__subhajitpaul_#2_int }
  \int_gadd:cn { g__subhajitpaul_#2pts_int } { #1 }
}
\NewDocumentCommand \typepart { mm }
{
  \part[#1]\emph{\tl_use:c { l__subhajitpaul_#2_tl }}
  \int_gincr:c { g__subhajitpaul_#2_int }
  \int_gadd:cn { g__subhajitpaul_#2pts_int } { #1 }
}
\NewDocumentCommand \typesubpart { mm }
{
  \subpart[#1]\emph{ \tl_use:c { l__subhajitpaul_#2_tl } }
  \int_gincr:c { g__subhajitpaul_#2_int }
  \int_gadd:cn { g__subhajitpaul_#2pts_int } { #1 }
}

\NewDocumentCommand \printRBTtable { O {1} }
{
  \begin{center}%
    \def\arraystretch{#1}%
    \begin{tabular}{lSS}
      \toprule
      \multicolumn{1}{c}{\small\textbf{Knowledge ~ levels}}   &   \multicolumn{1}{c}{\small\textbf{Number ~ of ~ questions}}  &   \multicolumn{1}{c}{\small\textbf{Marks}}\\
      \midrule
      \l__subhajitpaul_rem_tl &   \int_to_arabic:n { \g__subhajitpaul_rem_int } &   \int_to_arabic:n { \g__subhajitpaul_rempts_int } \\
      \l__subhajitpaul_und_tl   &   \int_to_arabic:n { \g__subhajitpaul_und_int } &   \int_to_arabic:n { \g__subhajitpaul_undpts_int } \\
      \l__subhajitpaul_app_tl    &   \int_to_arabic:n { \g__subhajitpaul_app_int } &   \int_to_arabic:n { \g__subhajitpaul_apppts_int } \\
      \l__subhajitpaul_ana_tl   &   \int_to_arabic:n { \g__subhajitpaul_ana_int } &   \int_to_arabic:n { \g__subhajitpaul_anapts_int } \\
      \l__subhajitpaul_eva_tl  &   \int_to_arabic:n { \g__subhajitpaul_eva_int } &   \int_to_arabic:n { \g__subhajitpaul_evapts_int } \\
      \l__subhajitpaul_cre_tl    &   \int_to_arabic:n { \g__subhajitpaul_cre_int } &   \int_to_arabic:n { \g__subhajitpaul_crepts_int } \\
      \cmidrule(lr){1-3}
      \textbf{Total}  &   \int_to_arabic:n { \g__subhajitpaul_rem_int + \g__subhajitpaul_und_int + \g__subhajitpaul_app_int + \g__subhajitpaul_ana_int + \g__subhajitpaul_eva_int + \g__subhajitpaul_cre_int }    & \int_to_arabic:n{ \g__subhajitpaul_rempts_int + \g__subhajitpaul_undpts_int + \g__subhajitpaul_apppts_int + \g__subhajitpaul_anapts_int + \g__subhajitpaul_evapts_int + \g__subhajitpaul_crepts_int } \\
      \bottomrule
    \end{tabular}
  \end{center}
}
\NewDocumentCommand \printQnData {}
{
  \seq_clear:N \l_tmpa_seq
  \seq_map_inline:Nn \l__subhajitpaul_qntypes_seq
  {
    \seq_put_right:Ne \l_tmpa_seq
    {
      \text_titlecase_first:n { ##1 } : ~ \int_to_arabic:v { g__subhajitpaul_##1pts_int } \textbar \int_to_arabic:v { g__subhajitpaul_##1_int }
    }
  }
  {\scriptsize \seq_use:Nn \l_tmpa_seq { , ~ } }
}
\ExplSyntaxOff
\begin{document}

\subsubsection*{\centering{GROUP -- A\\ \small Answer any FIVE questions.\normalsize}}\vspace{1ex}

\begin{questions}
%Qn 1
\typequestion{2}{und}\droppoints
\printQnData

%Qn 2
\typequestion{2}{eva}\droppoints
\printQnData

%Qn 3
\typequestion{2}{app}\droppoints
\printQnData

%Qn 4
\typequestion{2}{rem}\droppoints
\printQnData

%Qn 5
\typequestion{2}{und}\droppoints
\printQnData

%Qn 6
\typequestion{2}{und}\droppoints
\printQnData

%Qn 7
\typequestion{2}{app}\droppoints
\printQnData

%Qn 8
\typequestion{2}{rem}\droppoints
\printQnData

\subsubsection*{\centering{GROUP -- B\\ \small Answer any FOUR questions.\normalsize}}\vspace{1ex}

%Qn 9
\typequestion{5}{eva}\droppoints
\printQnData

%Qn 10
\typequestion{5}{und}\droppoints
\printQnData

%Qn 11
\typequestion{5}{app}\droppoints
\printQnData

%Qn 12
\typequestion{5}{ana}\droppoints
\printQnData

%Qn 13
\typequestion{5}{ana}\droppoints
\printQnData

%Qn 14
\typequestion{5}{und}\droppoints
\printQnData

\subsubsection*{\centering{GROUP -- C\\ \small Answer any TWO questions.\normalsize}}\vspace{1ex}

%Qn 15
\question
\begin{parts}
  %15.a
  \typepart{5}{ana}\droppoints
  \printQnData
  %15.b
  \typepart{5}{eva}\droppoints
  \printQnData
\end{parts}

%Qn 16
\question
\begin{parts}
  %Qn 16.a
  \typepart{5}{ana}\droppoints
  \printQnData
  %16.b
  \typepart{5}{app}\droppoints
  \printQnData
\end{parts}

% Qn 17
\question
\begin{parts}
  %17.a
  \typepart{5}{eva}\droppoints
  \printQnData
  %17.b
  \typepart{5}{eva}\droppoints
  \printQnData
\end{parts}

%Qn 18
\question
\begin{parts}
  %18.a
  \typepart{3}{app}\droppoints
  \printQnData
  %18.b
  \typepart{7}{ana}\droppoints
  \printQnData
\end{parts}

\printRBTtable[1.25]

\end{questions}

\printRBTtable
\end{document}

我不会发布输出,因为由于 Okular 错误,我的图像现在很糟糕,而且实际上,在这种情况下结果并不那么有趣。

相关内容