summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/schule/latex/schule.mod.Aufgabenpool.code.tex
blob: 33579f61b4397f44f07bc5718f8d8a8568a77660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
\ExplSyntaxOn

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Optionen für den Aufgabenpool
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clist_new:N \g__schule_aufgabenoptionen_clist

\DeclareDocumentCommand{\ifAufgabenpoolOptionTF}{m +m +m}{
    \clist_if_in:NnTF \g__schule_aufgabenoptionen_clist {#1} {#2} {#3}
}

\DeclareDocumentCommand{\ifAufgabenpoolOptionT}{m +m}{
    \clist_if_in:NnT \g__schule_aufgabenoptionen_clist {#1} {#2}
}

\DeclareDocumentCommand{\ifAufgabenpoolOptionF}{m +m}{
    \clist_if_in:NnF \g__schule_aufgabenoptionen_clist {#1} {#2}
}

\DeclareExerciseProperty-{poolOptionen}

\DeclareDocumentCommand{\setAufgabenpoolOptionen}{m}{
    \clist_set:Nn \g__schule_aufgabenoptionen_clist {#1}%
}

\DeclareDocumentCommand{\set@AufgabenpoolOptionen@Property}{}{
    \exp_args:Nnf\SetExerciseProperty{poolOptionen}{\clist_use:Nn \g__schule_aufgabenoptionen_clist {,}}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Basedir Elemente
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\str_new:N \g__schule_basedir_string
\str_gset:Nn \g__schule_basedir_string {.}

\DeclareExerciseProperty-{basedir}

\DeclareDocumentCommand{\setBasedir}{}{
    \exp_args:Nnf\SetExerciseProperty{basedir}{\str_use:N \g__schule_basedir_string}%
}

\DeclareDocumentCommand{\getBasedir}{}{
    \str_use:N \g__schule_basedir_string
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Aufgabenhinweise
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bool_new:N \g__schule_inAufgabenInput_bool
\bool_gset_false:N \g__schule_inAufgabenInput_bool
\NewDocumentEnvironment{aufgabenpoolHinweis}{+b}{
     \bool_if:NF \g__schule_inAufgabenInput_bool {#1}
}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Aufgabeneinbindung
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\aufgabeninput}{o m m}{
    \bool_gset_true:N \g__schule_inAufgabenInput_bool
    \str_gset:Nn \g__schule_basedir_string {#2}
    \clist_set:Nn \g__schule_aufgabenoptionen_clist {#1}
    \input{#2/#3}
    \bool_gset_false:N \g__schule_inAufgabenInput_bool
}

\xsimsetup{
  aufgabe/begin-hook = \setBasedir\set@AufgabenpoolOptionen@Property,
  loesung/begin-hook = \clist_set:Nx \g__schule_aufgabenoptionen_clist {\GetExerciseProperty{poolOptionen}} \str_gset:Nx \g__schule_basedir_string {\GetExerciseProperty{basedir}},
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% InputOnce
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clist_new:N \g__schule_inputonce_clist
\clist_new:N \g__schule_inputonceAppendix_clist
\prop_new:N \g__schule_appendix_prop
\prop_new:N \g__schule_appendixBasedir_prop

\DeclareDocumentCommand{\inputOnce}{m}{
    \clist_if_in:NnF \g__schule_inputonce_clist {#1} {
        \clist_gput_right:Nn \g__schule_inputonce_clist {#1}
        \input{\getBasedir/#1}
    }
}

\DeclareDocumentCommand{\inputOnceAppendix}{m}{
    \exp_args:Nnf \clist_if_in:NnF {\g__schule_inputonceAppendix_clist} {\getBasedir/#1} {
        \exp_args:Nnf \clist_gput_right:Nx {\g__schule_inputonceAppendix_clist} {\getBasedir/#1}
        \bool_if:NF \g__schule_inAufgabenInput_bool {\input{\getBasedir/#1}}
    }
}

\DeclareDocumentCommand{\showIncludeAppendix}{}{
    \clist_map_inline:Nn \g__schule_inputonceAppendix_clist {
        \input{##1}
    }
    \prop_map_inline:Nn \g__schule_appendix_prop {
        \exp_args:Nnf \str_gset:Nn \g__schule_basedir_string {\prop_item:Nn \g__schule_appendixBasedir_prop {##1}}
        ##2
    }
}

\NewDocumentEnvironment{onceAppendix}{m +b}{
    \prop_gput:Nnn \g__schule_appendix_prop {#1} {#2}
    \exp_args:Nnnf \prop_gput:Nnn {\g__schule_appendixBasedir_prop} {#1} {\getBasedir}
    \bool_if:NF \g__schule_inAufgabenInput_bool {
        #2
    }
}{}

\ExplSyntaxOff