Skip to content

Commit

Permalink
v0.5: style files; print solutions selections do select with AND
Browse files Browse the repository at this point in the history
  • Loading branch information
cgnieder committed Mar 30, 2017
1 parent bf53919 commit fb8ef68
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------
XSIM 2017/03/24 v0.4
XSIM 2017/03/30 v0.5

eXercise Sheets IMproved

Expand Down
8 changes: 4 additions & 4 deletions code/xsim.interface.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,15 @@
\NewDocumentCommand \printsolutions {sO{}}
{
\IfBooleanTF {#1}
{ \xsim_print_all_solutions:nn { \c_true_bool } {#2} }
{ \xsim_print_all_solutions:nn { \c_false_bool } {#2} }
{ \xsim_print_all_solutions_per_type:nn { \c_true_bool } {#2} }
{ \xsim_print_all_solutions_per_type:nn { \c_false_bool } {#2} }
}

\NewDocumentCommand \printallsolutions {sO{}}
{
\IfBooleanTF {#1}
{ \xsim_print_id_solutions:nn { \c_true_bool } {#2} }
{ \xsim_print_id_solutions:nn { \c_false_bool } {#2} }
{ \xsim_print_all_solutions_per_id:nn { \c_true_bool } {#2} }
{ \xsim_print_all_solutions_per_id:nn { \c_false_bool } {#2} }
}

% ----------------------------------------------------------------------------
Expand Down
17 changes: 15 additions & 2 deletions code/xsim.modules.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,28 @@
\c_space_tl
xsim~ module~ `#1'~ (#2)
]
\ExplSyntaxOn
}
\cs_generate_variant:Nn \msg_error:nnnn {nnnx}

% --------------------------------------------------------------------------
% define a xsim module:
% #1: name
% #2: description
\NewDocumentCommand \XSIMmodule {mm} { \__xsim_module:nn {#1} {#2} }
\NewDocumentCommand \XSIMmodule {mm} { \__xsim_module:nn {#1} {#2}
\ExplSyntaxOn }

% --------------------------------------------------------------------------
% style files
\NewDocumentCommand \xsimstyle {sm}
{
\__xsim_module:nn {#2} {}
\IfBooleanF {#1} { \ExplSyntaxOn }
}

\cs_new_protected:Npn \xsim_style_options:nn #1#2
{ \keys_define:nn {xsim/#1} {#2} }

\NewDocumentCommand \loadxsimstyle {m} { \xsim_load_module:n {#1} }

% --------------------------------------------------------------------------
\tex_endinput:D
30 changes: 12 additions & 18 deletions code/xsim.solutions.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

\prop_new:N \l__xsim_printsolutions_conditions_prop

\int_new:N \l_xsim_printsolutions_heading_int
\int_new:N \l_xsim_printsolutions_section_int
\int_new:N \l_xsim_printsolutions_chapter_int

\tl_new:N \l__xsim_printsolutions_headings_template_tl
\tl_new:N \ExerciseSection
Expand Down Expand Up @@ -105,7 +106,7 @@
{
\__xsim_printsolutions_condition_true:
\xsim_if_in_list:nxTF {section-value}
{ #1-#2 == { \int_use:N \l_xsim_printsolutions_heading_int } }
{ #1-#2 == { \int_use:N \l_xsim_printsolutions_section_int } }
{
\tl_set:Nx \ExerciseSection
{ \xsim_get_property:nnn {#1} {#2} {section} }
Expand All @@ -131,7 +132,7 @@
{
\__xsim_printsolutions_condition_true:
\xsim_if_in_list:nxTF {chapter-value}
{ #1-#2 == { \int_use:N \l_xsim_printsolutions_heading_int } }
{ #1-#2 == { \int_use:N \l_xsim_printsolutions_chapter_int } }
{
\tl_set:Nx \ExerciseChapter
{ \xsim_get_property:nnn {#1} {#2} {chapter} }
Expand Down Expand Up @@ -215,6 +216,7 @@
\cs_new_protected:Npn \__xsim_printsolutions_condition:nn #1#2
{ \bool_set_eq:cc {l__xsim_printsolutions_#1_condition_bool} {c_#2_bool} }

% false if any condition is false for this solution:
% #1: type
% #2: id
% #3: print|use
Expand Down Expand Up @@ -245,10 +247,7 @@
\cs_new_protected:Npn \xsim_if_this_solution_do:nnnn #1#2#3#4
{
\xsim_if_solution_exists:nnT {#1} {#2}
{
\__xsim_printsolutions_check_conditions:nnnT {#1} {#2} {#3} {#4}
% \__xsim_printsolutions_if_conditions:nnnF {#1} {#2} {#3} {#4}
}
{ \__xsim_printsolutions_check_conditions:nnnT {#1} {#2} {#3} {#4} }
}

% ----------------------------------------------------------------------------
Expand Down Expand Up @@ -306,11 +305,10 @@
\group_end:
}

% TODO: add options (print subheadings, sort per type,...)
% #1: boolean -- if true only the solutions of printed exercises will be
% output
% #2: options
\cs_new_protected:Npn \xsim_print_all_solutions:nn #1#2
\cs_new_protected:Npn \xsim_print_all_solutions_per_type:nn #1#2
{
\xsim_foreach_exercise_type:n
{ \xsim_print_type_solutions:nnn {#1} {#2} {##1} }
Expand All @@ -319,7 +317,7 @@
% #1: boolean -- if true only the solutions of printed exercises will be
% output
% #2: options
\cs_new_protected:Npn \xsim_print_id_solutions:nn #1#2
\cs_new_protected:Npn \xsim_print_all_solutions_per_id:nn #1#2
{
\xsim_verbose:n { Printing~ solutions. }
\group_begin:
Expand Down Expand Up @@ -363,27 +361,23 @@
section .choice: ,
section/true .code:n =
\__xsim_printsolutions_condition:nn {per-section} {true}
\__xsim_printsolutions_condition:nn {per-chapter} {false}
\int_set:Nn \l_xsim_printsolutions_heading_int { \value {section} } ,
\int_set:Nn \l_xsim_printsolutions_section_int { \value {section} } ,
section/false .code:n =
\__xsim_printsolutions_condition:nn {per-section} {false} ,
section/unknown .code:n =
\__xsim_printsolutions_condition:nn {per-section} {true}
\__xsim_printsolutions_condition:nn {per-chapter} {false}
\int_set:Nn \l_xsim_printsolutions_heading_int {#1} ,
\int_set:Nn \l_xsim_printsolutions_section_int {#1} ,
section .default:n = true ,
section .initial:n = false ,
chapter .choice: ,
chapter/true .code:n =
\__xsim_printsolutions_condition:nn {per-section} {false}
\__xsim_printsolutions_condition:nn {per-chapter} {true}
\int_set:Nn \l_xsim_printsolutions_heading_int { \value {chapter} } ,
\int_set:Nn \l_xsim_printsolutions_chapter_int { \value {chapter} } ,
chapter/false .code:n =
\__xsim_printsolutions_condition:nn {per-chapter} {false} ,
chapter/unknown .code:n =
\__xsim_printsolutions_condition:nn {per-section} {false}
\__xsim_printsolutions_condition:nn {per-chapter} {true}
\int_set:Nn \l_xsim_printsolutions_heading_int {#1} ,
\int_set:Nn \l_xsim_printsolutions_chapter_int {#1} ,
chapter .default:n = true ,
chapter .initial:n = false ,
collection .choice: ,
Expand Down
7 changes: 5 additions & 2 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/24}
\tl_const:Nn \c_xsim_date_tl {2017/03/30}
\tl_const:Nn \c_xsim_version_major_number_tl {0}
\tl_const:Nn \c_xsim_version_minor_number_tl {4}
\tl_const:Nn \c_xsim_version_minor_number_tl {5}
\tl_const:Nn \c_xsim_version_subrelease_tl {}
\tl_const:Nx \c_xsim_version_number_tl
{
Expand Down Expand Up @@ -129,3 +129,6 @@ v0.4 2017/03/24 - \IfExerciseBooleanPropertyTF
\AddtoExerciseTypeGoalPrint, \AddtoExerciseGoalPrint,
\ExerciseGoalValuePrint
- \addpoints, \addbonus, \points, \printgoal
v0.5 2017/03/30 - add style file mechanism
- make solution print conditions `section' and `chapter'
combinable
14 changes: 13 additions & 1 deletion doc/xsim-manual.cls
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
IfInsideSolutionF ,
IfInsideSolutionT ,
IfInsideSolutionTF ,
loadxsimstyle ,
numberofexercises ,
numberofusedexercises ,
points ,
Expand Down Expand Up @@ -149,6 +150,7 @@
XSIMmixedcase ,
XSIMputright ,
xsimsetup ,
xsimstyle ,
XSIMtranslate
} ,
add-envs = { exercise , solution } ,
Expand Down Expand Up @@ -387,7 +389,17 @@
\tcbuselibrary{skins,breakable}
\tcbset{enhanced,enhanced jigsaw}

\newtcolorbox{bewareofthedog}{colback=red!5!white,colframe=red!75!black}
\newtcolorbox{bewareofthedog}{
colback = red!25!white ,
colframe = red ,
underlay={%
\path[draw=none]
(interior.south west)
rectangle node[red]{\Huge\bfseries !}
([xshift=-4mm]interior.north west);
}%
}

\newtcolorbox{cnltxcode}[1][]{
boxrule = 1pt ,
colback = cnltxbg ,
Expand Down
Binary file modified doc/xsim_manual.pdf
Binary file not shown.
110 changes: 107 additions & 3 deletions doc/xsim_manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

\begin{document}

\section{Licence, Requirements and \textsc{README}}
\section{Licence, Requirements and \textsc{readme}}
\license

\xsim\ loads the packages \pkg{expl3}~\cite{bnd:l3kernel},
Expand All @@ -62,6 +62,16 @@ \section{Licence, Requirements and \textsc{README}}
no further action should be needed. When you are using \xsim\ you should be
using an up to date \TeX\ distribution, anyway.

\begin{bewareofthedog}
Newer versions of \xsim\ may depend on newer versions of the support
packages. Remember: it is always dangerous to update single packages.
Always update your \TeX\ distribution if you want an up to date version of a
package. Be careful: if you're in the middle of an important project it
might be better to wait with the update until you've finished the project.
Every update might be breaking some things.
\end{bewareofthedog}


\section{Motivation and Background}

It has been quite a while since I first published
Expand Down Expand Up @@ -910,6 +920,12 @@ \section{Printing Solutions}\label{sec:printing-solutions}
\meta{collection name} are printed.
\end{options}

The conditions can be combined. The following call will only print solutions
from exercises in section~3 of chapter~2:
\begin{sourcecode}
\printsolutions[chapter=2,section=3]
\end{sourcecode}

\begin{bewareofthedog}
The selection per section or per chapter relies on the \emph{counter
numbers} of the sections or chapters, respectively. This means if section
Expand Down Expand Up @@ -1620,7 +1636,25 @@ \section{Other Commands}

\appendix

\section{How to\dots}
\section{Future Plans}

\xsim\ is complete in so far as it is perfectly usable to create exams or
exercise and solution sections in books with the most freedom in layout
already. But still there are features which would be useful additions. Below
I list all ideas that I currently plan to add to \xsim:
\begin{itemize}
\item random selection of exercises from a collection.
\item a documentclass \code{xsim-exam} for creating exams; this class should
itself feature the possibility of creating different versions of an exam,
maybe already provide multiple choice questions and so on; one could also
think about automatic creation of running headers and footers, \ie, means
for changing the layout of the exam; following the spirit of \xsim\ this
should probably be done using templates as well.
\end{itemize}
I am very open to suggestions regarding features, both in general and
specifically regarding the document class.

\section{FAQ \& How to\dots}
This section serves as a kind of gallery showing solutions to common
problems. I expect this section to grow over the years. Some examples
especially regarding other layouts are also shown in example files added to
Expand Down Expand Up @@ -1661,7 +1695,26 @@ \subsection{\dots Resolve Strange Errors After Updating?}
this is done so deleting the auxfile and doing a few fresh compilations may
resolve your problems.

\subsection{\dots Put a Star (or Other Symbol) in Exercises That Are Special?}
\subsection{\code{! TeX capacity exceeded, sorry [text input levels=15].}
Why?}
You probably tried to use an exercise or solution in a macro of some sort.
This generally will fail\footnote{The reasons are not entirely clear to me.}.
A minimal example to reproduce the problem:
\begin{sourcecode}
\documentclass{article}
\usepackage{xsim}
\begin{document}
\def\x{%
\begin{exercise}
\end{exercise}%
}\x
\end{document}
\end{sourcecode}
But there should never be the need to hide the environments inside of a macro,
anyway.

\subsection{\dots Put a Star (or Another Symbol) in Headings of Exercises That
Are Special?}

The code below shows one possible modification of an exercise template which
allows to easily create bonus exercises:
Expand Down Expand Up @@ -1708,6 +1761,57 @@ \subsection{\dots Put a Star (or Other Symbol) in Exercises That Are Special?}
\end{exercise}
\end{example}

\subsection{\dots Create and Use \xsim\ Style Files?}

\xsim\ offers you the possibility to create own \emph{style files}. Let's say
you want to have a style called \code{math-exam}. Then you need to save all
necessary definitions in a file called:
\begin{center}
\code{xsim.math-exam.code.tex}
\end{center}
The first command in the file should be \cs{xsimstyle}\Marg{math-exam}. This
file can now be loaded into your document using
\cs{loadxsimstyle}\Marg{math-exam}:
\begin{sourcecode}
\documentclass[DIV=18,parskip=half]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[clear-aux]{xsim}
\loadxsimstyle{math-exam}

\title{Math Exam \#3}
\date{2017-03-28}
\end{sourcecode}

In this style file stuff like template and property definitions should
happen. This is more or less a convenient way to
\begin{itemize}
\item keep the preamble \enquote{clean} and
\item define re-usable styles without the need of copying the document
preamble to another document.
\end{itemize}
A style file is like a package or class file, \ie, \code{@} has category
code~11 (letter).

The formal description of the commands:
\begin{commands}
\command{xsimstyle}[\sarg\marg{style name}]
The first command in a \xsim\ style file called \code{xsim.\meta{style
name}.code.tex} which defines the \xsim\ style \meta{style name}. The
starred version activates expl3 syntax\footnote{Those uses who want this
will know what it means. If you don't know what it means you will not
need it.}.
\command{loadxsimstyle}[\marg{csv list of style names}]
Load one or more styles into the document.
\end{commands}

\begin{bewareofthedog}
At the moment this mechanism offers no advantages over creating a custom
package or simply \cs*{input}ing a file. Future versions might provide
additional features.
\end{bewareofthedog}

\subsection{\dots Print All Solutions Grouped by Section?}
Here is an idea how to get a list of all solutions grouped by the section the
corresponding exercises are appearing in.
Expand Down

0 comments on commit fb8ef68

Please sign in to comment.