4

exam package enables the possibility to use and define \half as to for instance consider .5. However I have not seen any way of implementing .75 and .25 in case I want a part or question to have that value.

Is it possible? In case yes can you give me an example and how I can have the correct sum of points per question?

Edit: MWE included

\documentclass[11pt, addpoints, twoside, a4paper]{exam}

\begin{document}

\begin{questions}

\renewcommand*\half{.5}
\question[0\half]
This question is 0.5 points

\renewcommand*\half{.25}
\question[1\half]
This question is 1.25 points

\renewcommand*\half{.5}
\question[1\half]
This question is 1.5 points

\end{questions}

Total points with addpoints: \numpoints~(3.5)

Total points real count: 3.25

I don't know how to define quarters, etc. so I can easily define the points in my questions without having to renew \texttt{half} command, and also having the final sum properly done.

\end{document}
  • 1
    The idea of an MWE for such a question is that you provide a full document that contains your use case except the feature that you want, in this case a short sample exam with 1 point per question for example. – Marijn May 30 '18 at 19:24
3

The exam class implements points as counters, which have integer values by definition. A possible solution could be to provide the points as integer values and divide them only in the output, e.g., assign 125 points to a question and print that as 1.25.

Division is (relatively) easy using FPdiv from the fp package. Rounding to two decimal places can be done using the numprint package. The exam class can be modified using patchcmd from the etoolbox package.

The main issue is to identify all instances of the code in the exam class responsible for printing the points. The class code is very readable and contains instructive comments, but it is quite long (over 8000 lines).

The MWE below contains a partial solution with a few modifications to the class code. However, for most use cases some additional patches will need to be applied.

Code:

\documentclass[addpoints]{exam}
\usepackage{fp}
\usepackage{numprint}
\npdecimalsign{.}
\nprounddigits{2}
\usepackage{etoolbox}
\makeatletter
% points printed at each question
\patchcmd{\point@block}{\@points}{\FPdiv\pointdiv{\@points}{100}\numprint{\pointdiv}}{}{}
% points printed for each question in grade table
\patchcmd{\do@oneline@v}{\pointsof@index{pq@index}}{\FPdiv\pointsdiv{\pointsof@index{pq@index}}{100}\numprint{\pointsdiv}}{}{}
% total number of points in grade table
\patchcmd{\prt@tablepoints}{\prt@hlfcntr{tbl@points}}{\FPdiv\pointsdiv{\prt@hlfcntr{tbl@points}}{100}\numprint{\pointsdiv}}{}{}
% patching needed in many other places
\makeatother
\begin{document}

\begin{questions}
\question[50]
Why is there air?
\question[125]
How much wood would a woodchuck chuck if a woodchuck could chuck
wood?
\question[150] Compute $\displaystyle\int_0^1 x^2 \, dx$.
\end{questions}
\gradetable
\end{document}

Result:

enter image description here

|improve this answer|||||
  • I stand corrected. :) At least on the 'substantially' part. – Alan Munn May 30 '18 at 22:19
  • @AlanMunn I think you were quite right that implementing this functionality will require a lot of effort, there are dozens of places in the class where points are displayed. So in the end it is probably good advice not to try it at all... – Marijn May 30 '18 at 22:30
  • @Marijn thanks a lot. I understand what you do and I think it's a good idea which solves my question. Just a comment, would it work with parts and subparts or do I have to add other pathcmd? The other solution could be to define new commands that generate the division and store in another variable. Then use the new variable – jlanza May 31 '18 at 8:26
  • 2
    @jlanza you probably need to add other patchcmds (note: 'patch', not 'path'). The points, totals, subtotals, bonus points etc. are stored in many different variables/commands throughout the class. You can try to explore the code, it is relatively easy to understand compared to many other classes. However, you could just use integers and grade up to 100 points, then your problem is instantly solved :) – Marijn May 31 '18 at 9:18
0

Disclaimer: This is a workaround, rather than a full solution, but maybe it's still useful for someone.

You could just manually multiply all your points by 4 like this:

0.25 pt → 1 pt
0.5 pt  → 2 pt
0.75 pt → 3 pt
1 pt    → 4 pt
1.25 pt → 5 pt
etc.

That way, you only have integer points in your exam and your fractional point problem is gone. And you still have the same granularity of points available when grading. Just remember that one of these new points is effectively a quarter of a point. Don't subdivide it further, or you will have the same problem again. ;-)

Of course it only works if you have full control over the number of points available in your exam and are not limited by external factors.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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