1

I was wondering if/why it is necessary to have the extra solution for the \blank exercises, as the question already contains all the informations.

One reason for the question is, that it is extra work to copy and paste the stuff into the solution and this extra step could produce mistakes... Another reason is, that I would love to have the possibility to use the solution/exercise in two different grades.

Grade 1: only the missing words (for an answer-only-sheet), now to be written as:

\begin{solution}
\blank{a}, \blank{b}
\end{solution}

Output:

Solution 1

a,b

Grade 2 (perhaps rather a variation of the exercise than the solution): the whole text with filled blanks, now to be written as:

\begin{solution}
\blank{a} and \blank{b} are the first letters of the alphabet.
\end{solution}

Output:

Solution 1

a and b are the first letters of the alphabet.

So that I can use the filled blanks in the whole text (grade 2) for the trainers workbook where the students have the empty blanks AND additionally use the condensed solution (grade 1) for a combined only-answer-sheet of all the solutions of all exercises at the end of the workbook.

Perhaps there could be a possibility of a \printcollection[print=exercise*]{foo} that prints the exercises, but with the blanks in the filled-style.

Here a MWE, showing the possible outcome, that compiles as long as the trainer boole is false.

\documentclass{article}
\usepackage{xsim}
\usepackage{etoolbox}

\newcounter{sections}

\newbool{trainer}
%\booltrue{trainer} % if trainer version, activate


\DeclareExerciseCollection{foo}
\DeclareExerciseCollection{ba}

\begin{document}

\section{A}
\collectexercises{foo}

\begin{exercise}
 The \blank{a} is the first letter of the alphabet.
\end{exercise}
\begin{solution}
 The \blank{a} is the first letter of the alphabet.
\end{solution}
\begin{exercise}
  The \blank{b} is the second letter of the alphabet.
\end{exercise}
\begin{solution}
  The \blank{b} is the second letter of the alphabet.
\end{solution}

\collectexercisesstop{foo}

\ifbool{trainer}
{\printcollection[print=solution]{foo}} %that is how it should look in the trainers workbook, but I don't want the whole text in the collection of all solutions
{\printcollection{foo}}


\section{B}
\collectexercises{ba}

\begin{exercise}
  The \blank{z} is the last letter of the alphabet.
\end{exercise}
\begin{solution}
  \blank{z}
\end{solution}

\collectexercisesstop{ba}

\ifbool{trainer}
{\printcollection[print=exercises*]{ba}} %that is what I would like for a kind of command that it prints the filled exercise like in section A if you put the whole text in the solution - perhaps it is rather a \printcollection*[print=exercises]
{\printcollection{ba}}


\section{Answersheet} % solution to number 3 shows how all solutions should look like in the answers-only-sheet

\setcounter{sections}{1}
\whileboolexpr
{ test {\ifnumless{\value{sections}}{\value{section}+1}} }
{
 \printsolutions[section=\value{sections},headings-template=per-section]
 \stepcounter{sections}
 }

\end{document}
  • Where is the difficulty to make an (non-working) minimal example that other can at least compile directly and then perhaps improve? – Ulrike Fischer Sep 5 '17 at 17:58
  • You probably could use the method described here: tex.stackexchange.com/questions/380959/… – clemens Sep 6 '17 at 8:19
  • @clemens yes, that would be the the backup solution, but it isn't yet what I would like. And I really think that it would be a great feature for '\blank' of the xsim package, if it would be possible to just reuse the exercise instead of printing an extra solution and using the extra solution only if you don't want the whole text written. – acep Sep 6 '17 at 11:22
2

If I understand the question correctly the following should be a way to go. The code below implements a blank/fill option (which will be added to the next release of xsim):

\documentclass{article}
\usepackage{xsim}

\ExplSyntaxOn
\bool_new:N \l__xsim_fill_blank_bool

\keys_define:nn {xsim/blank}
  {
    fill .bool_set:N = \l__xsim_fill_blank_bool ,
    fill .initial:n  = false
  }

\cs_set_protected:Npn \xsim_blank:n #1
  {
    \box_clear:N \l__xsim_blank_box
    \mode_if_math:TF
      { \hbox_set:Nn \l__xsim_blank_box { $ \m@th \mathpalette{}{#1} $ } }
      { \hbox_set:Nn \l__xsim_blank_box {#1} }
    \bool_if:nTF
      { \xsim_if_inside_solution_p: || \l__xsim_fill_blank_bool }
      { \xsim_write_cloze_filled:n {#1} }
      {
        \bool_if:NTF \l__xsim_blank_width_bool
          { \__xsim_blank_skip:V \l__xsim_blank_dim }
          { \__xsim_blank_skip:n { \box_wd:N \l__xsim_blank_box } }
      }
  }
\ExplSyntaxOff

\begin{document}

\begin{exercise}
  This is \blank{a} and \blank{b}.
\end{exercise}

\xsimsetup{blank/fill=true}
\printexercise{exercise}{1}

\end{document}

enter image description here

This should work with collections as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.