# Points printed right after part question in exam class

I'm using the exam class (exam.cls) to make an exam. I'm trying to get the points printed right after the part question. Anyone an idea how to achieve this?

\documentclass[11pt]{exam}
\begin{document}
\begin{questions}
\begin{parts}
\part[2] Are we happy?
\end{parts}
\end{questions}
\end{document}


Gives:

Where I want it to appears as follows (although without the vertical spacing):

From this nice answer with some modifying.

\documentclass[a4paper,addpoints]{exam}

\makeatletter
\@qformatfalse
\def\droppointsatend{%
\def\level@of@question{question}%
\leavevmode\unskip\nobreak%
\ifx\level@of@question\@queslevel%
\dotfill(\mbox{\totalpoints\ \points})%
\else%
\fi%
\par
}
\makeatother

\begin{document}
\pointsdroppedatright
\begin{questions}
\begin{parts}
\part[2] Are we happy? \droppointsatend
\end{parts}

\begin{parts}
\part[2] Are we happy? \droppointsatend
\end{parts}
\end{questions}

\noindent Total to earn: \numpoints\ \points

\end{document}


You can try the following code. This should give the desired result:

\documentclass[11pt]{exam}
\begin{document}
\begin{questions}