Edit
With version 0.19 (2015/07/04) the hack isn't necessary anymore. The following preamble to the code below suffices:
\documentclass{article}
\usepackage[auto-label]{exsheets}[2015/07/04]
\DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
} ,
title-post-code = \bfseries\space
to question \GetQuestionProperty{ref}{\CurrentQuestionID}
}
\usepackage{hyperref}
\begin{document}
Original answer
The problem your having is (I guess) that when the solutions are printed \CurrentQuestionID
doesn't hold the corresponding ID but in fact expands to an empty token list. This is probably a missing feature or even some kind of bug since arguably \CurrentQuestionID
should work in for the solutions as well...
Here is a suggestion which will probably find its way into exsheets
in the next few days:
\documentclass{article}
\usepackage[auto-label]{exsheets}
\DeclareInstance{exsheets-heading}{myblock}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
} ,
title-post-code = \bfseries\space
to question \GetQuestionProperty{ref}{\CurrentQuestionID}
}
\ExplSyntaxOn
\cs_set_protected:Npn \__exsheets_print_solution:nnnn #1#2#3#4
{
\tl_set:Nn \CurrentQuestionID {#3} % <<< this is needed
\tl_use:N \l__exsheets_solutions_pre_hook_tl
\exsheets_solutions_print_name:nnn {#1} {#2} {#3}
\tl_use:N \l__exsheets_solutions_pre_body_hook_tl
\use:n {#4}
\tl_use:N \l__exsheets_solutions_post_body_hook_tl
\tl_use:N \l__exsheets_solutions_post_hook_tl
\exsheets_h_or_vspace:N \l__exsheets_solutions_skip_below_dim
}
\ExplSyntaxOff
\usepackage{hyperref}
\begin{document}
\section{Problems}
\begin{question}
foo bar baz
\end{question}
\begin{solution}
blah blah
\end{solution}
\begin{question}
foo bar baz
\end{question}
\begin{solution}
blah blah
\end{solution}
\section{Answers}
\SetupExSheets{headings=myblock}
\printsolutions
\end{document}
