summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/README4
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/cntformats_en.pdfbin416521 -> 416305 bytes
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/exsheets_en.pdfbin670403 -> 675963 bytes
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/exsheets_en.tex110
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/grading-table.pdfbin26483 -> 26474 bytes
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/tasks_en.pdfbin445066 -> 444774 bytes
-rw-r--r--Master/texmf-dist/tex/latex/exsheets/exsheets.sty306
7 files changed, 279 insertions, 141 deletions
diff --git a/Master/texmf-dist/doc/latex/exsheets/README b/Master/texmf-dist/doc/latex/exsheets/README
index 319d5e15641..b1408ac5818 100644
--- a/Master/texmf-dist/doc/latex/exsheets/README
+++ b/Master/texmf-dist/doc/latex/exsheets/README
@@ -1,7 +1,7 @@
--------------------------------------------------------------------------
-EXSHEETS 2014/05/11
+EXSHEETS 2014/06/27
bundled packages:
-the EXSHEETS package v0.13
+the EXSHEETS package v0.14
Yet another package for the creation of exercise sheets
the EXSHEETS-LISTINGS package v0.2
Using listings in exsheets
diff --git a/Master/texmf-dist/doc/latex/exsheets/cntformats_en.pdf b/Master/texmf-dist/doc/latex/exsheets/cntformats_en.pdf
index 5ce72181de8..8cf3a16ec5d 100644
--- a/Master/texmf-dist/doc/latex/exsheets/cntformats_en.pdf
+++ b/Master/texmf-dist/doc/latex/exsheets/cntformats_en.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/exsheets/exsheets_en.pdf b/Master/texmf-dist/doc/latex/exsheets/exsheets_en.pdf
index 59593bf3880..191ab5488e5 100644
--- a/Master/texmf-dist/doc/latex/exsheets/exsheets_en.pdf
+++ b/Master/texmf-dist/doc/latex/exsheets/exsheets_en.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/exsheets/exsheets_en.tex b/Master/texmf-dist/doc/latex/exsheets/exsheets_en.tex
index ea18bc5f1a2..a96d6c2584c 100644
--- a/Master/texmf-dist/doc/latex/exsheets/exsheets_en.tex
+++ b/Master/texmf-dist/doc/latex/exsheets/exsheets_en.tex
@@ -249,9 +249,9 @@
\license
\ExSheets\ loads and needs the following packages:
-\needpackage{l3kernel}~\cite{pkg:l3kernel}, \pkg{xparse}, \pkg{xtemplate},
-\pkg{l3keys2e}\footnote{all three \CTANurl{l3packages}}~\cite{pkg:l3packages},
-\pkg{l3sort}\footnote{\CTANurl{l3experimental}}~\cite{pkg:l3experimental},
+\needpackage{l3kernel}~\cite{bnd:l3kernel}, \pkg{xparse}, \pkg{xtemplate},
+\pkg{l3keys2e}\footnote{all three \CTANurl{l3packages}}~\cite{bnd:l3packages},
+\pkg{l3sort}\footnote{\CTANurl{l3experimental}}~\cite{bnd:l3experimental},
\needpackage{xcolor}~\cite{pkg:xcolor}, \needpackage{ulem}~\cite{pkg:ulem},
\needpackage{etoolbox}~\cite{pkg:etoolbox},
\needpackage{environ}~\cite{pkg:environ}, and
@@ -261,7 +261,7 @@ calls \cs*{normalem} (from the \pkg{ulem} package).
\section{Motivation}
There are already quite a number of packages that allow the creation of
exercise sheets or written exams. Just to name the most common ones:
-\pkg{eqexam}~\cite{pkg:eqexam}, \pkg{exam}~\cite{pkg:exam},
+\pkg{eqexam}~\cite{pkg:eqexam}, \pkg{exam}~\cite{cls:exam},
\pkg{examdesign}~\cite{pkg:examdesign}, \pkg{exercise}~\cite{pkg:exercise},
\pkg{probsoln}~\cite{pkg:probsoln}, \pkg{answers}~\cite{pkg:answers},
\pkg{esami}~\cite{pkg:esami}, \pkg{exsol}~\cite{pkg:exsol} (and many
@@ -316,9 +316,9 @@ documentation. These packages provide functionality that is used by
The package \cntformats\ is probably not really useful on a user-level but
maybe for package writers.
-\changedversion{0.9i}\ExSheets\ used to bundle the \pkg{translations}
-package, too, but doesn't any more. You can find the \pkg{translations}
-package as a package of it's own on the \ac{ctan}.
+\ExSheets\ used to bundle the \pkg{translations} package,
+too\changedversion{0.9i}, but doesn't any more. You can find the
+\pkg{translations} package as a package of it's own on the \ac{ctan}.
\section{Installation and Documentation}
If you install \ExSheets\ manually beware to put the files
@@ -421,6 +421,23 @@ New options:
section~\ref{sec:solutions-print-all}.
\end{itemize}
+\subsection{Version 0.14}
+New options:
+\begin{itemize}
+ \item New option \option{pre-hook} to the \env{question} environment that
+ allows to add code directly before the question body, see
+ section~\ref{sec:opti-ques-envir}.
+ \item New option \option{post-hook} to the \env{question} environment that
+ allows to add code directly after the question body, see
+ section~\ref{sec:opti-ques-envir}.
+ \item New command \cs{ExSheetsHeading}.
+ \item New pre-defined question properties \code{question-body},
+ \code{bonus-points} and \code{counter}, see section
+ \ref{sec:additional_info}.
+ \item New option \option{save-to-aux}, see section
+ \ref{sec:additional_info}.
+\end{itemize}
+
\section{Thanks}
I need to thank the many users who gave me feedback so far! For one thing
this shows me that \ExSheets\ is useful to people. It also led to many
@@ -636,6 +653,10 @@ The \env{question} environment takes one or more of the following options:
section~\ref{sec:topics} for further information.
\keybool{use}\Module{question}\Default{true}
Discards the question. Or not.
+ \keyval{pre-hook}{code}\Module{question}\Default
+ \sinceversion{0.14}Adds \meta{code} directly before the question body.
+ \keyval{pre-hook}{code}\Module{question}\Default
+ \sinceversion{0.14}Adds \meta{code} directly after the question body.
\end{options}
\begin{example}
@@ -1243,7 +1264,10 @@ say. This is possible with the following commands:
\bool_set_false:N \g__exsheets_use_difficulties_bool
\ExplSyntaxOff
-\section{Adding and Using Additional Information to Questions}\label{sec:additional_info}
+\section{Adding and Using Additional Information to
+ Questions}\label{sec:additional_info}
+\subsection{Question Properties -- the Basics}
+
For managing lots of questions and corresponding solutions it can be very
useful to be able to save and recover additional information to the questions.
This is possible with the following commands. First the ones for saving:
@@ -1264,7 +1288,7 @@ Now the commands for recovering the properties:
\expandable\command{GetQuestionProperty}[\marg{name}\marg{id}]
Recover the property \meta{name} of the question with the \acs{id}
\meta{id}. Of course the property must have been declared before. The
- command is expandable. Since\sinceversion{0.12} the properties of a
+ command is expandable. Since\changedversion{0.12} the properties of a
question are written to the \code{aux} file it is possible to retrieve
them before the corresponding \env{question} environment has been used.
\end{commands}
@@ -1327,30 +1351,65 @@ It is now possible to recover these values later:
\end{center}
\end{example}
-\sinceversion{0.7a}If you use the package option \option{auto-label} the
-properties \code{ref} and \code{pageref} are predefined which will call the
-corresponding \cs*{ref} or \cs*{pageref}, respectively. Also see
-section~\ref{sec:auto-label-opti}.
+Please note that properties \emph{are not the same} as the dividing concepts
+explained in section~\ref{sec:dividing-concepts} although they may seem
+similar in meaning or even have the same name.
+
+When properties are set they are also written to the \code{aux} file which
+means they can be retrieved \emph{before} the corresponding question. Of
+course this means that two compilation runs are necessary.
+
+\subsection{Pre-defined Properties}
+
+A few properties are already defined by \ExSheets:
+\begin{itemize}
+ \item \code{counter}:\sinceversion{0.14} this property holds the actual
+ question number formatted according to the formatting set with option
+ \option{counter-format}.
+ \item \code{subtitle}:\sinceversion{0.12} this property holds the subtitle
+ of the question if given.
+ \item \code{question-body}:\sinceversion{0.14} this property holds the body
+ of the corresponding \env{question} environment. Unlike the other
+ properties it is per default \emph{not} written to the \code{aux} file.
+ \item \code{points}: this property holds the sum of points given to a
+ question.
+ \item \code{bonus-points}:\sinceversion{0.14} this property holds the sum of
+ bonus points given to a question.
+ \item \code{ref}:\sinceversion{0.7f} when the option \option{auto-label} is
+ used this property is defined and expands to the corresponding \cs*{ref}.
+ Also see section~\ref{sec:auto-label-opti}.
+ \item \code{page-ref}:\sinceversion{0.7f} when the option
+ \option{auto-label} is used this property is defined and expands to the
+ corresponding \cs*{pageref}. Also see section~\ref{sec:auto-label-opti}.
+\end{itemize}
+
+There is one option affecting the property \code{question-body}:
+\begin{options}
+ \keybool{save-to-aux}\Module{question}\Default{false}
+ When set to \code{true} the property \code{question-body} is also written
+ to the \code{aux} file.
+\end{options}
-Please note that these properties \emph{are not the same} as the dividing
-concepts explained in section~\ref{sec:dividing-concepts} although they may
-seem similar in meaning or even have the same name.
+\subsection{Advanced Usage}
-\sinceversion{0.3}There are additional commands that might prove useful:
+There are additional commands\sinceversion{0.3} that might prove useful. They
+allow advanced usage of defined properties. Below an example is shown how
+they can be used to generate a grading table.
\begin{commands}
\command{ForEachQuestion}[\marg{code to be executed for each used question}]
- Inside the argument one can refer to the \ac{id} of a question with
- \code{\#1}. Beware that this command only knows of questions used before
- it is issued.
+ \changedversion{0.14}Inside the argument one can refer to the \ac{id} of a
+ question with \code{\#1}. You can also refer to the number of the
+ question with \code{\#2}. \emph{Number} means that if you \emph{use}
+ seven questions then those questions have numbers~1 to~7.
\expandable\command{numberofquestions}
- Returns the current number of used questions. Beware that this command
- only knows of questions used before it is issued.
+ \changedversion{0.14} returns the complete number of used questions.
\expandable\command{iflastquestion}[\marg{true code}\marg{false code}]
Although this command is available in the whole document it is only useful
inside \cs{ForEachQuestion}. It tells you if the end of the loop is
reached or not.
\end{commands}
-For example one could use these commands to create a grading table:
+
+One could use these commands to create a grading table, for instance:
\begin{sourcecode}
\begin{tabular}{|l|*{\numberofquestions}{c|}c|}\hline
Question &
@@ -1380,8 +1439,9 @@ figure~\ref{fig:grading-table}.
\section{Variations of an Exam}
-\noindent\sinceversion{0.6}It is a quite common task to design an exam in two
-different variants. This is of course possible with \ExSheets' classes (see
+
+It is a quite common task\sinceversion{0.6} to design an exam in two different
+variants. This is of course possible with \ExSheets' classes (see
section~\ref{sec:classes}). However, often not the whole question is to be
different but only small details, the numbers in a maths exam, say. For this
purpose \ExSheets\ provides the following commands:
diff --git a/Master/texmf-dist/doc/latex/exsheets/grading-table.pdf b/Master/texmf-dist/doc/latex/exsheets/grading-table.pdf
index ad2da7f271e..248ccb5dba7 100644
--- a/Master/texmf-dist/doc/latex/exsheets/grading-table.pdf
+++ b/Master/texmf-dist/doc/latex/exsheets/grading-table.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/exsheets/tasks_en.pdf b/Master/texmf-dist/doc/latex/exsheets/tasks_en.pdf
index e70bac5f399..671ff5e4f3b 100644
--- a/Master/texmf-dist/doc/latex/exsheets/tasks_en.pdf
+++ b/Master/texmf-dist/doc/latex/exsheets/tasks_en.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
index 6b3ebe04da2..f6425d9bb7d 100644
--- a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
+++ b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
@@ -25,8 +25,8 @@
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% ----------------------------------------------------------------------------
-\def\exsheets@date{2014/05/11}
-\def\exsheets@version{0.13}
+\def\exsheets@date{2014/06/28}
+\def\exsheets@version{0.14}
\RequirePackage { expl3 , xparse }
\ProvidesExplPackage
@@ -51,14 +51,13 @@
% ----------------------------------------------------------------------------
% variants of kernel functions:
-\cs_generate_variant:Nn \prop_get:NnN { Nx }
-\cs_generate_variant:Nn \prop_get:NnN { cf }
+\cs_generate_variant:Nn \prop_get:NnN { Nx , cf }
\cs_generate_variant:Nn \prop_get:NnNTF { Nx }
-\cs_generate_variant:Nn \prop_gput:Nnn { Nf , Nff , Nfx }
-\cs_generate_variant:Nn \prop_gput:Nnn { Nx , Nxx }
-\cs_generate_variant:Nn \prop_gput:Nnn { cf , cff }
+\cs_generate_variant:Nn \prop_gput:Nnn { Nf , Nff , Nfx , Nx , Nxx , NxV , cf , cff }
+\cs_generate_variant:Nn \prop_gput_if_new:Nnn { Nxx }
\cs_generate_variant:Nn \tl_if_blank:nTF { x }
-\cs_generate_variant:Nn \tl_if_eq:nnF { x }
+\cs_generate_variant:Nn \tl_if_eq:nnF { x }
+\cs_generate_variant:Nn \int_to_arabic:n { V }
% ----------------------------------------------------------------------------
% temporary variables
@@ -182,7 +181,9 @@
\exp_not:N \providecommand \exp_not:N \exsheets@question@property[3]{} ^^J
\exp_not:N \providecommand \exp_not:N \exsheets@save@number[2]{} ^^J
\exp_not:N \providecommand \exp_not:N \exsheets@sum@of@points[1]{} ^^J
- \exp_not:N \providecommand \exp_not:N \exsheets@sum@of@bonus[1]{}
+ \exp_not:N \providecommand \exp_not:N \exsheets@sum@of@bonus[1]{} ^^J
+ % \exp_not:N \providecommand \exp_not:N \exsheets@number@of@questions[1]{} ^^J
+ % \exp_not:N \providecommand \exp_not:N \numberofquestions{}
}
}
@@ -233,6 +234,8 @@
\tl_set:Nn \l__exsheets_questions_toclevel_tl { subsection }
\tl_new:N \l__exsheets_solutions_toclevel_tl
\tl_set:Nn \l__exsheets_solutions_toclevel_tl { subsection }
+\tl_new:N \l__exsheets_solutions_pre_hook_tl
+\tl_new:N \l__exsheets_solutions_post_hook_tl
\AtBeginDocument{
\cs_if_exist:NF \phantomsection
@@ -804,6 +807,8 @@
\bool_new:N \l__exsheets_questions_use_bool
\bool_set_true:N \l__exsheets_questions_use_bool
\bool_new:N \l__exsheets_questions_deactivate_bool
+\bool_new:N \l__exsheets_save_question_body_to_aux_bool
+\bool_set_false:N \l__exsheets_save_question_body_to_aux_bool
\bool_new:N \l__exsheets_solutions_use_bool
\bool_set_true:N \l__exsheets_solutions_use_bool
@@ -967,6 +972,9 @@
\tl_new:N \l__exsheets_exercise_name_tl
\tl_set:Nn \l__exsheets_exercise_name_tl { Exercise }
+\tl_new:N \l__exsheets_questions_pre_hook_tl
+\tl_new:N \l__exsheets_questions_post_hook_tl
+
\tl_new:N \CurrentQuestionID
\bool_new:N \l__exsheets_questions_print_bool
@@ -985,18 +993,19 @@
\cs_new_eq:NN \exsheets_par: \par
-\NewEnviron { __exsheets_questions_internal: }
+\cs_new:Npn \exsheets_h_or_vspace:N #1
{
- \csappto { BODY }
+ \cs_if_eq:NNTF \exsheets_par: \scan_stop:
+ { \c_space_tl }% the `runin' case
{
- \cs_if_eq:NNTF \exsheets_par: \scan_stop:
- { \c_space_tl }
- {
- \exsheets_par:
- \dim_compare:nNnT { \parskip } = { 0pt }
- { \exsheets_glue:N \l__exsheets_questions_skip_below_dim }
- }
+ \exsheets_par:
+ \dim_compare:nNnT { \parskip } = { 0pt }
+ { \exsheets_glue:N #1 }
}
+ }
+
+\NewEnviron { __exsheets_questions_internal: }
+ {
\bool_if:nT
{
\l__exsheets_questions_print_bool &&
@@ -1004,11 +1013,52 @@
!\l__exsheets_questions_deactivate_bool
}
{
+ % label:
+ \tl_if_blank:VTF \l__exsheets_questions_label_tl
+ {
+ \bool_if:NT \l__exsheets_auto_label_bool
+ {
+ \exsheets_label:V \g__exsheets_questions_current_id_tl
+ \exsheets_set_ref_properties:V \CurrentQuestionID
+ }
+ }
+ {
+ \exsheets_label:V \l__exsheets_questions_label_tl
+ \exsheets_set_ref_properties:V \l__exsheets_questions_label_tl
+ }
\__exsheets_save_number_in:N \g__exsheets_question_number_prop
- \BODY
+ \tl_use:N \l__exsheets_questions_pre_hook_tl
+ \__exsheets_save_and_print_question_body:V \BODY
+ \tl_use:N \l__exsheets_questions_post_hook_tl
+ \exsheets_h_or_vspace:N \l__exsheets_questions_skip_below_dim
+ \exsheets_set_question_properties:x
+ {
+ \tl_if_blank:VF \l__exsheets_questions_subtitle_tl
+ { subtitle = { \exp_not:V \l__exsheets_questions_subtitle_tl } , }
+ counter = \l__exsheets_qu_counter_interpretation_tl ,
+ % number = \int_to_arabic:V \g__exsheets_questions_id_int ,
+ \bool_if:NF \l__exsheets_points_questions_default_bool
+ {
+ \fp_compare:nT { \g__exsheets_this_question_points_fp > 0 }
+ { points = \fp_to_tl:N \g__exsheets_this_question_points_fp , }
+ \fp_compare:nT { \g__exsheets_this_question_bonus_fp > 0 }
+ { bonus-points = \fp_to_tl:N \g__exsheets_this_question_bonus_fp }
+ }
+ }
}
}
+\cs_new:Npn \__exsheets_save_and_print_question_body:n #1
+ {
+ \group_begin:
+ \bool_if:NF \l__exsheets_save_question_body_to_aux_bool
+ { \@fileswfalse }
+ \exsheets_set_question_properties:n { question-body = {#1} }
+ \group_end:
+ #1
+ }
+\cs_generate_variant:Nn \__exsheets_save_and_print_question_body:n { V }
+
\prop_new:N \g__exsheets_questions_id_prop
\prop_new:N \g__exsheets_questions_subtitle_prop
\prop_new:N \g__exsheets_questions_used_prop
@@ -1144,16 +1194,6 @@
{
\tl_gset:Nx \g__exsheets_questions_current_id_tl
{ \tl_use:N \l__exsheets_questions_id_tl }
- }
- \tl_if_blank:VF \l__exsheets_questions_subtitle_tl
- {
- \exsheets_set_question_properties:x
- { subtitle = { \exp_not:V \l__exsheets_questions_subtitle_tl } }
- % this is used in the headings instance; could maybe be replaced
- % by retrieving the property...
- % \prop_gput:NVV \g__exsheets_questions_subtitle_prop
- % \g__exsheets_questions_current_id_tl
- % \l__exsheets_questions_subtitle_tl
}
}
\bool_if:nT
@@ -1164,11 +1204,16 @@
{
\bool_if:NT \l__exsheets_questions_use_bool
{
- \prop_gput:NVV \g__exsheets_questions_used_prop
- \g__exsheets_questions_current_id_tl
- \g__exsheets_questions_id_int
+ % TODO: write this to the aux file and at this point check if the
+ % entry is already present
+ % \prop_gput:NVV \g__exsheets_questions_used_prop
+ % \g__exsheets_questions_current_id_tl
+ % \g__exsheets_questions_id_int
\int_gincr:N \g__exsheets_questions_used_int
- }
+ \__exsheets_mark_as_used_x:nn
+ { \int_use:N \g__exsheets_questions_used_int }
+ { \tl_use:N \g__exsheets_questions_current_id_tl }
+ }
\prop_gput:NVV \g__exsheets_questions_id_prop
\g__exsheets_questions_current_id_tl
\g__exsheets_questions_id_int
@@ -1193,6 +1238,9 @@
\fp_gset_eq:NN
\g__exsheets_this_question_points_fp
\l__exsheets_question_points_fp
+ \fp_gset_eq:NN
+ \g__exsheets_this_question_bonus_fp
+ \l__exsheets_question_bonus_fp
\__exsheets_read_points:n { #2 }
% check if moving this to a later point has negative effects...
% \exsheets_set_question_properties:n { points = #2 }
@@ -1235,19 +1283,6 @@
% erhöhe jetzt, wenn kein Nein dabei war:
\tl_if_in:NnF \l__exsheets_step_counter_tl { n }
{ \refstepcounter{question} }
- % label:
- \tl_if_blank:VTF \l__exsheets_questions_label_tl
- {
- \bool_if:NT \l__exsheets_auto_label_bool
- {
- \exsheets_label:V \g__exsheets_questions_current_id_tl
- \exsheets_set_ref_properties:V \g__exsheets_questions_current_id_tl
- }
- }
- {
- \exsheets_label:V \l__exsheets_questions_label_tl
- \exsheets_set_ref_properties:V \l__exsheets_questions_label_tl
- }
\__exsheets_get_sectioning_numbers:
\bool_if:nT
{
@@ -1291,7 +1326,7 @@
\bool_if:nTF
{ \l__exsheets_parse_points_bool && !\l__exsheets_only_print_points_bool }
{
- \__exsheets_use_heading:VVVVnV
+ \exsheets_use_heading:VVVVnV
\l__exsheets_question_heading_instance_tl
\l__exsheets_questions_title_tl
\l__exsheets_qu_counter_interpretation_tl
@@ -1305,7 +1340,7 @@
% might be dangerous to expand here...
\tl_if_blank:xTF { \l__exsheets_questions_points_tl }
{
- \__exsheets_use_heading:VVVnnV
+ \exsheets_use_heading:VVVnnV
\l__exsheets_question_heading_instance_tl
\l__exsheets_questions_title_tl
\l__exsheets_qu_counter_interpretation_tl
@@ -1314,7 +1349,7 @@
\l__exsheets_tmpa_tl
}
{
- \__exsheets_use_heading:VVVVnV
+ \exsheets_use_heading:VVVVnV
\l__exsheets_question_heading_instance_tl
\l__exsheets_questions_title_tl
\l__exsheets_qu_counter_interpretation_tl
@@ -1329,14 +1364,6 @@
}
{
\end__exsheets_questions_internal:
- \bool_if:NF \l__exsheets_points_questions_default_bool
- {
- \fp_compare:nT { \g__exsheets_this_question_points_fp > 0 }
- {
- \exsheets_set_question_properties:x
- { points = \fp_to_tl:N \g__exsheets_this_question_points_fp }
- }
- }
}
% current question number:
@@ -1406,7 +1433,7 @@
{ \textbf{??} }
}
-\cs_new:Npn \__exsheets_question_number:N #1
+\cs_new_protected:Npn \__exsheets_question_number:N #1
{
\cs_if_exist:NTF #1
{
@@ -1425,6 +1452,17 @@
\int_set:Nn \l__exsheets_counter_qu_int { #3 }
}
+% map ID's to number of used questions
+\cs_new_protected:Npn \exsheets@used@id #1#2
+ { \prop_gput:Nnn \g__exsheets_questions_used_prop {#2} {#1} }
+
+\cs_new_protected:Npn \__exsheets_mark_as_used_x:nn #1#2
+ {
+ \prop_gput_if_new:Nxx \g__exsheets_questions_used_prop {#2} {#1}
+ \exsheets_write_to_aux_x:n
+ { \exsheets@used@id {#1} {#2} }
+ }
+
% ----------------------------------------------------------------------------
% title of a question:
\input { exsheets_headings.def }
@@ -1436,7 +1474,7 @@
% #4: points
% #5: bonus
% #6: id
-\cs_new_nopar:Npn \__exsheets_use_heading:nnnnnn #1#2#3#4#5#6
+\cs_new:Npn \exsheets_use_heading:nnnnnn #1#2#3#4#5#6
{
\IfInstanceExistTF { exsheets-heading } { #1 }
{ \UseInstance { exsheets-heading } { #1 } }
@@ -1446,7 +1484,10 @@
}
{ #2 } { #3 } { #4 } { #5 } { #6 }
}
-\cs_generate_variant:Nn \__exsheets_use_heading:nnnnnn { V , VVVnnV , VVVVnV }
+\cs_generate_variant:Nn \exsheets_use_heading:nnnnnn { V , VVVnnV , VVVVnV }
+
+\NewDocumentCommand \ExSheetsHeading { mmmmmm }
+ { \exsheets_use_heading:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6} }
\bool_new:N \l__exsheets_exam_bool
\bool_set_false:N \l__exsheets_exam_bool
@@ -1478,7 +1519,10 @@
\bool_gset_false:N \g__exsheets_questions_use_bool
\bool_set_false:N \l__exsheets_questions_use_bool ,
use .default:n = true ,
- skip-below .dim_set:N = \l__exsheets_questions_skip_below_dim
+ skip-below .dim_set:N = \l__exsheets_questions_skip_below_dim ,
+ pre-hook .tl_set:N = \l__exsheets_questions_pre_hook_tl ,
+ post-hook .tl_set:N = \l__exsheets_questions_post_hook_tl ,
+ save-to-aux .bool_set:N = \l__exsheets_save_question_body_to_aux_bool
}
% ----------------------------------------------------------------------------
@@ -1524,12 +1568,12 @@
\cs_new_protected:Npn \__exsheets_question_set_property:nn #1#2
{
\prop_gput:cVn { g__exsheets_question_property_#1_prop }
- \g__exsheets_questions_current_id_tl { #2 }
+ \CurrentQuestionID { #2 }
% watch if this has negativ effects:
\exsheets_write_to_aux_x:n
{
\exp_not:N \exsheets@question@property
- { \g__exsheets_questions_current_id_tl }
+ { \CurrentQuestionID }
{ \exp_not:n {#1} }
{ \exp_not:n {#2} }
}
@@ -1549,6 +1593,12 @@
\cs_generate_variant:Nn \exsheets_get_question_property:nn { no }
\int_new:N \g__exsheets_tmpa_int
+% \cs_new_protected:Npn \ForEachQuestion #1
+% {
+% \int_gzero:N \g__exsheets_tmpa_int
+% \int_step_inline:nnnn {1} {1} {\numberofquestions}
+% { \int_gincr:N \g__exsheets_tmpa_int #1 }
+% }
\cs_new_protected:Npn \ForEachQuestion #1
{
\int_gzero:N \g__exsheets_tmpa_int
@@ -1559,11 +1609,14 @@
\cs_new:Npn \iflastquestion
{
\int_compare:nTF
- { \g__exsheets_questions_used_int = \g__exsheets_tmpa_int }
+ { \numberofquestions = \g__exsheets_tmpa_int }
+ }
+
+\cs_if_exist:NF \numberofquestions
+ {
+ \cs_new:Npn \numberofquestions
+ { \int_to_arabic:V \g__exsheets_questions_used_int }
}
-
-\cs_new:Npn \numberofquestions
- { \int_use:N \g__exsheets_questions_used_int }
% ----------------------------------------------------------------------------
% debug-Info:
@@ -1793,10 +1846,13 @@
{
\bool_gset_true:N \g__exsheets_questions_use_bool
\clist_gput_right:Nn \questionsincludedlast { #1 }
- \prop_gput:NnV \g__exsheets_questions_used_prop
- { #1 }
- \g__exsheets_questions_id_int
\int_gincr:N \g__exsheets_questions_used_int
+ \__exsheets_mark_as_used_x:nn
+ { \int_use:N \g__exsheets_questions_used_int }
+ { #1 }
+ % \prop_gput:NnV \g__exsheets_questions_used_prop
+ % { #1 }
+ % \g__exsheets_questions_id_int
\prop_gput:NnV \g__exsheets_questions_id_prop
{ #1 }
\g__exsheets_questions_id_int
@@ -1814,10 +1870,13 @@
{
\bool_gset_true:N \g__exsheets_questions_use_bool
\clist_gput_right:Nn \questionsincludedlast { #1 }
- \prop_gput:NnV \g__exsheets_questions_used_prop
- { #1 }
- \g__exsheets_questions_id_int
+ % \prop_gput:NnV \g__exsheets_questions_used_prop
+ % { #1 }
+ % \g__exsheets_questions_id_int
\int_gincr:N \g__exsheets_questions_used_int
+ \__exsheets_mark_as_used_x:nn
+ { \int_use:N \g__exsheets_questions_used_int }
+ { #1 }
\prop_gput:NnV \g__exsheets_questions_id_prop
{ #1 }
\g__exsheets_questions_id_int
@@ -1955,6 +2014,7 @@
\prop_new:N \g__exsheets_solutions_content_prop
\prop_new:N \g__exsheets_solutions_questions_id_prop
\prop_new:N \g__exsheets_solutions_names_prop
+\prop_new:N \g__exsheets_solutions_counter_prop
\tl_new:N \l__exsheets_solutions_name_tl
\tl_set:Nn \l__exsheets_solutions_name_tl { Solution }
@@ -1965,15 +2025,18 @@
\bool_if:NTF \l__exsheets_include_all_bool
{ \int_set:Nn \l__exsheets_tmpe_int { \g__exsheets_questions_id_int -1 } }
{ \int_set_eq:NN \l__exsheets_tmpe_int \g__exsheets_questions_id_int }
- \prop_gput:Nff \g__exsheets_solutions_content_prop
+ \prop_gput:Nxn \g__exsheets_solutions_content_prop
{ \int_use:N \g__exsheets_questions_id_int }
{ #1 }
- \prop_gput:Nff \g__exsheets_solutions_questions_id_prop
+ \prop_gput:NxV \g__exsheets_solutions_questions_id_prop
+ { \int_use:N \g__exsheets_questions_id_int }
+ \g__exsheets_questions_current_id_tl
+ \prop_gput:NxV \g__exsheets_solutions_names_prop
{ \int_use:N \g__exsheets_questions_id_int }
- { \tl_use:N \g__exsheets_questions_current_id_tl }
- \prop_gput:Nff \g__exsheets_solutions_names_prop
+ \l__exsheets_solutions_name_tl
+ \prop_gput:NxV \g__exsheets_solutions_counter_prop
{ \int_use:N \g__exsheets_questions_id_int }
- { \tl_use:N \l__exsheets_solutions_name_tl }
+ \l__exsheets_qu_counter_pattern_tl
% print here
\bool_if:NT \l__exsheets_solutions_print_here_bool
{
@@ -1984,19 +2047,15 @@
\l__exsheets_solutions_name_tl
\g__exsheets_questions_current_id_tl
\use:n { #1 }
- \cs_if_eq:NNTF \exsheets_par: \scan_stop:
- { \c_space_tl }
- {
- \exsheets_par:
- \dim_compare:nNnT { \parskip } = { 0pt }
- { \exsheets_glue:N \l__exsheets_solutions_skip_below_dim }
- }
+ \exsheets_h_or_vspace:N \l__exsheets_solutions_skip_below_dim
}
}
\cs_generate_variant:Nn \__exsheets_save_solution:n { V }
\NewEnviron { __exsheets_solution_internal: }
{
+ % \exp_args:NNV \cspreto \BODY \l__exsheets_solutions_pre_hook_tl
+ % \exp_args:NNV \csappto \BODY \l__exsheets_solutions_post_hook_tl
\bool_if:nT
{ \g__exsheets_questions_use_bool && \l__exsheets_solutions_use_bool }
{ \__exsheets_save_solution:V \BODY }
@@ -2035,6 +2094,7 @@
{
\bool_set_true:N \l__exsheets_inside_solution_bool
\IfNoValueF { #1 } { \keys_set:nn { exsheets / solution } { #1 } }
+ % \tl_use:N \l__exsheets_solutions_pre_hook_tl
}
\tl_if_blank:VT \l__exsheets_solution_heading_instance_tl
{
@@ -2044,7 +2104,11 @@
}
\__exsheets_solution_internal:
}
- { \end__exsheets_solution_internal: }
+ {
+ \end__exsheets_solution_internal:
+ % \bool_if:NT \l__exsheets_solutions_use_bool
+ % { \tl_use:N \l__exsheets_solutions_post_hook_tl }
+ }
\bool_new:N \l__exsheets_solutions_runin_bool
\bool_set_false:N \l__exsheets_solutions_runin_bool
@@ -2057,7 +2121,7 @@
\l__exsheets_solution_heading_instance_tl
\l__exsheets_heading_instance_tl
}
- \__exsheets_use_heading:Vnnnnn
+ \exsheets_use_heading:Vnnnnn
\l__exsheets_solution_heading_instance_tl
{ #2 } { #1 } { 0 } { 0 } { #3 }
}
@@ -2174,22 +2238,18 @@
{ #1 } \l__exsheets_tmpb_tl
\prop_get:NnN \g__exsheets_solutions_questions_id_prop
{ #1 } \l__exsheets_tmpc_tl
+ \prop_get:NnN \g__exsheets_solutions_counter_prop
+ { #1 } \l__exsheets_tmpd_tl
\eSaveCounterPatternFrom [ exsheets ]
\l__exsheets_current_pattern_interpretation_tl
\l__exsheets_current_pattern_tl
- \l__exsheets_qu_counter_pattern_tl
+ \l__exsheets_tmpd_tl
\exsheets_solutions_print_name:VVV
\l__exsheets_current_pattern_tl
\l__exsheets_tmpa_tl
\l__exsheets_tmpc_tl
\tl_use:N \l__exsheets_tmpb_tl
- \cs_if_eq:NNTF \exsheets_par: \scan_stop:
- { \c_space_tl }
- {
- \exsheets_par:
- \dim_compare:nNnT { \parskip } = { 0pt }
- { \exsheets_glue:N \l__exsheets_solutions_skip_below_dim }
- }
+ \exsheets_h_or_vspace:N \l__exsheets_solutions_skip_below_dim
}
}
@@ -2350,6 +2410,8 @@
{ #1 } \l__exsheets_tmpb_tl
\prop_get:NnN \g__exsheets_solutions_questions_id_prop
{ #1 } \l__exsheets_tmpc_tl
+ \prop_get:NnN \g__exsheets_solutions_counter_prop
+ { #1 } \l__exsheets_tmpd_tl
\group_begin:
\tl_set_eq:NN \CurrentQuestionID \l__exsheets_tmpc_tl
\__exsheets_sectioning_hook:nV { ch }
@@ -2360,19 +2422,13 @@
\eSaveCounterPatternFrom [ exsheets ]
\l__exsheets_current_pattern_interpretation_tl
\l__exsheets_current_pattern_tl
- \l__exsheets_qu_counter_pattern_tl
+ \l__exsheets_tmpd_tl
\exsheets_solutions_print_name:VVV
\l__exsheets_current_pattern_tl
\l__exsheets_tmpa_tl
\l__exsheets_tmpc_tl
\tl_use:N \l__exsheets_tmpb_tl
- \cs_if_eq:NNTF \exsheets_par: \scan_stop:
- { \c_space_tl }
- {
- \exsheets_par:
- \dim_compare:nNnT { \parskip } = { 0pt }
- { \exsheets_glue:N \l__exsheets_solutions_skip_below_dim }
- }
+ \exsheets_h_or_vspace:N \l__exsheets_solutions_skip_below_dim
}
}
@@ -2422,13 +2478,7 @@
\l__exsheets_tmpa_tl
\l__exsheets_tmpc_tl
\tl_use:N \l__exsheets_tmpb_tl
- \cs_if_eq:NNTF \exsheets_par: \scan_stop:
- { \c_space_tl }
- {
- \exsheets_par:
- \dim_compare:nNnT { \parskip } = { 0pt }
- { \exsheets_glue:N \l__exsheets_solutions_skip_below_dim }
- }
+ \exsheets_h_or_vspace:N \l__exsheets_solutions_skip_below_dim
}
}
}
@@ -2490,7 +2540,9 @@
print .default:n = true ,
name .tl_set:N = \l__exsheets_solutions_name_tl ,
sorted .bool_set:N = \l__exsheets_print_byID_sorted_bool ,
- skip-below .dim_set:N = \l__exsheets_solutions_skip_below_dim
+ skip-below .dim_set:N = \l__exsheets_solutions_skip_below_dim ,
+ % pre-hook .tl_set:N = \l__exsheets_solutions_pre_hook_tl ,
+ % post-hook .tl_set:N = \l__exsheets_solutions_post_hook_tl
}
% ----------------------------------------------------------------------------
@@ -2705,8 +2757,12 @@
\NewQuSolPair{question}{solution}
% properties:
-\DeclareQuestionProperty{points}
+% \DeclareQuestionProperty{number}
+\DeclareQuestionProperty{counter}
\DeclareQuestionProperty{subtitle}
+\DeclareQuestionProperty{question-body}
+\DeclareQuestionProperty{points}
+\DeclareQuestionProperty{bonus-points}
\bool_if:NT \l__exsheets_auto_label_bool
{
\DeclareQuestionProperty{ref}
@@ -2786,7 +2842,11 @@
\exp_not:N \exsheets@sum@of@points
{ \fp_eval:n { \g__exsheets_points_sum_fp } }^^J
\exp_not:N \exsheets@sum@of@bonus
- { \fp_eval:n { \g__exsheets_bonus_sum_fp } }
+ { \fp_eval:n { \g__exsheets_bonus_sum_fp } }^^J
+ \exp_not:N \gdef \exp_not:N \numberofquestions
+ { \int_use:N \g__exsheets_questions_used_int }
+ % \exsheets@number@of@questions
+ % { \int_to_arabic:V \g__exsheets_questions_id_int }
}
}
@@ -2978,10 +3038,27 @@ HISTORY:
of solutions (when printed with \printsolutions[all])
when solutions from a new section or chapter are
printed
+2014/05/11 v0.13a - bug fix: solutions get the counter-format that's
+ active when the corresponding `solution' environment
+ is placed in the source
+2014/06/27 v0.14 - new command: \ExSheetsHeading
+ - \__exsheets_use_heading:nnnnnn =>
+ \exsheets_use_heading:nnnnnn
+ - new options `question/pre-hook' and
+ `question/post-hook'
+ % `solution/pre-hook' and
+ % `solution/post-hook'
+ - new pre-defined property `question-body'
+ - new pre-defined property `bonus-points'
+ - new pre-defined property `counter'
+ - new option `question/save-to-aux'
+ - \ForEachQuestion, \numberofquestions and
+ \iflastquestion are now available before any
+ questions have been typeset
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TODO:
-- add a `tags' concept
+- add a `tags' concept => major task
- add user interface that removes \par and vertical skip after
question/solution environments.
(equal to \cs_set_eq:NN \exsheets_par: \scan_stop: )
@@ -2990,3 +3067,4 @@ HISTORY:
- \examspace inside {tasks} => possible? (\pagegoal-\pagetotal) gives wrong
values here
- remove doubled points name if total points are unknown
+