Debian Codegraph @

texmf-dist/source/latex/competences/competences.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2016 by Christophe Bares <christopheATbares.fr>
4 % -------------------------------------------------------------
5 %
6 % This file may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in:
10 %
11 % http://www.latex-project.org/lppl.txt
12 %
13 % and version 1.3 or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % \fi
17 %
18 % \iffalse
19 %<*driver>
20 \ProvidesFile{competences.dtx}
21 %</driver>
22 %<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
23 %<package>\ProvidesPackage{competences}
24 %<*package>
25 [2016/10/27 v1.0]
26 %</package>
27 %
28 %<*driver>
29 \documentclass{ltxdoc}
30 \usepackage{competences}[2016/10/27]
31 \EnableCrossrefs
32 \CodelineIndex
33 \RecordChanges
34 \begin{document}
35 \DocInput{competences.dtx}
36 \PrintChanges
37 \PrintIndex
38 \end{document}
39 %</driver>
40 % \fi
41 %
42 % \CheckSum{0}
43 %
44 % \CharacterTable
45 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
46 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
47 % Digits \0\1\2\3\4\5\6\7\8\9
48 % Exclamation \! Double quote \" Hash (number) \#
49 % Dollar \$ Percent \% Ampersand \&
50 % Acute accent \' Left paren \( Right paren \)
51 % Asterisk \* Plus \+ Comma \,
52 % Minus \- Point \. Solidus \/
53 % Colon \: Semicolon \; Less than \<
54 % Equals \= Greater than \> Question mark \?
55 % Commercial at \@ Left bracket \[ Backslash \\
56 % Right bracket \] Circumflex \^ Underscore \_
57 % Grave accent \` Left brace \{ Vertical bar \|
58 % Right brace \} Tilde \~}
59 %
60 %
61 % \changes{v0.1}{2016/06/26}{Initial version}
62 % \changes{v1.0}{2016/10/27}{First functional version}
63 %
64 % \GetFileInfo{competences.dtx}
65 %
66 % \DoNotIndex{\newcommand,\newenvironment}
67 %
68 %
69 % \title{The \textsf{competences} package\thanks{This document
70 % corresponds to \textsf{competences}~\fileversion, dated \filedate.}}
71 % \author{Christophe Bares\\ \texttt{<christopheATbares.fr>}}
72 %
73 % \maketitle
74 %
75 % \section{Introduction}
76 %
77 % This package is a attempt to
78 %
79 % \section{Usage}
80 %
81 %
82 % \DescribeMacro{\declareprefix}
83 % This macro declares a new prefix as competence tag
84 % \index{declareprefix|usage}. This macro takes the prefix you want
85 % to declare as unique argument.
86 %
87 % This prefix will be use in sumup table. If you want to declare several
88 % prefixes, use this macro for each prefix.
89
90
91 % \DescribeEnv{dummyEnv}
92 % This environment does nothing. It is merely an example.
93 % If this were a real environment, you would put a paragraph here
94 % describing what the environment is supposed to do, what its
95 % mandatory and optional arguments are, and so forth.
96 %
97 % \StopEventually{}
98 %
99 % \section{Implementation}
100 %
101 % \begin{macro}{\dummyMacro}
102 % This is a dummy macro. If it did anything, we'd describe its
103 % implementation here.
104 % \begin{macrocode}
105 \newcommand{\dummyMacro}{}
106
107
108 % \end{macrocode}
109 % \end{macro}
110 %
111 % \begin{environment}{dummyEnv}
112 % This is a dummy environment. If it did anything, we'd describe its
113 % implementation here.
114 % \begin{macrocode}
115 \newenvironment{dummyEnv}{%
116 }{%
117 % \end{macrocode}
118 % \changes{v1.0a}{2004/11/05}{Added a spurious change log entry to
119 % show what a change \emph{within} an environment definition looks
120 % like.}
121 % Don't use |%| to introduce a code comment within a |macrocode|
122 % environment. Instead, you should typeset all of your comments with
123 % \LaTeX---doing so gives much prettier results. For comments within a
124 % macro/environment body, just do an |\end{macrocode}|, include some
125 % commentary, and do another |\begin{macrocode}|. It's that simple.
126 % \begin{macrocode}
127 }
128 % \end{macrocode}
129 % \end{environment}
130 %
131
132 % \iffalse
133 %<*package>
134 \RequirePackage[%
135 color=blue!20,%
136 ]{todonotes}
137 \reversemarginpar
138
139 \RequirePackage{datatool}
140 \RequirePackage{etoolbox}
141 \RequirePackage{longtable}
142
143 \def\total{0}
144 \def\gtotal{0}
145
146
147 \newcommand{\getCurrentSectionNumber}{%
148 \ifnum\c@enumi=0 %
149 \ifnum\c@section=0 %
150 \thechapter
151 \else
152 \ifnum\c@subsection=0 %
153 \thesection
154 \else
155 \ifnum\c@subsubsection=0 %
156 \thesubsection
157 \else
158 \thesubsubsection
159 \fi
160 \fi
161 \fi
162 \else
163 \ifnum\c@enumii=0 %
164 \theenumi
165 \else
166 \theenumii
167 \fi
168 \fi
169 }
170
171 %</package>
172 \newcommand{\getCurrentpartiedocument}{%
173 \thesection
174 }
175 %<*package>
176
177 \DTLgnewdb{CS}
178 \DTLgnewdb{QUEST}
179 \DTLgnewdb{PARTIE}
180 \DTLgnewdb{PF}
181 \DTLaddcolumn{QUEST}{compsec}%
182 \DTLaddcolumn{QUEST}{partie}%
183
184 % Is Competence already in DB?
185 \newcommand{\ifcompexists}[3]{%
186 \DTLgetrowforkey{\competences@tmpcs}{CS}{cs}{#1}%
187 \ifdefempty{\competences@tmpcs}{#3}{#2}%
188 }
189
190 % Is Question already in DB?
191 \newcommand{\ifquestexists}[3]{%
192 \DTLgetrowforkey{\competences@tmpq}{QUEST}{compsec}{#1}%
193 \ifdefempty{\competences@tmpq}{#3}{#2}%
194 }
195
196 % Is Part already in DB?
197 \newcommand{\ifpartexists}[3]{%
198 \DTLgetrowforkey{\competences@tmpp}{PARTIE}{partie}{#1}%
199 \ifdefempty{\competences@tmpp}{#3}{#2}%
200 }
201
202
203 \newcommand{\addcompetence}[2][1]{%
204 \todo[noline]{#2}
205
206
207 \ifcompexists{#2}{%
208 }
209 {\DTLnewrow{CS}%
210 \DTLnewdbentry{CS}{cs}{#2}%
211 \DTLaddcolumn{QUEST}{#2}%
212 }
213 \def\quest{\getCurrentSectionNumber}
214 \def\partie{\getCurrentpartiedocument}
215
216 \ifpartexists{\partie}{}{
217 \DTLnewrow{PARTIE}%
218 \dtlexpandnewvalue
219 \DTLnewdbentry{PARTIE}{partie}{\partie}%
220 \dtlnoexpandnewvalue
221 }
222
223 \ifquestexists{\quest}{%
224 \DTLnewdbentry{QUEST}{#2}{#1}%
225 }{%
226 \DTLforeach*{CS}{\cs=cs}{
227 \DTLaddcolumn{QUEST}{\cs}%
228 }%
229
230 \DTLnewrow{QUEST}%
231 \dtlexpandnewvalue
232 \DTLnewdbentry{QUEST}{compsec}{\quest}%
233 \DTLnewdbentry{QUEST}{partie}{\partie}%
234 \dtlnoexpandnewvalue
235 \DTLnewdbentry{QUEST}{#2}{#1}%
236 }
237 }
238
239 \newcommand{\addGlobalCompetence}[2][1]{%
240 \ifcompexists{#2}{%
241 }{%
242 \DTLnewrow{CS}%
243 \DTLnewdbentry{CS}{cs}{#2}%
244 \DTLaddcolumn{QUEST}{#2}%
245 }
246
247 \def\quest{-}
248 \def\partie{Global}
249
250 \ifpartexists{\partie}{%
251 }{%
252 \DTLnewrow{PARTIE}%
253 \dtlexpandnewvalue
254 \DTLnewdbentry{PARTIE}{partie}{\partie}%
255 \dtlnoexpandnewvalue
256 }
257
258 \ifquestexists{\quest}{%
259 \DTLnewdbentry{QUEST}{#2}{#1}%
260 }{%
261 \DTLforeach*{CS}{\cs=cs}{
262 \DTLaddcolumn{QUEST}{\cs}%
263 }%
264
265 \DTLnewrow{QUEST}%
266 \dtlexpandnewvalue
267 \DTLnewdbentry{QUEST}{compsec}{\quest}%
268 \DTLnewdbentry{QUEST}{partie}{\partie}%
269 \dtlnoexpandnewvalue
270 \DTLnewdbentry{QUEST}{#2}{#1}%
271 }
272 }
273
274
275 \newcommand{\tableaucompetences}{%
276 Ce sujet aborde \DTLrowcount{CS}\ compétences: \DTLforeach*{CS}{\compname=cs}{\compname\DTLiflastrow{.}{, }}
277 \bigskip
278
279
280 \begin{longtable}{l|c|*{\DTLrowcount{CS}}{|c}||c}
281 Question &Partie& \DTLforeach*{CS}{\cs=cs}{\cs &} points\\\hline
282 \DTLforeach*{QUEST}{\compsec=compsec,\partie=partie}{
283 \DTLforeachkeyinrow{\point}
284 {\DTLifstringeq{\point}{NULL}{}{
285 \point%
286 \DTLifstringeq{\dtlkey}{compsec}{}{%
287 \DTLifstringeq{\dtlkey}{partie}{}{%
288 \DTLgadd{\total}{\point}{\total}%
289 }%
290 }%
291 } & %
292 }
293 \total
294 \DTLgadd{\gtotal}{\total}{\gtotal}
295 \DTLgadd{\total}{0}{0}
296 \DTLiflastrow{\\\hline}{\\}%
297 }%
298 Total &-&\DTLforeach*{CS}{\cs=cs}{\DTLsumforkeys{QUEST}{\cs}{\total} \total&} \gtotal\\\hline
299 & & \DTLforeach*{CS}{\cs=cs}{\cs &}
300 \end{longtable}
301
302 %% For debugging
303 % \DTLdisplaylongdb{CS}
304 % \DTLdisplaylongdb{PARTIE}
305 % \DTLdisplaylongdb{QUEST}
306
307 }
308 %<*package>
309 \def\cstotal{0}%
310 %</package>
311 \newcommand{\sumcspartie}[2]{%
312 \DTLgadd{\cstotal}{0}{0}%
313 \DTLforeach*[\DTLiseq{\part}{#1}]{QUEST}{\comp=#2,\part=partie}{%
314 \DTLifnull{\comp}{}{\DTLgadd{\cstotal}{\cstotal}{\comp}}%
315 }%
316 % \cstotal
317 }
318
319
320
321 \newcommand{\tableaupartie}[1]{%
322 \def\ptotal{0}
323 \def\pctotal{0}
324 \def\gptotal{0}
325 Bilan Partie #1
326 \begin{longtable}{l|c|*{\DTLrowcount{CS}}{|c}||c}%
327 Question &Partie& \DTLforeach*{CS}{\cs=cs}{\cs &} points\\\hline
328 \DTLforeach*[\DTLiseq{\partie}{#1}]{QUEST}{\compsec=compsec,\partie=partie}{%
329 \DTLforeachkeyinrow{\point}%
330 {\DTLifstringeq{\point}{NULL}{}{%
331 \point%
332 \DTLifstringeq{\dtlkey}{compsec}{}{%
333 \DTLifstringeq{\dtlkey}{partie}{}{%
334 \DTLgadd{\ptotal}{\point}{\ptotal}%
335 }%
336 }%
337 }&%
338 }%
339 \ptotal%
340 \DTLgadd{\gptotal}{\ptotal}{\gptotal}%
341 \DTLgadd{\ptotal}{0}{0}%
342 \\\hline%
343 }%
344 Total &-&\DTLforeach*{CS}{\cs=cs}{%
345 \sumcspartie{#1}{\cs}%
346 \cstotal
347 &
348 }%
349 \gptotal\\\hline
350 Total \% &-&\DTLforeach*{CS}{\cs=cs}{%
351 \sumcspartie{#1}{\cs}
352 \DTLdiv{\pctotal}{\cstotal}{\gptotal}%
353 \DTLmul{\pctotal}{100}{\pctotal}%
354 \DTLround{\pctotal}{\pctotal}{1}%
355 \pctotal \%&%
356 }%
357 100.0\%\\\hline
358 & & \DTLforeach*{CS}{\cs=cs}{\cs &}
359 \end{longtable}
360
361 %% For debugging
362 % \DTLdisplaylongdb{CS}
363 % \DTLdisplaylongdb{QUEST}
364 % \DTLdisplaylongdb{PARTIE}
365 }
366
367 \def\pftotal{0}
368 \newcommand{\sumpfpartie}[2]{%
369 \DTLgadd{\pftotal}{0}{0}%
370 \DTLforeach*[\DTLisinlist{\partiein}{#1}]{QUEST}{\compsec=compsec,\partiein=partie}{%
371 \DTLforeachkeyinrow{\point}{%
372 \DTLifstringeq{\point}{NULL}{}{%
373 \DTLifstringeq{\dtlkey}{compsec}{}{%
374 \DTLifstringeq{\dtlkey}{partie}{}{%
375 \DTLifStartsWith{\dtlkey}{#2}{%
376 \DTLgadd{\pftotal}{\pftotal}{\point}%
377 }{}%
378 }%
379 }%
380 }%
381 }%
382 }%
383 }%
384
385
386
387 \newcommand{\tableauprefix}[1]{%
388 \begin{center}
389 \begin{tabular}{|c|*{\DTLrowcount{PF}}{|c}||c|}\hline%
390 Partie & \DTLforeach*{PF}{\pf=pf}{\pf &} Total\\\hline
391 \DTLforeach*[\DTLisinlist{\partie}{#1}]{PARTIE}{\partie=partie}{%
392 \partie &
393 \DTLgadd{\gptotal}{0}{0}%
394 \DTLforeach*{PF}{\pf=pf}{%
395 \sumpfpartie{\partie}{\pf}%
396 \pftotal
397 \DTLgadd{\gptotal}{\pftotal}{\gptotal}%
398 \DTLgadd{\pftotal}{0}{0}%
399 &
400 }%
401 \gptotal\\
402 &
403 \DTLforeach*{PF}{\pf=pf}{%
404 \sumpfpartie{\partie}{\pf}%
405 \DTLdiv{\pctotal}{\pftotal}{\gptotal}%
406 \DTLmul{\pctotal}{100}{\pctotal}%
407 \DTLround{\pctotal}{\pctotal}{1}%
408 \pctotal \%%
409 \DTLgadd{\pftotal}{0}{0}%
410 &
411 }%
412 \\\hline
413 }%
414 Total &
415 \DTLgadd{\gptotal}{0}{0}%
416 \DTLforeach*{PF}{\pf=pf}{%
417 \sumpfpartie{#1}{\pf}%
418 \pftotal
419 \DTLgadd{\gptotal}{\pftotal}{\gptotal}%
420 \DTLgadd{\pftotal}{0}{0}%
421 &
422 }%
423 \gptotal\\
424 &%
425 \DTLforeach*{PF}{\pf=pf}{%
426 \sumpfpartie{#1}{\pf}%
427 \DTLdiv{\pctotal}{\pftotal}{\gptotal}%
428 \DTLmul{\pctotal}{100}{\pctotal}%
429 \DTLround{\pctotal}{\pctotal}{1}%
430 \pctotal \%%
431 \DTLgadd{\pftotal}{0}{0}%
432 &
433 }%
434 100\%\\\hline
435 \end{tabular}
436 \end{center}
437 }%
438
439 % preremplissage de la BdD CS
440 \newcommand{\declarecompetence}[1]{%
441 \DTLnewrow{CS}%
442 \DTLnewdbentry{CS}{cs}{#1}%
443 }
444
445 % preremplissage de la BdD PF
446 \newcommand{\declareprefix}[1]{%
447 \DTLnewrow{PF}%
448 \DTLnewdbentry{PF}{pf}{#1}%
449 }
450
451 %</package>
452 % \fi
453
454 % \iffalse meta-comment
455 %
456 % \RequirePackage{pgfkeys,pgffor}
457 %
458 % \newcounter{mainargs}
459 % \pgfkeys{mainargs/.is family, mainargs,
460 % step counter/.code=\stepcounter{mainargs},
461 % add argument/.style={step counter, arg\themainargs/.initial={#1}},
462 % }
463 %
464 % \newcommand{\listecompetences}[2][]{%
465 % \setcounter{mainargs}{0}%
466 % \pgfkeys{mainargs, add argument/.list={#2}}%
467 % %
468 % \foreach \n in {1,...,\themainargs}{%
469 % \DTLnewrow{CS}%
470 % \DTLnewdbentry{CS}{cs}{\pgfkeysvalueof{/mainargs/arg\n}}%
471 % % \pgfkeysvalueof{/mainargs/arg\n},
472 % }%
473 %
474 % }
475 % \fi
476
477
478 % \Finale
479 \endinput