# Horizontal line from end of quesiton sentence to right margin in exam.cls

I need to draw a line from the end of a sentence in a question to the right margin. In exam class, I can do this with \hrulefill if I don't use \droppoints, but as soon as I do, the line is no longer to the right margin.

First question works without \droppoints, second question cuts line short.

\question[2]
This is a question to answer here:\hrulefill

\question[2]
This is another question:\hrulefill \droppoints


The reason for this is because \droppoints also inserts a rubber length - \hfill - to stretch to the right side of the page. The length is shared between the two components, \hfill and \hrulefill.

You can either force a new paragraph and then jump back to insert the \droppoints, or create a new macro (say) \droppointshere that doesn't insert the \hfill:

\documentclass{exam}

\makeatletter
\def\droppointshere{%
% \leavevmode\unskip\nobreak\hfill% <----- removed
\rlap{\hskip\rightmargin  % Defined by the list environment
\hskip\@rightmargin % Defined by exam.cls
\hskip-\rightpointsmargin
}% rlap
\par
}
\makeatother

\begin{document}

\begin{questions}
\question[2]
This is a question to answer here: \hrulefill

\question[2]
This is another question: \hrulefill \droppoints

\question[2]
This is another question: \hrulefill \par
\vspace{\dimexpr-\parskip-\baselineskip}\droppoints

\question[2]
This is a final question: \hrulefill \droppointshere
\end{questions}

\end{document}