Exsheets:使用任务改进子问题分数特征

Exsheets:使用任务改进子问题分数特征

我有一个由几个子问题组成的问题(使用 完成tasks)。我还想在最后有一个表格,其中有每个问题的分数。问题如下:

(1) 正如您在 MWE 中看到的,最终表格中只显示问题的分数而不显示子问题的分数,有没有办法让所有分数都出现?

(2)此外,我还需要手动将子问题的值相加并将其放入问题环境中(否则它不会出现并在最终表中相加),有没有办法抓取每个子问题的分数并使其出现在主问题中?

(3) 我习惯marginnote将分数作为侧注;但我对此不太满意,是否有任何exsheets机制可以做得更好(例如,像问题的标题)?

% 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}

\usepackage[load-headings]{exsheets}
\SetupExSheets{%
    solution/print=true,
    headings=block-wp,
}

\settasks{label=qu.tsk}

\usepackage{marginnote}

\begin{document}

\begin{question}{3.5}

\begin{tasks}
\task \marginnote{\points{1}}%
\blindtext

\task \marginnote{\points{0.5}}%
\blindtext

\task \marginnote{\points{1}}%
\blindtext

\task \marginnote{\points{1}}%
\blindtext
\end{tasks}

\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}

答案1

没有自动解决方案。但是,您可以定义问题属性subpoints,并通过适当定义命令\subpoints和适当构建成绩表,我们可以得到一些有用的东西。以下代码给出了以下成绩表:

在此处输入图片描述

输入的问题类似于

\begin{question}
  \begin{tasks}
    \task \subpoints{1} \blindtext
    \task \subpoints{0.5} \blindtext
    \task \subpoints{1} \blindtext
    \task \subpoints{1} \blindtext
\end{tasks}
\end{question}

完整代码如下:

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

\usepackage[load-headings]{exsheets}
\SetupExSheets{
  solution/print = true,
  headings       = block-wp,
}
% this requires version 0.9 of tasks.sty:
\settasks{
  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
  {
    \fp_gadd:Nn \g_cacamailg_subpoints_fp { #1 }
    % \@cntfmts@parsed@pattern holds the current {tasks} label:
    \seq_gput_right:Nx \g_cacamailg_tmpa_seq
      { \@cntfmts@parsed@pattern & #1 }
    % \addpoints adds the points to the current question points
    % 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}
  \begin{tasks}
    \task \subpoints{1} \blindtext
    \task \subpoints{0.5} \blindtext
    \task \subpoints{1} \blindtext
    \task \subpoints{1} \blindtext
\end{tasks}
\end{question}

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

\begin{question}
  \begin{tasks}
    \task \subpoints{0.75} \blindtext
    \task \subpoints{0.75} \blindtext
    \task \subpoints{1.5} \blindtext
\end{tasks}
\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}

相关内容