在考试类别中添加不同问题的标记

在考试类别中添加不同问题的标记

我使用考试类别生成了以下文档。我想将问题 2、3 和 4 的分数相加,并将总分写在第二部分标题的旁边。我知道如何获得所有问题的总分,但不知道特定部分内问题的总分。 在此处输入图片描述

答案1

嗯,你不能直接计算每个部分的分数,只能计算每页的分数。所以我用了一个计数器,并将问题分数添加到该计数器中。有三点:你不能使用一半的分数,你必须在每次提问后更新计数器,并且你必须在排版下一节之前重置计数器。

\documentclass[a4paper,addpoints]{exam}

\renewcommand{\thepartno}{\alph{partno}}
\renewcommand{\partlabel}{(\thepartno)}

\marksnotpoints

\pointsinrightmargin

\newcounter{sectionpoints}\setcounter{sectionpoints}{0}

%% This will remove the points being typeset after the question number and part letter.
%% Use \droppointsatend to typeset points at the end of the current line.
%% If \droppointsatend is called at the question level, the points will
%% be prepended with a \dotfill, otherwise the points will be prepended
%% with a \hfill.
\makeatletter
\@qformatfalse
\def\droppointsatend{%
  \def\level@of@question{question}%
  \leavevmode\unskip\nobreak%
  \ifx\level@of@question\@queslevel%
    \dotfill(\mbox{\totalpoints\ \points})%
  \else%
    \hfill\mbox{[\@points]}%
  \fi%
  \par
%% Make sure we drop the points at the right
\pointsdroppedatright
}

%% Get the total points from the current question as an integer
\def\valuepointsofquestion{\@ifundefined{pointsofq@\romannumeral \arabic{question}}%
  {0}%
  {\csname pointsofq@\romannumeral \arabic{question}\endcsname}%
}%
\makeatother

\begin{document}

\begin{questions}

\uplevel{\textbf{Section I}}
\question Some text \droppointsatend
This question is worth \totalpoints\ \points

\begin{parts}
\part[5] Some text \droppointsatend 
\part[5] Some text \droppoints % \droppointsatend
\part[5] Some text \droppoints % \droppointsatend
\part[5] Some text \droppoints % \droppointsatend
\end{parts}

\addtocounter{sectionpoints}{\valuepointsofquestion}

\question[10] Compute $\displaystyle \int_0^1 \!x^2\,\mathrm{d}x $ \droppointsatend
This question is worth \totalpoints\ \points

\addtocounter{sectionpoints}{\valuepointsofquestion}

\uplevel{The total \points\ for this section is \thesectionpoints.}

\uplevel{\textbf{Section II}}
\setcounter{sectionpoints}{0}

\question[15] Compute $\displaystyle \int_0^\infty\!\mathrm{e}^{-x^2}\,\mathrm{d}x$ \droppointsatend
\addtocounter{sectionpoints}{\valuepointsofquestion}

\question Some text \droppointsatend
\addtocounter{sectionpoints}{\valuepointsofquestion}

\begin{parts}
\part[5] Some text \droppoints % \droppointsatend 
\part[5] Some text \droppoints % \droppointsatend
\part[5] Some text \droppoints % \droppointsatend
\part[5] Some text \droppoints % \droppointsatend
\end{parts}

\uplevel{The total \points\ for this section is \thesectionpoints.}

\end{questions}

\bigskip
\noindent Total to earn: \numpoints\ \points

\end{document}

代码截图

相关内容