Debian Codegraph @

texmf-dist/doc/latex/xsim/examples/xsim.various.tex

raw
1 \documentclass{article}
2 \usepackage[use-files]{xsim}
3 \usepackage{lipsum,tcolorbox}
4
5 \DeclareExerciseType{question}{
6 exercise-env = question ,
7 solution-env = hint ,
8 exercise-name = Question ,
9 solution-name = Hint ,
10 exercise-template = default ,
11 solution-template = default ,
12 counter = exercise % shares a counter with the `exercise' type
13 }
14
15 \DeclareExerciseType{problem}{
16 exercise-env = problem ,
17 solution-env = answer ,
18 exercise-name = Problem ,
19 solution-name = Answer ,
20 exercise-template = tcolorbox ,
21 solution-template = tcolorbox
22 }
23
24 \DeclareExerciseProperty{grade}
25 \DeclareExerciseProperty{difficulty}
26
27 \tcbuselibrary{breakable}
28 \DeclareExerciseEnvironmentTemplate{tcolorbox}
29 {%
30 \newcommand*\writehere{%
31 \IfInsideSolutionTF{}{%
32 \tcblower
33 \emph{Your answer:}
34 \vspace*{4cm}
35 }%
36 }
37 \vspace{\baselineskip}
38 \tcolorbox[
39 colback = red!5!white ,
40 colframe = red!75!black ,
41 colbacktitle = yellow!50!red ,
42 coltitle = red!25!black ,
43 fonttitle = \bfseries ,
44 subtitle style = {
45 boxrule = 0.4pt ,
46 colback = yellow!50!red!25!white
47 } ,
48 breakable ,
49 title = \GetExerciseName~\GetExerciseProperty{counter}
50 \IfExercisePropertySetT{points}{%
51 (\GetExerciseProperty{points}
52 \IfExerciseGoalSingularTF{points}
53 {\XSIMtranslate{point}}
54 {\XSIMtranslate{points}})%
55 }]
56 \IfInsideSolutionF{%
57 \IfExercisePropertySetT{tags}{%
58 Tags: \ListExerciseTags{tags}{, } \par
59 }%
60 }%
61 }
62 {%
63 \endtcolorbox
64 \vspace{\baselineskip}
65 }
66
67 \xsimsetup{
68 % tags = {geometry} ,
69 % topics = {geometry}
70 % tags/ingore-untagged % if true untagged exercise will be printed regardless
71 % % which tags have been chosen
72 }
73
74 \begin{document}
75
76 \gradingtable \par \bigskip
77
78 Total: \printtotalpoints \par
79 from questions: \printpoints{question} \par
80 from exercises: \printpoints{exercise} \par
81 from problems: \printpoints{problem} \par \bigskip
82
83 Total bonus: \printtotalbonus \par
84 from questions: \printbonus{question} \par
85 from exercises: \printbonus{exercise} \par
86 from problems: \printbonus{problem} \par
87
88 % 1
89 \begin{exercise}[points=4,bonus-points=1,topics=geometry,tags={geometry,triangles},grade=7]
90 \lipsum[1]
91 \begin{verbatim}
92 foo x^2 y^3 \gna
93 \end{verbatim}
94 \end{exercise}
95 \begin{solution}[print]
96 This is the solution to \ExerciseType\ \GetExerciseProperty{counter}.
97 \begin{verbatim}
98 foo x^2 y^3 \gna
99 \end{verbatim}
100 \end{solution}
101
102 % 2
103 \begin{exercise}[subtitle=Foo,points=5,topics=analysis,tags={analysis,functions},grade=11]
104 \lipsum[2]
105 \end{exercise}
106 \begin{solution}
107 This is the solution to \ExerciseType\ \GetExerciseProperty{counter}.
108 \end{solution}
109
110 % 3
111 \begin{problem}[tags={analysis,functions}]
112 \lipsum[3]
113 \writehere
114 \end{problem}
115 \begin{answer}
116 This is the solution to \ExerciseType\ \GetExerciseProperty{counter}.
117 \end{answer}
118
119 % 4
120 \begin{question}
121 \lipsum[4]
122
123 \verb+\ExerciseID+: \GetExerciseAliasProperty{ID}
124
125 \verb+\GetExerciseProperty{id}+: \GetExerciseProperty{id}
126
127 \verb+\GetExerciseAliasProperty{ID}+: \GetExerciseAliasProperty{ID}
128
129 \verb+\GetExerciseProperty{ID}+: \GetExerciseProperty{ID}
130 \end{question}
131 \begin{hint}
132 This is the solution to \ExerciseType\ \GetExerciseProperty{counter}.
133 \end{hint}
134
135 % 5
136 \begin{problem}[points=2]
137 \lipsum[3]
138
139 \verb+\ExerciseID+: \GetExerciseAliasProperty{ID}
140
141 \verb+\GetExerciseProperty{id}+: \GetExerciseProperty{id}
142
143 \verb+\GetExerciseAliasProperty{ID}+: \GetExerciseAliasProperty{ID}
144
145 \verb+\GetExerciseProperty{ID}+: \GetExerciseProperty{ID}
146 \writehere
147 \end{problem}
148 \begin{answer}
149 This is the solution to \ExerciseType\ \GetExerciseProperty{counter}.
150 \end{answer}
151
152 % 6
153 \begin{problem}[points=1]
154 \lipsum[3]
155
156 \verb+\ExerciseID+: \GetExerciseAliasProperty{ID}
157
158 \verb+\GetExerciseProperty{id}+: \GetExerciseProperty{id}
159
160 \verb+\GetExerciseAliasProperty{ID}+: \GetExerciseAliasProperty{ID}
161
162 \verb+\GetExerciseProperty{ID}+: \GetExerciseProperty{ID}
163 \end{problem}
164 \begin{answer}
165 This is the solution to \ExerciseType\ \GetExerciseProperty{counter}.
166 \end{answer}
167
168 % 7
169 \begin{exercise}[ID=test]
170 \lipsum[5]
171
172 \verb+\ExerciseID+: \GetExerciseAliasProperty{ID}
173
174 \verb+\GetExerciseProperty{id}+: \GetExerciseProperty{id}
175
176 \verb+\GetExerciseAliasProperty{ID}+: \GetExerciseAliasProperty{ID}
177
178 \verb+\GetExerciseProperty{ID}+: \GetExerciseProperty{ID}
179 \end{exercise}
180 \begin{solution}
181 This is the solution to \ExerciseType\ \GetExerciseProperty{counter}.
182 \end{solution}
183
184 % 8
185 \begin{exercise}[print=false,use=false]
186 \lipsum[5]
187 \end{exercise}
188 \begin{solution}
189 This is the solution to \ExerciseType\ \GetExerciseProperty{counter}.
190 \end{solution}
191
192 % \printsolutionstype{exercise}
193
194 \printsolutions*
195
196 \section{Statistics}
197
198 \ForEachUsedExerciseByType{%
199 \noindent\XSIMmixedcase{\ExerciseParameterGet{#1}{exercise-name}}~#3: \\
200 \hspace*{2em}id: #2, type: #1, subtitle: #4, points: #5, bonus: #6\par \medskip
201 }
202
203 \bigskip
204
205 \ForEachUsedExerciseByID{%
206 \noindent\XSIMmixedcase{\ExerciseParameterGet{#1}{exercise-name}}~#3: \\
207 \hspace*{2em}id: #2, type: #1, subtitle: #4, points: #5, bonus: #6\par \medskip
208 }
209
210 \bigskip
211
212 \ForEachUsedExerciseByType{%
213 \ExercisePropertyIfSetT{#1}{#2}{points}
214 { \XSIMmixedcase{\ExerciseParameterGet{#1}{exercise-name}}~#3: #5~points\par }%
215 }
216
217 \bigskip
218
219 Number of questions: \numberofquestions \par
220 Number of exercises: \numberofexercises \par
221 Number of problems: \numberofproblems
222
223 \section{Grading tables}
224
225 \gradingtable[template=default*,type=exercise] \par \bigskip
226
227 \gradingtable[template=default*,type=problem] \par \bigskip
228
229 \gradingtable[template=default*] \par \bigskip
230
231 % vertical
232 \gradingtable[type=exercise] \par \bigskip
233
234 \gradingtable[type=problem] \par \bigskip
235
236 \gradingtable
237
238 \end{document}