A few months ago egreg gave a wonderful answer to a question I had about a modified gradetable using the exam document class. More recently, after loading the hyperref package, I realized the hyperlinking to a question's location from the modified table was not preserved.
Perhaps it's easy for a more experienced user to tell why this is the case, but egreg's code is quite beyond me. I'm wondering whether or not there's a way to modify the following code to preserve hyperlinking of questions:
\documentclass[10pt,addpoints]{exam}
\usepackage{xparse,tabularx,refcount,etoolbox}
\usepackage{hyperref}
\usepackage{lipsum}
\newcounter{grading}
\BeforeBeginEnvironment{questions}{%
\stepcounter{grading}%
\gradingtable
}
\AfterEndEnvironment{questions}{%
\addtocounter{question}{-1}%
\refstepcounter{question}%
\label{grading\thegrading @label}%
}
\ExplSyntaxOn
\tl_new:N \l__farlow_grading_tl
\NewDocumentCommand{\gradingtable}{}
{
\tl_clear:N \l__farlow_grading_tl
\int_step_inline:nnnn { 1 } { 1 } { \getrefnumber{grading\thegrading @label} }
{
\tl_put_right:Nn \l__farlow_grading_tl
{
##1 \vphantom{$\bigg|$} & & & \\ \hline
}
}
\par\noindent
\begin{tabularx}{\textwidth}
{
| c |
>{\hsize=0.5\hsize} X |
>{\hsize=0.5\hsize} X |
>{\hsize=2.0\hsize} X |
}
\hline
Problem &
\multicolumn{1}{c|}{Understood} &
\multicolumn{1}{c|}{Confused} &
\multicolumn{1}{c|}{Note} \\ \hline
\tl_use:N \l__farlow_grading_tl
\end{tabularx}
}
\ExplSyntaxOff
\begin{document}
\begin{questions}
\fullwidth{\lipsum[1-2]}
\question First question.
\question Second question.
\end{questions}
\end{document}
This produces the following:
In the code above, I only notably modified egreg's original code by loading the hyperref package as well as got rid of two question environments. With what I have in mind, I only need one questions environment, but it would be ideal if the question numbers in the table hyperlinked to the appropriate numbered question in the document.
Is there a relatively easy way to modify egreg's code to accomplish this or is it largely a lost cause?
