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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
%D \module
%D [ file=m-educat,
%D version=2003.03.05,
%D title=\CONTEXT\ Extra Modules,
%D subtitle=Educational Extras,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
%D This module will collect a few macros cq.\ definitions
%D meant for educational use. Most of the code has been laying
%D around for some time and has been (or is still) used in
%D \PRAGMA\ projects.
\unprotect
\startvariables dutch english
german czech
italian romanian
answerarea: antwoordgebied answerarea
answerarea answerarea
answerarea answerarea
\stopvariables
\startelements dutch english
german czech
italian romanian
answerspace: antwoordruimte answerspace
answerspace answerspace
answerspace answerspace
answerlines: antwoordregels answerlines
answerlines answerlines
answerlines answerlines
\stopelements
\startcommands dutch english
german czech
italian romanian
setupanswerarea: stelantwoordgebiedin setupanswerarea
setupanswerarea setupanswerarea
setupanswerarea setupanswerarea
\stopcommands
\definesystemvariable{iv}
\definecolor [answerareacolor] [s=.90]
\definecolor [answerlinecolor] [white]
\definetextbackground
[\v!answerarea]
[\c!location=\v!text,
\c!n=0,
\c!frame=\v!off,
\c!framecolor=answerlinecolor,
\c!rulethickness=2pt,
\c!background=\v!color,
\c!backgroundcolor=answerareacolor,
\c!alternative=2] % betweenline
% n=gedwongen
% m=extra auto
\def\setupanswerarea
{\setuptextbackground[\v!answerarea]}
\setvalue\e!answerspace
{\dosingleempty\doanswerspace}
\def\doanswerspace[#1]%
{\begingroup
\dontcomplain
\setupanswerarea
[\c!n=0,\c!m=,#1,\c!location=\v!text]%
\doifelsenothing{\backgroundvariable\c!m}
{\expandafter\donoanswerspace}
{\expandafter\dodoanswerspace}%
[#1]}
\def\donoanswerspace[#1]#2%
{\setupthinrules
[\c!alternative=\backgroundvariable\c!alternative,
\c!color=\backgroundvariable\c!framecolor,
\c!background=\backgroundvariable\c!background,
\c!backgroundcolor=\backgroundvariable\c!backgroundcolor,
\c!rulethickness=\backgroundvariable\c!rulethickness]%
\doifelse{\backgroundvariable\c!n}{*}
{\thinrule
\par}
{\scratchcounter0\backgroundvariable\c!n\relax
% tricky, guess
\def\processisolatedword##1%
{\setbox\scratchbox=\hbox{##1}%
\vbox{\hsize\wd\scratchbox\thinrule
\ifcase\scratchcounter\else
\setbox\scratchbox=\hbox{\space}%
\nobreak\hskip\zeropoint \!!minus \wd\scratchbox
\vbox{\hsize\wd\scratchbox\thinrule}%
\fi}}%
\processisolatedwords{#2}\processisolatedword
% so far
\ifcase\scratchcounter \else \ifnum\scratchcounter<3
\nobreak \vbox{\hsize\scratchcounter em\thinrule}%
\else % more
\advance \scratchcounter -2
\dorecurse\scratchcounter{\allowbreak\vbox{\hsize1em\thinrule}}%
\nobreak \vbox{\hsize2em\thinrule}%
\fi \fi}%
\endgroup}
\def\dodoanswerspace[#1]#2% m case
{\getvalue{\e!start\v!answerarea}%
#2%
\doifelse{\backgroundvariable\c!m}{*}
{\hfill\strut
\getvalue{\e!stop\v!answerarea}%
\par}
{\scratchcounter0\backgroundvariable\c!m\relax
\ifcase\scratchcounter \else \ifnum\scratchcounter<3
\nobreak \hbox to \scratchcounter em{\strut\hss}%
\else % more
\advance \scratchcounter -2
\dorecurse\scratchcounter{\allowbreak\hbox to 1em{\strut\hss}}%
\nobreak \hbox to 2em{\strut\hss}%
\fi \fi
\getvalue{\e!stop\v!answerarea}}%
\endgroup}
\setvalue{\e!start\e!answerlines}%
{\dosingleempty\dostartanswerlines}
\def\dostartanswerlines[#1]%
{\begingroup
\dontcomplain
\setupanswerarea
[\c!n=0,\c!m=,#1,\c!location=\v!text]%
\doifnot{\backgroundvariable\c!option}\v!joinedup\softbreak
\doifelsenothing{\backgroundvariable\c!m}
{\expandafter\donostartanswerlines}
{\expandafter\dodostartanswerlines}%
[#1]}
\def\donostartanswerlines[#1]%
{\setupthinrules
[\c!alternative=\backgroundvariable\c!alternative,
\c!color=\backgroundvariable\c!framecolor,
\c!background=\backgroundvariable\c!background,
\c!backgroundcolor=\backgroundvariable\c!backgroundcolor,
\c!rulethickness=\backgroundvariable\c!rulethickness]%
\thinrules[\c!n=\backgroundvariable\c!n]\par
\endgroup
\grabuntil{\e!stop\e!answerlines}}
\def\dodostartanswerlines[#1]%
{\begingroup
\getvalue{\e!start\v!answerarea}%
\ignorespaces}
\setvalue{\e!stop\e!answerlines}%
{\scratchcounter0\backgroundvariable\c!m\relax
% a \softbreak is more efficient in pos dan \par
\ifcase\scratchcounter
% nothing
\or
\softbreak
\else
\softbreak
\advance \scratchcounter \minusone
\dorecurse\scratchcounter{\strut\hfill\strut\softbreak}%
\fi
\strut\hfill\strut
\getvalue{\e!stop\v!answerarea}%
\par\endgroup\endgroup}
\setvalue\e!answerlines
{\dosingleempty\doanswerlines}
\def\doanswerlines[#1]#2%
{\getvalue{\e!start\e!answerlines}[#1]%
#2%
\getvalue{\e!stop\e!answerlines}}
\protect \doifnotmode{demo}{\endinput}
%D Test materiaal.
\starttext
\startnotmode[answers]
\setupanswerarea[level=+1]
\stopnotmode
\setupcolors[state=start]
test test test \answerspace [n=10] {Whow}. test test test
test tets test test \answerspace [n=10] {Whow}. test test
test test tets test test \answerspace [n=10] {Whow}. test
test test test tets test test \answerspace [n=10] {Whow}.
test test test test test test \answerspace [n=*] {Whow.}
test test test test test test test \startanswerlines
[n=3] What A Junk Answer \stopanswerlines
test test test test test test test \startanswerlines
[n=3,alternative=0] What A Junk Answer \stopanswerlines
test test test test test test test \startanswerlines
[n=3,alternative=1] What A Junk Answer \stopanswerlines
test test test test test test test \startanswerlines
[n=3,alternative=2] What A Junk Answer \stopanswerlines
\startitemize[paragraph]
\item \startanswerlines [option=seried,n=2] xxx \stopanswerlines
\stopitemize
test test test \answerspace [m=10] {Whow}. test test test
test tets test test \answerspace [m=10] {Whow}. test test
test test tets test test \answerspace [m=10] {Whow}. test
test test test tets test test \answerspace [m=10] {Whow}.
test test test test test test \answerspace [m=*] {Whow.}
test test test test test test test \startanswerlines
[m=2] What A Junk Answer \stopanswerlines
test test test test test test test \startanswerlines
[m=2,alternative=0] What A Junk Answer \stopanswerlines
test test test test test test test \startanswerlines
[m=2,alternative=1] What A Junk Answer \stopanswerlines
test test test test test test test \startanswerlines
[m=2,alternative=2] What A Junk Answer \stopanswerlines
\startitemize[paragraph]
\item \startanswerlines [option=seried,m=2] xxx \stopanswerlines
\stopitemize
\stoptext
|