Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

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}
share|improve this answer
    
oh that is neat. worked like a charm. Thanks ! –  Suresh Sep 3 '10 at 5:24
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.