# Customized bonus questions in exam class

I'm using the exam class (with the addpoints option) to create assignments, and I want to create some bonus questions. I have a customized question format that looks like this:

\qformat{Question \thequestion: [\totalpoints]}


which works fine for regular questions.

However, the \totalpoints command doesn't return a value for bonus questions, and so those questions are incorrectly marked as having 0 points.

I hacked this by redefining \qformat (before the bonus questions) to be

\qformat{Question \thequestion: [\totalbonuspoints]}


which works fine. But I'd rather have a single designation that works for all question (bonus or not). How might I do that ?

note: I could have used \thepoints in the definition, but some of my questions have parts, and so \totalpoints is needed to add up the points.

-

Looking at the source of exam.cls there is a if@bonus that you can use to test if you are typesetting a bonus or a regular question. Hacking a bit you can do something like

\makeatletter
\newcommand\thetotalpoints{%
\if@bonus
[\totalbonuspoints\ bonus points]
\else
[\totalpoints\ points]
\fi
}
\makeatother

\qformat{Question \thequestion: \thetotalpoints \hfill}

-
oh that is neat. worked like a charm. Thanks ! –  Suresh Sep 3 '10 at 5:24

The betatest version of exam.cls creates the command \bonusqformat that does for bonus questions what the command \qformat does for regular questions. You can get a copy of version 2.318beta of exam.cls from this web page. Using that version of exam.cls, you can say

\qformat{Question \thequestion: [\totalpoints]\hfill}
\bonusqformat{Question \thequestion: [\totalbonuspoints]\hfill}


or

\qformat{Question \thequestion:\dotfill [\totalpoints]}
\bonusqformat{Bonus Question \thequestion:\dotfill [\totalbonuspoints]}


or whatever other variant you like.

-