# Exam doc. class: how to number solutions?

I'm trying to produce an answer key for an exam. What I'd like to do is to produce a list of only the answers. (Technically I'm planning on putting a grading checklist into the solutions - I want to see as many questions' checklists on one page as possible while grading)

I was hoping to use \ifprintanswers but when I use \thequestion in the \solutiontitle it always shows up as zero.

Also, when I use this approach (which is based on the endnotes approach I found on StackExchange) I need to first compile the document (using XeLaTeX) WITHOUT \printanswers, then go back and run it a second time with \printanswers turned on. If I don't it complains about a missing .ent file, which I assume is where the endnotes are being stored.

I was hoping there's some way to capture the value of \thequestion when I run it without the \printanswersso that it'll still be there on the second run.

MWE:

\documentclass[addpoints, 12pt]{exam}

%TODO: Turn this on/off based on need for answer key
\unframedsolutions
% This will number the answers
% from https://tex.stackexchange.com/questions/284672/numbering-solutions-in-exam-environment#comment686934_284672
\renewcommand{\solutiontitle}{\noindent\textbf{Solution \thequestion:}}

% this exists to collect up the solutions/answers in one place:
% from https://tex.stackexchange.com/a/237849/131222
\usepackage{endnotes}

\def\enotesize{\normalsize}
\def\makeenmark{\relax}

\begin{document}

\newpage
\else % prints out the exam itself

\begin{questions}

\qformat{\large \textbf{Question:} \thequestion: \thequestiontitle\hfill(\thepoints)}

\titledquestion{Syntax and Semantics}[30]

\titledquestion{Second Question}[30]

\titledquestion{Third Question}[30]
\end{questions}
\fi

\end{document}


If you examine the .ent file, you will see that none of the macros inside the \endnotetext are expanded. This means that in the second run you have a bunch of solutions with no questions. At the least, you need to increment the question counter.

\documentclass[addpoints, 12pt]{exam}

%TODO: Turn this on/off based on need for answer key
\unframedsolutions
% This will number the answers
% from https://tex.stackexchange.com/questions/284672/numbering-solutions-in-exam-environment#comment686934_284672
\renewcommand{\solutiontitle}{\noindent\textbf{Solution \thequestion:~}}

% this exists to collect up the solutions/answers in one place:
% from https://tex.stackexchange.com/a/237849/131222
\usepackage{endnotes}

\def\enotesize{\normalsize}
\def\makeenmark{\relax}

\begin{document}

\newpage
\else % prints out the exam itself

\begin{questions}

\qformat{\large \textbf{Question \thequestion:} \thequestiontitle\hfill(\thepoints)}

\titledquestion{Syntax and Semantics}[30]