summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-12-02 22:18:13 +0000
committerKarl Berry <karl@freefriends.org>2013-12-02 22:18:13 +0000
commitac2cf3ee05ab2a5494afa92dbbdc6d56e7518bae (patch)
tree00742fb981b2fb0e6cf8ee6b973a6f582b5d46b7 /Master
parentc2d797847ce261ccb5b01de5ce8f45175422abb3 (diff)
exsheets (2dec13)
git-svn-id: svn://tug.org/texlive/trunk@32302 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/README4
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/exsheets_en.pdfbin693812 -> 666983 bytes
-rw-r--r--Master/texmf-dist/doc/latex/exsheets/exsheets_en.tex111
-rw-r--r--Master/texmf-dist/tex/latex/exsheets/exsheets.sty311
4 files changed, 327 insertions, 99 deletions
diff --git a/Master/texmf-dist/doc/latex/exsheets/README b/Master/texmf-dist/doc/latex/exsheets/README
index faed4849294..d464675a53e 100644
--- a/Master/texmf-dist/doc/latex/exsheets/README
+++ b/Master/texmf-dist/doc/latex/exsheets/README
@@ -1,7 +1,7 @@
--------------------------------------------------------------------------
-EXSHEETS 2013/11/20
+EXSHEETS 2013/12/02
bundled packages:
-the EXSHEETS package v0.11
+the EXSHEETS package v0.12
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/exsheets_en.pdf b/Master/texmf-dist/doc/latex/exsheets/exsheets_en.pdf
index 3b54dfb80f5..624c25da908 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 54c8e2196c1..f8fa3f14b60 100644
--- a/Master/texmf-dist/doc/latex/exsheets/exsheets_en.tex
+++ b/Master/texmf-dist/doc/latex/exsheets/exsheets_en.tex
@@ -65,6 +65,7 @@
C,
checkedchoicebox,choice,choicebox,
correct,
+ CurrentQuestionID,
DebugExSheets,
DeclareQuestionClass,DeclareQuestionProperty,
examspace,
@@ -74,6 +75,7 @@
GetQuestionProperty,
grade,
includequestions,iflastquestion,
+ IfQuestionSubtitleF,IfQuestionSubtitleT,IfQuestionSubtitleTF,
lastvariant,
NewQuSolPair,NewLstQuSolPair,
numberofquestions,
@@ -447,20 +449,18 @@ what any consequences of that will be for \ExSheets.
\section{Package Options}\label{sec:options}
The package \ExSheets\ has some options, namely the following ones:
\begin{options}
- %% color
- \keyval{color}{colour}\Default{exsheetsblue}
- A custom colour that is used in certain but very rare circumstances.
%% counter-format
\keyval{counter-format}{counter-format}\Default{qu.}
Formatting of the counter of the questions. This option takes a special
kind of string that is described in section~\ref{ssec:counter}.
\keyval{counter-within}{counter}\Default
- Resets the \code{question} counter with every step of \code{<counter>}.
+ Resets the \code{question} counter with every step of \meta{counter}.
%% auto-label
\keybool{auto-label}\Default{false}
If set to \code{true} \ExSheets\ will automatically place a
- \cs*{label}\Marg{qu:\meta{id}} for each question. It will also create the
- question properties \code{ref} and \code{pageref}, see
+ \cs*{label}\Marg{qu:\meta{id}} for each question. See
+ section~\ref{sec:auto-label-opti} for ways to customize this. It will
+ also create the question properties \code{ref} and \code{pageref}, see
section~\ref{sec:additional_info} for more on this.
%% headings
\keyval{headings}{instance}\Default{block}
@@ -557,6 +557,18 @@ You can also assign bonus points by inserting \code{\meta{point}+\meta{bonus
\end{question}
\end{example}
+The points are counted and added to the total sum of points, see
+section~\ref{sec:points} for details on this. \sinceversion{0.12}Should you
+want that the points of a specific question \emph{should not be added} to the
+total sum then precede it with a bang \code{!}:
+\begin{example}
+ \begin{question}{!3}
+ This question's points won't be added to the total sum.
+ \end{question}
+\end{example}
+Beware that this also prevents bonus points. The points simply will be
+written where the heading instance puts them.
+
\sinceversion{0.3}On additional thing: you might want to define custom
commands that should behave differently if they're inside or outside of the
\env{question} environment. In this case you can use these commands:
@@ -572,7 +584,7 @@ commands that should behave differently if they're inside or outside of the
input stream if not.
\end{commands}
-\subsection{Options to the \env*{question} Environment}
+\subsection{Options to the \env*{question} Environment}\label{sec:opti-ques-envir}
The \env{question} environment takes one or more of the following options:
\begin{options}
\keychoice{type}{exam,exercise}\Module{question}\Default{exercise}
@@ -625,6 +637,52 @@ for example useful when you want to print a sample solution for an exam. With
\keyis{use}{false} it is fully discarded which means it is not accessible
through an \acs{id} and a possible solution will not be saved.
+\subsection{Subtitles to Questions}
+The \option{subtitle} option mentioned in section~\ref{sec:opti-ques-envir}
+can be used to add a subtitle to a question. However, unless you choose a
+suitable heading (see section~\ref{sec:exsheets-headings}) it won't be
+printed. Currently there is \emph{one} heading instance that uses the
+subtitles but it should be easy to create a custom heading using one of the
+existing ones as a starter example. When creating such a heading you may want
+to distinguish between the cases when a subtitle has been given and when no
+subtitle is present. This can be done with the following commands:
+\begin{commands}
+ \expandable\command{IfQuestionSubtitleTF}[\marg{true code}\marg{false code}]
+ Tests if the current question has a subtitle. Leaves either \meta{true
+ code} or \meta{false code} in the input stream.
+ \expandable\command{IfQuestionSubtitleT}[\marg{true code}]
+ Tests if the current question has a subtitle. Leaves \meta{true code} in
+ the input stream if it has.
+ \expandable\command{IfQuestionSubtitleF}[\marg{false code}]
+ Tests if the current question has a subtitle. Leaves \meta{false code} in
+ the input stream if it hasn't.
+\end{commands}
+
+A subtitle is also a property of a question in the sense of
+section~\ref{sec:additional_info}. That means if a subtitle is given it can
+be retrieved with \cs{GetQuestionProperty}.
+
+As an example you could define your own heading instance that prints the
+\acs{id} of a question and (if given) the subtitle:
+
+\begin{sourcecode}
+ \DeclareInstance{exsheets-heading}{QE}{default}{
+ join = {
+ title[r,B]number[l,B](.333em,0pt) ;
+ title[r,B]subtitle[l,B](1em,0pt)
+ } ,
+ attach = {
+ main[l,vc]title[l,vc](0pt,0pt) ;
+ main[r,vc]points[l,vc](\marginparsep,0pt)
+ } ,
+ subtitle-post-code = {ID: \CurrentQuestionID} ,
+ number-post-code = {\IfQuestionSubtitleF{ID: \CurrentQuestionID}}
+ }
+\end{sourcecode}
+
+Please see section~\ref{sec:exsheets-headings} for more details on heading
+instances.
+
\subsection{The \env*{solution} Environment}
If you want to save/print (more on the exact usage in
section~\ref{sec:solutions}) a solution you have to use the \env{solution}
@@ -987,9 +1045,8 @@ the following command:
\begin{commands}
\command{DebugExSheets}[\Marg{\choices{true,false}}]
Enable or disable visual \ExSheets' debugging.
- \command{CurrentQuestionID}
- \sinceversion{0.4a}Expands to the current question \acs{id} (after two
- expansions).
+ \expandable\command{CurrentQuestionID}
+ \sinceversion{0.4a}Expands to the current question \acs{id}.
\end{commands}
Let's create some more questions and take a look what this command does:
\begin{example}
@@ -1168,9 +1225,12 @@ Now the commands for recovering the properties:
Recover the number of the question with the \acs{id} \meta{id}. The
number is displayed according to the format set with
\option{counter-format}.
- \command{GetQuestionProperty}[\marg{name}\marg{id}]
+ \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.
+ \meta{id}. Of course the property must have been declared before. The
+ command is expandable. Since\sinceversion{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}
Let's say we have declared the properties \code{notes}, \code{reference} and
@@ -1233,7 +1293,8 @@ It is now possible to recover these values later:
\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.
+corresponding \cs*{ref} or \cs*{pageref}, respectively. Also see
+section~\ref{sec:auto-label-opti}.
Please note that these properties \emph{are not the same} as the dividing
concepts explained in section~\ref{sec:dividing-concepts} although they may
@@ -1462,6 +1523,30 @@ following macro:
usage of \cs{includequestions}.
\end{commands}
+\section{The \option*{auto-label} Option}\label{sec:auto-label-opti}
+The\sinceversion{0.12} package option \option{auto-label} sets a
+\cs*{label}\Marg{qu:\meta{id}} every time the question environment is used.
+Both the used command and the automated label can be customized using the
+following options:
+
+\begin{options}
+ \keyval{label-format}{code}\Default{qu:\#1}
+ The pattern for generating the automatic label. \code{\#1} gets replaced
+ by the \ac{id} of the corresponding question.
+ \keyval{label-cmd}{macro}\Default{\cs*{label}}
+ The command used for generating the label. A command that should take one
+ mandatory argument.
+ \keyval{ref-cmd}{macro}\Default{\cs*{ref}}
+ The command used in the \code{ref} property created by the
+ \option{auto-label} option, also see section \ref{sec:additional_info}.
+ The command should take one mandatory argument.
+ \keyval{pageref-cmd}{macro}\Default{\cs*{pageref}}
+ The command used in the \code{pageref} property created by the
+ \option{auto-label} option, also see section \ref{sec:additional_info}.
+ The command should take one mandatory argument.
+\end{options}
+
+
\section{Own Question/Solution Pairs}
\noindent\changedversion{0.9}\ExSheets\ provides he possibility to create new
environments that behave like the \env{question} and \env{solution}
diff --git a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
index ed95236e601..7a67093fe33 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{2013/11/20}
-\def\exsheets@version{0.11}
+\def\exsheets@date{2013/12/02}
+\def\exsheets@version{0.12}
\RequirePackage { expl3 , xparse }
\ProvidesExplPackage
@@ -51,12 +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: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_get:NnN { Nx }
+\cs_generate_variant:Nn \prop_get:NnN { 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 \tl_if_blank:nTF { x }
% ----------------------------------------------------------------------------
% temporary variables
@@ -79,13 +80,13 @@
% messages
\msg_new:nnn { exsheets} { totalpoints }
{
- You~need~to~activate~"points/parse"~if~you~want~to~use~
+ You~need~to~activate~`points/parse'~if~you~want~to~use~
\token_to_str:N \totalpoints .~I~will~do~nothing~instead.
}
\msg_new:nnn { exsheets} { parse-points }
{
- You~need~to~activate~"points/parse"~if~you~want~to~use~
+ You~need~to~activate~`points/parse'~if~you~want~to~use~
\token_to_str:N #1 .~I~will~do~nothing~instead.
}
@@ -111,7 +112,7 @@
\msg_new:nnn { exsheets } { only-inside-question }
{
- The~command~\token_to_str:N #1 \c_space_tl can~only~be~used~inside~
+ The~command~`~\token_to_str:N #1 \c_space_tl'~can~only~be~used~inside~
the~question~environment.
}
@@ -120,10 +121,13 @@
\msg_new:nnn { exsheets } { deprecated-command }
{
- The~command~"~\token_to_str:N #1 \c_space_tl"~is~deprecated.~
- Use~"~\token_to_str:N #2 \c_space_tl"~instead.
+ The~command~`~\token_to_str:N #1 \c_space_tl'~is~deprecated.~
+ Use~`~\token_to_str:N #2 \c_space_tl'~instead.
}
+\msg_new:nnn { exsheets } { dropped-option }
+ { The~option~`#1'~has~been~dropped. }
+
\msg_new:nnn { exsheets } { grade-missing }
{ The~grade~`#1'~has~never~been~declared. }
@@ -151,6 +155,9 @@
{ \msg_warning:nnnn { exsheets } { deprecated-command } { #1 } { #2 } #2 }
}
+\cs_new_protected:Npn \exsheets_option_dropped:n #1
+ { \msg_warning:nnn { exsheets } { dropped-option } { #1 } }
+
% ----------------------------------------------------------------------------
\RequirePackage
{ xtemplate , l3sort , l3keys2e , xcolor , etoolbox , environ , pgfcore }
@@ -159,8 +166,24 @@
% color:
\xdefinecolor { exsheetsblue } { rgb } { 0.02 , 0.04 , 0.48 }
\xdefinecolor { exsheetsred } { rgb } { 0.65 , 0.04 , 0.07 }
-\tl_new:N \g__exsheets_color_tl
-\tl_gset:Nn \g__exsheets_color_tl { exsheetsblue }
+% \tl_new:N \g__exsheets_color_tl
+\tl_const:Nn \c__exsheets_color_tl { exsheetsblue }
+
+% ----------------------------------------------------------------------------
+% write to aux file:
+\cs_new_protected:Npn \exsheets_write_to_aux_x:n #1
+ { \if@filesw \iow_now:Nx \@auxout { #1 } \fi }
+
+% prevent compilatin errors when exsheets is removed from a document:
+\AtBeginDocument{
+ \exsheets_write_to_aux_x:n
+ {
+ \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]{}
+ }
+}
% ----------------------------------------------------------------------------
% how are questions/solutions/... counted?
@@ -217,7 +240,8 @@
\keys_define:nn { exsheets }
{
- color .tl_gset:N = \g__exsheets_color_tl ,
+ color .code:n =
+ \exsheets_option_dropped:n { color } ,
counter-format .code:n =
\SaveCounterPattern [ exsheets ]
\l__exsheets_qu_counter_pattern_tl
@@ -937,6 +961,8 @@
\tl_new:N \l__exsheets_exercise_name_tl
\tl_set:Nn \l__exsheets_exercise_name_tl { Exercise }
+\tl_new:N \CurrentQuestionID
+
\bool_new:N \l__exsheets_questions_print_bool
\bool_set_true:N \l__exsheets_questions_print_bool
\bool_new:N \l__exsheets_inside_question_bool
@@ -989,12 +1015,36 @@
\tl_new:N \l__exsheets_questions_label_tl
\tl_new:N \l__exsheets_questions_points_tl
-\bool_new:N \l__exsheets_points_not_given_bool
+\prg_new_conditional:Npnn \exsheets_if_question_subtitle: { p,T,F,TF }
+ {
+ \tl_if_blank:VTF \l__exsheets_questions_subtitle_tl
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+
+\cs_new:Npn \IfQuestionSubtitleTF { \exsheets_if_question_subtitle:TF }
+\cs_new:Npn \IfQuestionSubtitleT { \exsheets_if_question_subtitle:T }
+\cs_new:Npn \IfQuestionSubtitleF { \exsheets_if_question_subtitle:F }
+
+\bool_new:N \l__exsheets_only_print_points_bool
\fp_new:N \g__exsheets_this_question_points_fp
\fp_new:N \g__exsheets_this_question_bonus_fp
-\cs_new_protected:Npn \__exsheets_read_points:w #1+#2+#3 \q_stop
+\cs_new:Npn \__exsheets_read_points:w #1 ! #2 ! #3 \q_stop
+ {
+ \tl_if_blank:nTF { #1 }
+ {
+ \bool_set_true:N \l__exsheets_only_print_points_bool
+ \tl_set:Nn \l__exsheets_questions_points_tl { #2 }
+ }
+ {
+ \bool_set_false:N \l__exsheets_only_print_points_bool
+ \__exsheets_read_points_aux:w #1++ \q_stop
+ }
+ }
+
+\cs_new_protected:Npn \__exsheets_read_points_aux:w #1+#2+#3 \q_stop
{
\tl_if_blank:nTF { #1 }
{ \fp_zero:N \l__exsheets_question_points_fp }
@@ -1010,10 +1060,60 @@
\cs_new_protected:Npn \__exsheets_read_points:n #1
{
\bool_if:NTF \l__exsheets_parse_points_bool
- { \__exsheets_read_points:w #1++ \q_stop }
+ { \__exsheets_read_points:w #1!! \q_stop }
{ \tl_set:Nn \l__exsheets_questions_points_tl { #1 } }
}
+\cs_new:Npn \exsheets_label_format:n #1 { qu:#1 }
+\cs_new:Npn \__exsheets_label:n { \label }
+\cs_new:Npn \exsheets_label:n { }
+\cs_generate_variant:Nn \exsheets_label:n { V }
+\cs_new:Npn \__exsheets_ref:n { \ref }
+\cs_new:Npn \exsheets_ref:n { }
+\cs_new:Npn \__exsheets_pageref:n { \pageref }
+\cs_new:Npn \exsheets_pageref:n { }
+
+\cs_new_protected:Npn \exsheets_update_referencing_command:NN #1#2
+ {
+ \cs_set:Npx #1 ##1
+ { \exp_not:o { #2 } { \exsheets_label_format:n { ##1 } } }
+ }
+
+\cs_new_protected:Npn \exsheets_update_referencing_commands:
+ {
+ \exsheets_update_referencing_command:NN \exsheets_label:n \__exsheets_label:n
+ \exsheets_update_referencing_command:NN \exsheets_ref:n \__exsheets_ref:n
+ \exsheets_update_referencing_command:NN \exsheets_pageref:n \__exsheets_pageref:n
+ }
+
+\cs_new_protected:Npn \exsheets_set_ref_properties:n #1
+ {
+ \exsheets_set_question_properties:x
+ {
+ ref = \exp_not:o { \exsheets_ref:n { #1 } } ,
+ pageref = \exp_not:o { \exsheets_pageref:n { #1 } }
+ }
+ }
+\cs_generate_variant:Nn \exsheets_set_ref_properties:n { V }
+
+\keys_define:nn { exsheets }
+ {
+ label-format .code:n =
+ \cs_set:Npn \exsheets_label_format:n ##1 { #1 }
+ \exsheets_update_referencing_commands: ,
+ label-cmd .code:n =
+ \cs_set:Npn \__exsheets_label:n { #1 }
+ \exsheets_update_referencing_commands: ,
+ ref-cmd .code:n =
+ \cs_set:Npn \__exsheets_ref:n { #1 }
+ \exsheets_update_referencing_commands: ,
+ page-ref-cmd .code:n =
+ \cs_set:Npn \__exsheets_pageref:n { #1 }
+ \exsheets_update_referencing_commands:
+ }
+
+\exsheets_update_referencing_commands:
+
\newenvironment { __exsheets_question: } [2]
{
\bool_set_true:N \l__exsheets_inside_question_bool
@@ -1038,35 +1138,16 @@
{
\tl_gset:Nx \g__exsheets_questions_current_id_tl
{ \tl_use:N \l__exsheets_questions_id_tl }
- }
- % label:
- \tl_if_blank:VTF \l__exsheets_questions_label_tl
- {
- \bool_if:NT \l__exsheets_auto_label_bool
- {
- \exp_args:Nx \label { qu : \g__exsheets_questions_current_id_tl }
- \exsheets_set_question_properties:x
- {
- ref = \exp_not:N \ref { qu : \g__exsheets_questions_current_id_tl } ,
- pageref = \exp_not:N \pageref { qu : \g__exsheets_questions_current_id_tl }
- }
- }
- }
- {
- \exp_args:Nx \label { \l__exsheets_questions_label_tl }
- \exsheets_set_question_properties:x
- {
- ref = \exp_not:N \ref { \l__exsheets_questions_label_tl } ,
- pageref = \exp_not:N \pageref { \l__exsheets_questions_label_tl }
- }
- }
- % FIXME: rather useless since it isn't used at all, see also
- % exsheets_headings.def
+ }
\tl_if_blank:VF \l__exsheets_questions_subtitle_tl
{
- \prop_gput:NVV \g__exsheets_questions_subtitle_prop
- \g__exsheets_questions_current_id_tl
- \l__exsheets_questions_subtitle_tl
+ \exsheets_set_question_properties:x
+ { subtitle = { \exp_not:V \l__exsheets_questions_subtitle_tl } }
+ % FIXME: rather useless since it isn't used at all, see also
+ % exsheets_headings.def
+ % \prop_gput:NVV \g__exsheets_questions_subtitle_prop
+ % \g__exsheets_questions_current_id_tl
+ % \l__exsheets_questions_subtitle_tl
}
}
\bool_if:nT
@@ -1097,8 +1178,9 @@
\fp_set_eq:NN
\l__exsheets_question_points_fp
\l__exsheets_points_default_fp
- \exsheets_set_question_properties:x
- { points = \fp_to_tl:N \l__exsheets_points_default_fp }
+ % check if moving this to a later point has negative effects...
+ % \exsheets_set_question_properties:x
+ % { points = \fp_to_tl:N \l__exsheets_points_default_fp }
}
}
{
@@ -1106,7 +1188,8 @@
\g__exsheets_this_question_points_fp
\l__exsheets_question_points_fp
\__exsheets_read_points:n { #2 }
- \exsheets_set_question_properties:n { points = #2 }
+ % check if moving this to a later point has negative effects...
+ % \exsheets_set_question_properties:n { points = #2 }
}
\tl_if_blank:VT \l__exsheets_question_heading_instance_tl
{
@@ -1146,6 +1229,19 @@
% 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
{
@@ -1185,7 +1281,9 @@
\l__exsheets_tmpa_tl
\l__exsheets_questions_id_tl
}
- \bool_if:NTF \l__exsheets_parse_points_bool
+ \tl_set_eq:NN \CurrentQuestionID \l__exsheets_tmpa_tl
+ \bool_if:nTF
+ { \l__exsheets_parse_points_bool && !\l__exsheets_only_print_points_bool }
{
\__exsheets_use_heading:VVVnnV
\l__exsheets_question_heading_instance_tl
@@ -1196,13 +1294,26 @@
\l__exsheets_tmpa_tl
}
{
- \__exsheets_use_heading:VVVnnV
- \l__exsheets_question_heading_instance_tl
- \l__exsheets_questions_title_tl
- \l__exsheets_qu_counter_interpretation_tl
- { \l__exsheets_questions_points_tl }
- { 0 }
- \l__exsheets_tmpa_tl
+ % might be dangerous to expand here...
+ \tl_if_blank:xTF { \l__exsheets_questions_points_tl }
+ {
+ \__exsheets_use_heading:VVVnnV
+ \l__exsheets_question_heading_instance_tl
+ \l__exsheets_questions_title_tl
+ \l__exsheets_qu_counter_interpretation_tl
+ { 0 }
+ { 0 }
+ \l__exsheets_tmpa_tl
+ }
+ {
+ \__exsheets_use_heading:VVVnnV
+ \l__exsheets_question_heading_instance_tl
+ \l__exsheets_questions_title_tl
+ \l__exsheets_qu_counter_interpretation_tl
+ { \l__exsheets_questions_points_tl }
+ { 0 }
+ \l__exsheets_tmpa_tl
+ }
}
}
}
@@ -1229,9 +1340,7 @@
\cs_new_protected:Npn \__exsheets_save_number_in_aux_x:Nnn #1#2#3
{
\prop_gput:Nfx #1 { #2 } { #3 }
- \if@filesw
- \iow_now:Nx \@auxout { \exsheets@save@number { #2 } { #3 } }
- \fi
+ \exsheets_write_to_aux_x:n { \exsheets@save@number { #2 } { #3 } }
}
\cs_new_protected:Npn \__exsheets_save_number_in:N #1
@@ -1348,7 +1457,7 @@
\tl_set:Nn \l__exsheets_exercise_name_tl { #1 }
\tl_set:Nn \l__exsheets_questions_name_tl { #1 } ,
headings .tl_set:N = \l__exsheets_question_heading_instance_tl ,
- subtitle .tl_set:N = \l__exsheets_questions_subtitle_tl ,
+ subtitle .tl_set:N = \l__exsheets_questions_subtitle_tl ,
print .bool_set:N = \l__exsheets_questions_print_bool ,
print .default:n = true ,
ID .tl_set:N = \l__exsheets_questions_id_tl ,
@@ -1393,20 +1502,42 @@
\NewDocumentCommand \SetQuestionProperties { m }
{ \exsheets_set_question_properties:n { #1 } }
+% #1: ID
+% #2: property
+% #3: value
+\cs_new:Npn \exsheets@question@property #1#2#3
+ {
+ \prop_gput:cnn { g__exsheets_question_property_#2_prop }
+ { #1 } { #3 }
+ }
+
+% #1: property
+% #2: value
\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 }
+ % watch if this has negativ effects:
+ \exsheets_write_to_aux_x:n
+ {
+ \exp_not:N \exsheets@question@property
+ { \g__exsheets_questions_current_id_tl }
+ { \exp_not:n {#1} }
+ { \exp_not:n {#2} }
+ }
}
-\NewDocumentCommand \GetQuestionProperty { mm }
- { \exsheets_get_question_property:nn { #1 } { #2 } }
+% #1: property
+% #2: ID
+\DeclareExpandableDocumentCommand \GetQuestionProperty { mm }
+ { \exsheets_get_question_property:no { #1 } { #2 } }
\cs_new:Npn \exsheets_get_question_property:nn #1#2
{
\prop_if_in:cnT { g__exsheets_question_property_#1_prop } { #2 }
{ \prop_get:cn { g__exsheets_question_property_#1_prop } { #2 } }
}
+\cs_generate_variant:Nn \exsheets_get_question_property:nn { no }
\int_new:N \g__exsheets_tmpa_int
\cs_new_protected:Npn \ForEachQuestion #1
@@ -1480,8 +1611,6 @@
\NewDocumentCommand \DebugExSheets { G{true} }
{ \use:c { bool_set_#1:N } \l__exsheets_questions_debug_bool }
-\cs_new:Npn \CurrentQuestionID { \g__exsheets_questions_current_id_tl }
-
% ----------------------------------------------------------------------------
% include random/selected questions from a file:
\bool_new:N \l__exsheets_select_questions_bool
@@ -1937,22 +2066,20 @@
\cs_new_protected:Npn \__exsheets_exlabel:n #1
{
\@bsphack
- \if@filesw
- \iow_now:Nx \@auxout
+ \exsheets_write_to_aux_x:n
{
\token_to_str:N \newlabel { exse:#1 }
{ { \arabic { section } } { \thepage } }
}
\cs_if_exist:NT \thechapter
{
- \iow_now:Nx \@auxout
+ \exsheets_write_to_aux_x:n
{
\token_to_str:N \newlabel { exch:#1 }
{ { \arabic { chapter } } { \thepage } }
}
}
- \@esphack
- \fi
+ \@esphack
}
% user command:
@@ -1967,10 +2094,10 @@
}
% this is like \ref from latex.ltx
-\cs_new:Npn \__exsheets_ref:n #1
+\cs_new:Npn \__exsheets_exref:n #1
{
\cs_if_exist:cTF { r@#1 }
- { \__exsheets_ref_aux:n { #1 } }
+ { \__exsheets_exref_aux:n { #1 } }
{
1\relax
\protect\G@refundefinedtrue
@@ -1978,10 +2105,10 @@
}
}
-\cs_new:Npn \__exsheets_ref_aux:n #1
+\cs_new:Npn \__exsheets_exref_aux:n #1
{ \exp_after:wN \exp_after:wN \exp_after:wN \use_i:nn \cs:w r@#1 \cs_end: }
-\cs_new_eq:NN \exref \__exsheets_ref:n
+\cs_new_eq:NN \exref \__exsheets_exref:n
% user command:
\NewDocumentCommand \printsolutions { O{all} }
@@ -2536,13 +2663,14 @@
% properties:
\DeclareQuestionProperty{points}
+\DeclareQuestionProperty{subtitle}
\bool_if:NT \l__exsheets_auto_label_bool
{
\DeclareQuestionProperty{ref}
\DeclareQuestionProperty{pageref}
}
-% classs:
+% classes:
\DeclareQuestionClass{class}{classes}
\DeclareQuestionClass{topic}{topics}
@@ -2610,15 +2738,13 @@
% save total points in .aux file to make it available for \allpoints anywhere
\AtEndDocument
{
- \if@filesw
- \iow_now:Nx \@auxout
- {
- \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 } }
- }
- \fi
+ \exsheets_write_to_aux_x:n
+ {
+ \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 } }
+ }
}
% ----------------------------------------------------------------------------
@@ -2777,6 +2903,23 @@ HISTORY:
has been passed to the headings
2013/11/20 v0.11 - \GetQuestionClass{}
- \PrintQuestionClass(TF)
+2013/12/02 v0.12 - fix issue with \CurrentQuestionID
+ - new options `label-format', `label-cmd', `ref-cmd'
+ and `pageref-cmd' for `auto-label' options that
+ allow specification of labelling command and thus
+ compatibility with packages like `cleveref'
+ - write question properties to aux file so they can be
+ retrieved before the corresponding question is
+ printed
+ - make \GetQuestionProperty expandable
+ - new syntax featture in points argument: a leading
+ bang prevents the points from being added to the sum
+ of points
+ - added possibility for
+ https://bitbucket.org/cgnieder/exsheets/issue/15
+ - added \IfQuestionSubtitle(TF)
+ - added `subtitle' property
+ - dropped `color' option
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TODO: