# Exsheets: improve subquestions scores features using tasks

I have a question that is composed by several subquestions (which is done using tasks). I also want to have a table at the end where I have the score for each question. The questions are as follows:

(1) As you can in the MWE, in the final table only appears the score for questions and not subquestions, is there a way to make all them appear?

(2) Also I need to manually sum the values of subquestions and put it in the questions environment (otherwise it would not appear and be summed in the final table), is there a way to grab the score for each subquestion making it appear in the main question?

(3) I am using marginnote to put the score as a side note; and I not very happy with that, is there any exsheets mechanism to do it better (e.g., like the headings for questions)?

% arara: pdflatex
% arara: pdflatex
% arara: clean: { files: [ main.aux, main.log, main.out ] }
% arara: preview

\documentclass[10pt,a4paper]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{lmodern}
\usepackage[pass,showframe]{geometry}

\usepackage{array}

\usepackage{blindtext}

\SetupExSheets{%
solution/print=true,
}

\usepackage{marginnote}

\begin{document}

\begin{question}{3.5}

\blindtext

\blindtext

\blindtext

\blindtext

\end{question}

\null\vspace*{\fill}
\begin{center}
\begin{tabular}{|l| *{\numberofquestions}{c|} c|}\hline
Question & \ForEachQuestion{\QuestionNumber{#1}\iflastquestion{}{&}} & Total \\\hline
Points & \ForEachQuestion{\GetQuestionProperty{points}{#1}\iflastquestion{}{&}} & \pointssum* \\\hline
Notes & \ForEachQuestion{\iflastquestion{}{&}} & \\\hline
\end{tabular}
\end{center}
\end{document}


There is no automatic solution. You can however define a question property subpoints and with a suitable definition of a command \subpoints and a suitable built of the grade table we can get maybe something usable. The code below gives the following grade table:

Questions are entered similar to

\begin{question}
\end{question}


Here's the full code:

\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[pass,showframe]{geometry}
\usepackage{array}
\usepackage{marginnote}
\usepackage{blindtext}

\SetupExSheets{
solution/print = true,
}
% this requires version 0.9 of tasks.sty:
counter-format = qu.tsk ,
label-width    = 2em
}

\usepackage{etoolbox,expl3,xparse}
\DeclareQuestionProperty{subpoints}
\makeatletter
\ExplSyntaxOn
\fp_new:N \g_cacamailg_subpoints_fp
\seq_new:N \g_cacamailg_tmpa_seq

% the following assumes you're always going to use a {tasks}
% environment for the subquestions
\cs_new_protected:Npn \cacamailg_subpoints:n #1
{
% \@cntfmts@parsed@pattern holds the current {tasks} label:
\seq_gput_right:Nx \g_cacamailg_tmpa_seq
{ \@cntfmts@parsed@pattern & #1 }
% and the total sum of points:
\marginnote { \addpoints { #1 } }
\ignorespaces
}
\NewDocumentCommand \subpoints { m }
{ \cacamailg_subpoints:n { #1 } }

\cs_generate_variant:Nn \exsheets_set_question_properties:n { x }

% at the end of a {question}:
\AtEndEnvironment{question}
{
% are subpoints given?
\fp_compare:nNnT { \g_cacamailg_subpoints_fp } > { 0 }
{
% then build a table of the subpoints to be used in the grade table
\exsheets_set_question_properties:x
{
subpoints =
{
\exp_not:N \begin{tabular}[t]{ll}
\seq_use:Nnnn \g_cacamailg_tmpa_seq {\\} {\\} {\\}
\exp_not:N \end{tabular}
}
}
% clear question specific variables:
\seq_gclear:N \g_cacamailg_tmpa_seq
\fp_gzero:N \g_cacamailg_subpoints_fp
}
}
\ExplSyntaxOff
\makeatother

\begin{document}

\begin{question}
\end{question}

\begin{question}{2}
\blindtext
\end{question}

\begin{question}
\end{question}

\null\vspace*{\fill}

\begin{center}
\begin{tabular}{|l|l|l|l|}\hline
Question & \multicolumn{2}{c|}{ Points } & Notes \\ \hline
\ForEachQuestion{
\QuestionNumber{#1} &
\GetQuestionProperty{points}{#1} &
\GetQuestionProperty{subpoints}{#1} & \\ \hline
}
Total  & \multicolumn{2}{l|}{\pointssum* } &\\\hline
\end{tabular}
\end{center}

\end{document}

• I tested you code and I am very happy with it. However, I think for students it is useful to know the score of a question as a whole even when using tasks and subpoints. As such, I am wondering if it is possible to have that, e.g., in the 1st question of your code without summing it to the total? I am thinking of something like \currentpointssum* to sum the inner subpoints of a question specific question (it would be expanded only after the question is finished) and not added to the total pointssum*. – cacamailg Jun 12 '13 at 12:42
• @cacamailg If you use \points instead of \addpoints in the definition of \subpoints the points will not be added, neither to the current question nor to the total sum. It's not clear to me if that is what you want, though.... – clemens Jun 12 '13 at 13:18
• I wanted to be able to specify \begin{question}{<value>} where the <value> is the sum of the scores of subquestions inside that question. Also that <value> would be calculated automatically and not added to pointssum* (because it is already done by the subquestions). – cacamailg Jun 12 '13 at 15:01
• @cacamailg \begin{question}{<value>} always adds to the total sum. If you want to specify that \subpoints should not add the points but only print them which is exactly what I suggested in my other comment – clemens Jun 12 '13 at 15:26
• I understand that. I think I was not clear. Now I just wanted a <macro> to automatically calculate <value> which is the sum of \subpoints so that I could write \begin{question}{<macro>} and that would be translated in \begin{question}{<value>}. – cacamailg Jun 12 '13 at 16:57