Skip to content

Commit

Permalink
further improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cgnieder committed Mar 24, 2017
1 parent 6d85405 commit 6ccfe7a
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 57 deletions.
12 changes: 9 additions & 3 deletions code/xsim.definitions.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
\DeclareExerciseParameter !{solution-name}
\DeclareExerciseParameter !{exercise-template}
\DeclareExerciseParameter !{solution-template}
\DeclareExerciseParameter {counter}
\DeclareExerciseParameter* {counter}
\DeclareExerciseParameter* {number}

% ----------------------------------------------------------------------------
Expand Down Expand Up @@ -78,6 +78,9 @@
\DeclareExerciseGoal {points}
\DeclareExerciseGoal {bonus-points}

\NewDocumentCommand \printgoal {m}
{ \ExerciseGoalValuePrint {#1} {} {} }

\NewDocumentCommand \points {m}
{
\ExerciseGoalValuePrint {#1}
Expand Down Expand Up @@ -219,7 +222,10 @@
\ForEachUsedExerciseByType
{
\XSIMifeqTF {#1} { \ExerciseTableType {#1} }
{ \XSIMputright \ExerciseTableCode { \XSIMifblankTF {#5} {0} {#5} & } }
{
\XSIMputright \ExerciseTableCode
{ \XSIMifblankTF {#5} {\printgoal{0}} {\printgoal{#5}} & }
}
{}
}
\XSIMputright \ExerciseTableCode
Expand Down Expand Up @@ -277,7 +283,7 @@
}
{}
\XSIMputright \ExerciseTableCode
{ #3 & \XSIMifblankTF {#5} {0} {#5} & \\ }
{ #3 & \XSIMifblankTF {#5} {\printgoal{0}} {\printgoal{#5}} & \\ }
}
{}
}
Expand Down
8 changes: 4 additions & 4 deletions code/xsim.exercises.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,13 @@
\exp_not:N \@addtoreset { \xsim_get_parameter:nn {#1} {counter} } {####1},
\xsim_get_parameter:nn {#1} {exercise-env} / the-counter .code:n =
\cs_set:cpn {the \xsim_get_parameter:nn {#1} {counter} } {####1} ,
\xsim_get_parameter:nn {#1} {exercise-env} / exercise-template
\xsim_get_parameter:nn {#1} {exercise-env} / template
.code:n = \xsim_set_parameter:nnn {#1} {exercise-template} {####1} ,
\xsim_get_parameter:nn {#1} {exercise-env} / solution-template
\xsim_get_parameter:nn {#1} {solution-env} / template
.code:n = \xsim_set_parameter:nnn {#1} {solution-template} {####1} ,
\xsim_get_parameter:nn {#1} {exercise-env} / exercise-name
\xsim_get_parameter:nn {#1} {exercise-env} / name
.code:n = \xsim_set_parameter:nnn {#1} {exercise-name} {####1} ,
\xsim_get_parameter:nn {#1} {exercise-env} / solution-name
\xsim_get_parameter:nn {#1} {solution-env} / name
.code:n = \xsim_set_parameter:nnn {#1} {solution-name} {####1}
}
\xsim_new_environment:nn {#1} {exercise}
Expand Down
8 changes: 4 additions & 4 deletions code/xsim.sty
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

\ExplSyntaxOn

\tl_const:Nn \c_xsim_date_tl {2017/03/22}
\tl_const:Nn \c_xsim_date_tl {2017/03/24}
\tl_const:Nn \c_xsim_version_major_number_tl {0}
\tl_const:Nn \c_xsim_version_minor_number_tl {3}
\tl_const:Nn \c_xsim_version_minor_number_tl {4}
\tl_const:Nn \c_xsim_version_subrelease_tl {}
\tl_const:Nx \c_xsim_version_number_tl
{
Expand Down Expand Up @@ -117,7 +117,7 @@ v0.1 2017/03/19 - first draft which actually seems to do everything as
v0.2 2017/03/21 - bugfix in the verbwrite module
- add `use!' and `print!' properties
- add the concepts of `noupdate' and `boolean' properties
v0.3 2017/03/23 - \IfExerciseBooleanPropertyTF
v0.4 2017/03/24 - \IfExerciseBooleanPropertyTF
- \GetExercisePropertyTF, \PropertyValue
- \printallsolutions
- \UseExerciseTemplate
Expand All @@ -128,4 +128,4 @@ v0.3 2017/03/23 - \IfExerciseBooleanPropertyTF
- \AddtoExerciseTypeGoal, \AddtoExerciseGoal
\AddtoExerciseTypeGoalPrint, \AddtoExerciseGoalPrint,
\ExerciseGoalValuePrint
- \addpoints, \addbonus, \points
- \addpoints, \addbonus, \points, \printgoal
6 changes: 5 additions & 1 deletion doc/xsim-manual.cls
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
printallsolutions ,
printcollection ,
printexercise ,
printgoal ,
printpoints ,
printsolution ,
printsolutions ,
printsolutionstype ,
Expand Down Expand Up @@ -377,7 +379,9 @@
}
\ExplSyntaxOff

\newcommand*\environ[1]{\beginenv*\Marg{\env{exercise}}}
\newcommand*\environ{\@ifstar\environ@star\environ@nostar}
\newcommand*\environ@star[1]{\beginenv*\Marg{\env*{#1}}}
\newcommand*\environ@nostar[1]{\beginenv*\Marg{\env{#1}}}

\RequirePackage{tcolorbox}
\tcbuselibrary{skins,breakable}
Expand Down
Binary file modified doc/xsim_manual.pdf
Binary file not shown.
80 changes: 46 additions & 34 deletions doc/xsim_manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ \section{Licence, Requirements and \textsc{README}}
\section{Motivation and Background}

It has been quite a while since I first published
\pkg{exsheets}~\cite{pkg:exsheets} in Juni 2012. Since then it has gained a
\pkg{exsheets}~\cite{pkg:exsheets} in June 2012. Since then it has gained a
user base and a little bit of popularity as the number of questions on tex.sx
shows (99~at the time of writing)~\cite{texsx:tagged/exsheets}. User
questions, bug reports and feature requests improved it over the time. It
Expand Down Expand Up @@ -132,7 +132,7 @@ \subsection{Package Options}\label{sec:package-options}
or via the setup command:
\begin{commands}
\command{xsimsetup}[\marg{options}]
Set up \xsim's two package options and all other options described at
Set up \xsim's package options and all other options described at
other places in the manual.
\end{commands}

Expand All @@ -143,7 +143,7 @@ \subsection{Setting Options}
\begin{options}
\keyval*{toplevel}{value}
A toplevel option.
\keyval*{sublebel}{value}\Module*{module}
\keyval*{sublevel}{value}\Module*{module}
A sublevel option belonging to the module \module*{module}
\end{options}
Both kinds of options are set with \cs{xsimsetup}:
Expand Down Expand Up @@ -353,7 +353,8 @@ \section{New Exercise Types}\label{sec:new-exercise-types}
The counter used for the exercises of type \meta{type}. If not explicitly
set the counter with the same name as \parameter{exercise-env} is used.
Otherwise the specified counter is used. This enables to have different
types of exercises sharing a common counter.
types of exercises sharing a common counter. This parameter can't be
changed afterwards.
\paraval{number}{integer}
An internal parameter that is used to keep track of the number of
exercises of a type. This parameter cannot be set or changed by the
Expand All @@ -362,8 +363,8 @@ \section{New Exercise Types}\label{sec:new-exercise-types}

It is possible to change some of the parameters after an exercise type has
been defined. Those include \parameter{exercise-name},
\parameter{solution-name}, \parameter{exercise-template},
\parameter{solution-template}, and \parameter{counter}:
\parameter{solution-name}, \parameter{exercise-template}, and
\parameter{solution-template}:
\begin{commands}
\command{SetExerciseParameter}[\marg{type}\marg{parameter}\marg{value}]
Usable to set a single parameter to a new value.
Expand All @@ -372,9 +373,10 @@ \section{New Exercise Types}\label{sec:new-exercise-types}
key/value pairs.
\end{commands}
If you try to set an already set but fixed parameter like
\parameter{exercise-env} a warning will be written to the log file. If you
set \parameter{counter} to another value you must make sure that the new value
is a valid and defined counter.
\parameter{exercise-env} a warning will be written to the log file. For all
parameters that can be changed also options exist wich can be set via
\cs{xsimsetup}. They are explained in
section~\vref{sec:environment-options-hooks}.

\section{Exercise Properties}\label{sec:exercise-properties}

Expand Down Expand Up @@ -439,7 +441,7 @@ \subsection{Declaring Own Properties}
if used without value it gets the value \code{true} instead of an empty
value. If any other value is used the property is set to
\code{false}. A boolean option obviously cannot be unique. The optional
\sarg\ takes precedence over the optional star, \ie, if both are present
\sarg\ takes precedence over the optional \barg, \ie, if both are present
the property is boolean \emph{but not} unique.

If used with the optional \narg\ a property is defined which won't get
Expand Down Expand Up @@ -483,7 +485,7 @@ \subsection{A Special Kind of Property: Exercise Goals}\label{sec:goals}
\meta{goal}.
\command{TotalExerciseTypeGoal}[\marg{type}\marg{goal}\marg{singular}\marg{plural}]
Get the sum of goal \meta{goal} for all exercises of type \meta{type}.
\meta{singular} andf \meta{plural} are placed after the sum in the input
\meta{singular} and \meta{plural} are placed after the sum in the input
stream depending on whether the sum equals~$1$ or not.
\command{TotalExerciseGoal}[\marg{goal}\marg{singular}\marg{plural}]
Get the sum of goal \meta{goal} for all exercises. \meta{singular} and
Expand All @@ -508,6 +510,9 @@ \subsection{A Special Kind of Property: Exercise Goals}\label{sec:goals}
\command{ExerciseGoalValuePrint}[\marg{value}\marg{singular}\marg{plural}]
Print \meta{value} and -- depending on wether the value equals $1$ or not --
\meta{singular} or \meta{plural}.
\command{printgoal}[\marg{value}]
Print \meta{value} according to option \option{goal-print}. Defined in
terms of \cs{ExerciseGoalValuePrint}.
\command{printpoints}[\marg{type}]
Print the sum of points for all exercises of type \meta{type} followed by
an appropriate translation of the words \enquote{point} or
Expand Down Expand Up @@ -567,9 +572,9 @@ \subsection{A Special Kind of Property: Exercise Tags}\label{sec:tags}
\emph{usage} of exercises and the difference to \emph{printing} an exercise
and how to use exercise tags for selection.
\begin{commands}
\command{DeclareExerciseTagging}{tag}
This defines an exercise tagging group name \meta{tag}. It also defines a
property named \meta{tag}. In addition to options are defines: and option
\command{DeclareExerciseTagging}[\marg{tag}]
This defines an exercise tagging group named \meta{tag}. It also defines a
property named \meta{tag}. In addition two options are defined: an option
named \code{\meta{tag}} which can be used for selection and an boolean
option \code{\meta{tag}/ignore-untagged}.
\end{commands}
Expand All @@ -580,7 +585,7 @@ \subsection{A Special Kind of Property: Exercise Tags}\label{sec:tags}
\DeclareExerciseTagging{topics}
\xsimsetup{tags/ingore-untagged=false}
\end{sourcecode}
this means that these options are available:
This means that these options are available:
\begin{options}
\keyval{tags}{csv list of tags}
Choose the set of tags whose associated exercises should be printed.
Expand All @@ -591,7 +596,7 @@ \subsection{A Special Kind of Property: Exercise Tags}\label{sec:tags}
been chosen with the option \option{tags}.
\keybool{ignore-tagging}\Module{topics}\Default{true}
If set to true exercises with no topics will be printed even if tags have
been chosen with the option \option{tags}.
been chosen with the option \option{topics}.
\end{options}

It may happen that you choose certain tags for printing and want one or two
Expand Down Expand Up @@ -619,13 +624,13 @@ \subsection{What the Environments do}
\item If the exercise is \emph{used} the corresponding counter is stepped
and the exercise is added to the \enquote{use list}. The properties
\property{counter} and \property{use} are updated accordingly.
\item If an exercise is printed then it is also used. An exercise that isn't
used cannot be printed. Being printed means two things: being added to
the \enquote{print list} and being typeset at the position where the
exercise is placed in the source file. If an exercise is \emph{not
printed but used} it means that the counter will be stepped. This can
be useful for creating an exercise sheet only containing the solutions for
some exercises.
\item If an exercise is \emph{printed} then it is also \emph{used}. An
exercise that isn't used cannot be printed. Being printed means two
things: being added to the \enquote{print list} and being typeset at the
position where the exercise is placed in the source file. If an exercise
is \emph{not printed but used} it means that the counter will be stepped.
This can be useful for creating an exercise sheet only containing the
solutions for some exercises.
\item If an exercise is printed certain hooks and template code is inserted
around the environment body.
\end{itemize}
Expand Down Expand Up @@ -675,12 +680,18 @@ \subsection{Environment Options \& Hooks}\label{sec:environment-options-hooks}
\keyval{the-counter}{code}\Module{exercise}
An interface for redefining the counter representation command
\cs*{the\meta{counter}}.
\keyval{exercise-template}{template}\Module{exercise}
\keyval{template}{template}\Module{exercise}
An interface for \cs{SetExerciseParameter}\Marg{exercise}%
\Marg{exercise-template}\marg{template}.
\keyval{solution-template}{template}\Module{exercise}
\keyval{template}{template}\Module{solution}
An interface for \cs{SetExerciseParameter}\Marg{exercise}%
\Marg{solution-template}\marg{template}.
\keyval{name}{name}\Module{exercise}
An interface for \cs{SetExerciseParameter}\Marg{exercise}%
\Marg{exercise-name}\marg{name}.
\keyval{name}{name}\Module{solution}
An interface for \cs{SetExerciseParameter}\Marg{exercise}%
\Marg{solution-name}\marg{name}.
\keyval{pre-hook}{code}\Module{exercise}\Default
The code for the \emph{pre exercise hook} for exercises of the type
\enquote{exercise}.
Expand Down Expand Up @@ -850,9 +861,7 @@ \subsection{Usage}

\section{Printing Solutions}\label{sec:printing-solutions}

There are two commands for printing the solutions to exercises -- one for
printing the solutions of a specific exercise type and another for printing
all solutions.
There are different commands for printing the solutions to exercises:
\begin{commands}
\command{printsolutionstype}[\sarg\oarg{options}\marg{exercise type}]
Prints the solutions of all used exercises of type \meta{exercise type}.
Expand Down Expand Up @@ -1343,7 +1352,7 @@ \subsubsection{Mimicking \pkg*{exsheets}' \code{runin} Template}

See it in action:
\begin{example}
\xsimsetup{exercise/exercise-template=runin}
\xsimsetup{exercise/template=runin}
\renewcommand*\theexercise{\arabic{exercise}.}
\begin{exercise}[subtitle=exsheets' runin,points=2.5]
\lipsum[4]
Expand Down Expand Up @@ -1383,7 +1392,7 @@ \subsubsection{Mimicking \pkg*{exsheets}' \code{margin} Template}

See it in action:
\begin{example}
\xsimsetup{exercise/exercise-template=margin}
\xsimsetup{exercise/template=margin}
\renewcommand*\theexercise{\arabic{exercise}.}
\begin{exercise}[subtitle=exsheets' margin,points=2.5]
\lipsum[4]
Expand Down Expand Up @@ -1432,7 +1441,7 @@ \subsubsection{The \code{default} Table Template}\label{sec:table-templ-default}
}
{}%
\XSIMputright\ExerciseTableCode
{#3 & \XSIMifblankTF{#5}{0}{#5} & \\ }%
{#3 & \XSIMifblankTF{#5}{\printgoal{0}}{\printgoal{#5}} & \\ }%
}
{}%
}
Expand Down Expand Up @@ -1500,7 +1509,10 @@ \subsubsection{The \code{default*} Table Template}\label{sec:table-templ-default
}%
\ForEachUsedExerciseByType{%
\XSIMifeqTF{#1}{\ExerciseTableType{#1}}
{\XSIMputright\ExerciseTableCode{\XSIMifblankTF{#5}{0}{#5} &}}
{%
\XSIMputright\ExerciseTableCode{%
\XSIMifblankTF{#5}{\printgoal{0}}{\printgoal{#5}} &}%
}
{}%
}%
\XSIMputright\ExerciseTableCode{%
Expand Down Expand Up @@ -1689,7 +1701,7 @@ \subsection{\dots Put a Star (or Other Symbol) in Exercises That Are Special?}

The usage is now as follows:
\begin{example}
\xsimsetup{exercise/exercise-template = bonus}
\xsimsetup{exercise/template = bonus}
% set the boolean property to true
\begin{exercise}[bonus]
A bonus question.
Expand Down Expand Up @@ -1803,7 +1815,7 @@ \section{The \pkg*{xsimverb} package}
\end{sourcecode}

\section{All Exercise Examples}
\xsimsetup{exercise/exercise-template = bonus}
\xsimsetup{exercise/template = bonus}
\printcollection[headings]{all exercises}

\section{All Solution Examples}
Expand Down
2 changes: 1 addition & 1 deletion examples/boxed-headings.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
{\vspace{\baselineskip}}

\xsimsetup{exercise/exercise-template = custom}
\xsimsetup{exercise/template = custom}

\usepackage{lipsum}

Expand Down
4 changes: 2 additions & 2 deletions examples/crossref.tex
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
}
{}
\xsimsetup{
exercise/exercise-template = custom ,
exercise/solution-template = custom ,
exercise/template = custom ,
solution/template = custom ,
print-solutions/headings-template = custom
}

Expand Down
6 changes: 3 additions & 3 deletions examples/different-point-types.tex
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
}%
}
{}
\SetExerciseParameters{exercise}{
exercise-template = custom ,
solution-template = custom
\xsimsetup{
exercise/template = custom ,
solution/template = custom
}
\renewcommand*\theexercise{\arabic{exercise}.}

Expand Down
2 changes: 1 addition & 1 deletion examples/difficulties.tex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}
{}

\xsimsetup{exercise/exercise-template = custom}
\xsimsetup{exercise/template = custom}

\begin{document}

Expand Down
4 changes: 2 additions & 2 deletions examples/floating.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
placement=htp,
]{ex}

\xsimsetup{exercise/exercise-template = float}

\DeclareExerciseEnvironmentTemplate{float}
{%
\ex
Expand All @@ -35,6 +33,8 @@
}
{\endex}

\xsimsetup{exercise/template = float}

\begin{document}

\listofexs
Expand Down
Loading

0 comments on commit 6ccfe7a

Please sign in to comment.