Skip to content

Commit

Permalink
Replace \DisplayProblem with built-in if
Browse files Browse the repository at this point in the history
  • Loading branch information
Strauman committed Mar 18, 2019
1 parent 37a4c54 commit 6ebd00b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 24 deletions.
3 changes: 2 additions & 1 deletion exercises/firstexercise.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%!TEX root = ../example.tex
\nextproblem{head=hello,solution only}
% \nextproblem{head=hello,solution only}
\begin{problem}
PROBLEM 1
\end{problem}
%% REMEMBER that \end{solution} can't have spaces in front of it and needs it's own line
\begin{solution}
Expand Down
4 changes: 2 additions & 2 deletions exercises/secondexercise.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%!TEX root = ../example.tex
\nextproblem{hide}
% \nextproblem{hide}
\begin{intro}
In this exercise, we'll be looking at \( \dots \)
2(i) In this exercise, we'll be looking at \( \dots \)
\end{intro}
\nextproblem{tag=Y, points=1}
\begin{problem}
Expand Down
4 changes: 4 additions & 0 deletions exercises/thirdexercise.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
Problem intro for thirdexercise
\end{intro}
\begin{problem}\pptag{TST}%
3,1
3rd TEST1
\end{problem}
\begin{problem}
3,2
3rd TEST2
\end{problem}
\begin{problem}
3,3
3rd TEST3
\begin{verbatim}
VERBATIMTEXT3
\end{verbatim}
\end{problem}
\begin{problem}
3,4
3rd TEST4
\end{problem}
15 changes: 7 additions & 8 deletions src/envcontrol.tex
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
% An all of their uses should be be replaced by ifs.
\gdef\isFalse{0}
\gdef\isTrue{1}
%\DisplayProblem should be prefixed ASAP!
\gdef\DisplayProblem{\isTrue}
\global\exb@DisplayCurrentProblemtrue
\gdef\@displayMetaCounter{\isFalse}

%%%% NB: Difference between \DisplaySolution and \DisplaySolutions
Expand All @@ -46,11 +45,11 @@
%
% \exb@ifshowproblem{true}{false}
\gdef\exb@ifshowproblem#1#2{%
% If \DisplayProblem==1 && exb@opthides==false, then show
% If exb@DisplayCurrentProblem==true && exb@opthides==false, then show
% Set displaying default to false
\exb@isdisplayingfalse%
% If \DisplayProblem==1
\ifnum\pdfstrcmp{\DisplayProblem}{\@isTrue}=\z@%
% If exb@DisplayCurrentProblem==true
\ifexb@DisplayCurrentProblem%
\ifexb@opthides\else\exb@isdisplayingtrue\fi\fi%
\ifexb@isdisplaying#1\else#2\fi%
}
Expand Down Expand Up @@ -92,9 +91,9 @@
\fi%
}%
% Special case: solutions only
\ifexb@solutionsonly\def\ProcessCutFile{}\if\DisplayProblem\@isTrue\relax\stepcounter{partproblemcounter}\fi\fi
\ifexb@solutionsonly\def\ProcessCutFile{}\ifexb@DisplayCurrentProblem\relax\stepcounter{partproblemcounter}\fi\fi
}{\@dinfo{Ending problem env}%
\if\DisplayProblem\@isTrue\relax%
\ifexb@DisplayCurrentProblem\relax%
\if\exbank@opt@partProblems\@isTrue\relax%\ifexb@opthides\else
\Trigger\EndPartproblem%
\tighten@paragraph\fi%
Expand All @@ -114,7 +113,7 @@
\Trigger\AtBeginSolutionHard
\begingroup
\ifexb@DisplaySolutions%
\if\DisplayProblem\isFalse%
\ifexb@DisplayCurrentProblem\isFalse%
\global\exb@DisplayCurrentSolutionfalse
\fi
\fi
Expand Down
2 changes: 1 addition & 1 deletion src/hidetags.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%!TEX root = main.tex
\def\exb@hidetaglist{}
\At\DecideProblemDisplay{
\ifnum\pdfstrcmp{\DisplayProblem}{\T@}=\z@\relax%
\ifexb@DisplayCurrentProblem\relax%
\ifx\exb@hidetaglist\relax\else
\exb@intersection@any{\exb@currentTags}{\exb@hidetaglist}{\global\exb@opthidestrue}{}%
\fi
Expand Down
1 change: 1 addition & 0 deletions src/ifs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
\global\newif\ifexb@opt@tightenparagraphs
\global\newif\ifexb@DisplaySolutions
\global\newif\ifexb@DisplayCurrentSolution
\global\newif\ifexb@DisplayCurrentProblem
5 changes: 3 additions & 2 deletions src/main.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
\documentclass{article}\makeatletter\let\ea\expandafter\let\dlog\@latex@warning\def\insp#1{\dlog{\string#1:\meaning#1}}\def\csinsp#1{\edef\mcro{\unexpanded\expandafter{\csname #1\endcsname}}\def\tmp{{\mcro}}\expandafter\insp\mcro}
\input{../exercises/mathcommands}
\input{exbankpack}
\usepackage{lipsum}

\exercisebanksetup{%
exercise directory=../exercises
Expand All @@ -10,8 +11,8 @@
%% The \exclude{setname}{1,2,3,...,9} excludes partproblems 1,...,9 from setname
\makeset{electro}{capacitance}
\makeset{first}{firstexercise}
\makeset{2}{firstexercise, \exclude{secondexercise}{1,2}, thirdexercise}
\makeset{2}{firstexercise, \exclude{secondexercise}{1,2}, \select{thirdexercise}{1,2}, \exclude{thirdexercise}{1,2}}
% \DisplaySolutions
\begin{document}
\buildset{electro}
\buildset{2}
\end{document}
19 changes: 9 additions & 10 deletions src/setbuilder.tex
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,22 @@
\let\ipm\@ifppMode
\let\T@\isTrue
\let\F@\isFalse
% \@dlog{tlist:\meaning\exb@tagList}
% \ifnum\pdfstrcmp{\exb@tagList}{\exb@emptyList}=\z@\relax
% \xdef\DisplayProblem{\ipm\exclude\T@\ipm\select\F@}\else%
% \isin{\exb@currentTags}{\exb@tagList}{}{\xdef\DisplayProblem{\F@}}%
% \fi

% Short hands for doing pp mode selection:
\def\exb@DPT{\global\exb@DisplayCurrentProblemtrue}
\def\exb@DPF{\global\exb@DisplayCurrentProblemfalse}
\At\DecideProblemDisplay{%
\ifnum\pdfstrcmp{\ppList}{\emptyList}=\z@\relax%
\xdef\DisplayProblem{\ipm\exclude\T@\ipm\select\F@}
\ipm\exclude\exb@DPT\ipm\select\exb@DPF
\fi
\exb@int@isin{\themetacounter}{\ppList}{
\xdef\DisplayProblem{\ipm\exclude\F@\ipm\select\T@\ipm\normal\T@}
\ipm\exclude\exb@DPF\ipm\select\exb@DPT\ipm\normal\exb@DPT
}{
\xdef\DisplayProblem{\ipm\exclude\T@\ipm\select\F@\ipm\normal\T@}
\ipm\exclude\exb@DPT\ipm\select\exb@DPF\ipm\normal\exb@DPT
}
\ifexb@tagbuildmode
\ifnum\pdfstrcmp{\DisplayProblem}{\T@}=\z@\relax%
\exb@intersection@any{\exb@currentTags}{\exb@tagList}{\global\exb@opthidesfalse}{\global\exb@opthidestrue\xdef\DisplayProblem{0}}%
\ifexb@DisplayCurrentProblem\relax%
\exb@intersection@any{\exb@currentTags}{\exb@tagList}{\global\exb@opthidesfalse}{\global\exb@opthidestrue\exb@DisplayCurrentProblemfalse}%
\fi
\fi
}
Expand Down

0 comments on commit 6ebd00b

Please sign in to comment.