上一个答案:

上一个答案:

Exercisebank 在 0.2.0 版本中没有内置处理积分的方法。如何将积分系统添加到部分问题中exercisebank例如,在练习文件中,我想做

\begin{problem}
  \addpoints{2}
  problem description
\end{problem}

现在它应该显示在部分问题标题中。例如(1c) 2p:

我还想要一个可以在最后使用的命令来显示累计积分。例如

\totalpoints

答案1

在这里工作得很好。我稍微修改了代码,这样你就可以在右侧使用像 xsim 中一样的小规则来获得点Needs \usepackage{marginnote}

代码改变的部分如下:

.....
\def\ppheader{%
    \leavevmode%
    \smash{%
        \llap{%
            {\large\textbf{\theproblemcounter\alph{partproblemcounter})}}%
            % if \currentPoints contains 0, \currentPoints aren't printed.
            %\ifnum\currentPoints=\z@\else\currentPoints p\fi~}}\ignorespaces%
            \ifnum\currentPoints=\z@\else\marginnote{\rule{1cm}{.5pt}~/\currentPoints P.}
            \fi}}\ignorespaces%
}
....

唯一的问题是,\totalpoints最后必须运行。我的考试通常以标题页开始,显示总分(\totalpoints)。但这在这里不起作用。

答案2

编辑:积分系统现已实施exercisebank

在你的锻炼文件中说testexercise.tex

\begin{problem}
    \nextproblem{points=2}
    Problem containing \makeatletter\exb@currentPoints\makeatother~points
\end{problem}
\begin{problem}
    \addpoints{points=1}
    Problem containing \makeatletter\exb@currentPoints\makeatother~points
\end{problem}
\begin{problem}
    \ppheader
    Problem containing no points
\end{problem}

您可以访问宏中的总点数\totalpoints


上一个答案:

这是即将推出的功能,但我不知道具体什么时候能实现。在这里,我将介绍一种解决方法,如果你使用例如\select\exclude。下面我将说明如何实现该功能:

此代码为点创建一个计数器和一个占位符:

main.tex

\documentclass{article}
\usepackage{exercisebank}
\usepackage{filecontents}
\makeatletter
% Make a counter for accumulating points
\newcounter{problempoints}
% For readability, defining
\let\totalpoints\theproblempoints
% \currentPoints is a placeholder for
% the number of points the current part problem has
\gdef\currentPoints{0}
% Disable the default part problem header made by exercisebank
\exercisebanksetup{part problem header={\relax}}
% Make a new command to insert part problem header
% (inspired by the default found on page 10 in the manual):
\def\ppheader{%
  \leavevmode%
  \smash{%
    \llap{%
      {\large\textbf{(\theproblemcounter\alph{partproblemcounter})}}%
      % if \currentPoints contains 0, \currentPoints aren't printed.
      \ifnum\currentPoints=\z@\else\currentPoints p\fi~}}\ignorespaces%
}
% Reset \currentPoints, so that if no points are set in the next, nothing would be added
\At\EndPartproblem{\gdef\currentPoints{0}}
% Make a new command that sets the current points and increases the total-counter
\newcommand\addpoints[1]{%
  \gdef\currentPoints{#1}%
  \addtocounter{problempoints}{#1}%
  \ppheader
}
\makeset{test}{testexercise}
\makeatother
\begin{document}
  \buildset{test}
\end{document}

现在testexercise.tex

\begin{problem}
    \addpoints{2}
    Problem containing \currentPoints~points
\end{problem}
\begin{problem}
    \addpoints{1}
    Problem containing \currentPoints~points
\end{problem}
\begin{problem}
    \ppheader
    Problem containing no points
\end{problem}

这将产生


这是一个问答问题。我在 github 和电子邮件上收到过多次关于此问题的询问,所以我决定在这里做一个问答。

相关内容