Been racking my brain on this problem, not sure what I'm doing wrong. This code is highly based off of this solution but something isnt clicking. The goal is to be able to reference the contents of the solution environment later in my code.
Here is what im working with:
\documentclass[addpoints,12pt]{exam}
\usepackage{environ}
\makeatletter
\NewEnviron{sol}{
\begin{solution}
\def\@currentlabel{\BODY}\label{solt:\thequestion}
\BODY
\end{solution}
}
\makeatother
\begin{document}
\begin{questions}
\question This is a question
\begin{sol}
My solution
\end{sol}
\begin{choices}
\choice 8
\choice 1
\choice 3
\choice 4
\end{choices}
\end{questions}
The first solution is:\\
\ref{solt:1}
\end{document}
When I run this, I receive an invalid reference. Any pointers as to what i may be doing incorrectly?