[LON-CAPA-users] Variables in libraries
lon-capa-users@mail.lon-capa.org
lon-capa-users@mail.lon-capa.org
Sat, 19 Jul 2008 19:11:08 -0400
<font size=3D"2">I have been beating this for a couple of days, and am havi=
ng trouble understanding a) what is going on, and b) what I should do about=
it:)<br><br>The basic idea is that I want to put various pieces of code in=
libraries, which are then called from the main problems. Otherwise I end u=
p with the same code copied into many problems; when I want to make a chang=
e, I have to somehow find all those problems and change them. Of course, Lo=
nCapa doesn't have any search tools, so it is awkward to do this over my 70=
00 problems.<br><br>The problem I am having is understanding when my script=
variables will work and when they won't. I know this has to do with the or=
der that the main problem html versus the libraries are parsed/evaluated/so=
mething.<br><br>In the example below, the status of the problem part SetupK=
ey within the FunctionCode library is retrieved fine. However, I do not see=
m to be able to retrieve the SetupKey submission at any time, either from w=
ithin the FunctionCode library (the ideal case) or from the MainProblem cod=
e.<br><br>So, 1) why doesn't this work? and <br>2) how would I obtain the s=
ubmission?<br><br>Thanks for any clues,<br>brew<br><br>MainProblem.problem:=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br><problem><br>&=
lt;script type=3D"loncapa/perl"><br>$KeyCodeBeforeMain =3D &EXT('use=
r.resource.resource.SetupKey.KeyCode.submission');<br>$whichScript=3D"Befor=
eMain";<br></script><br><br><import id=3D"SetKey">FunctionCode.=
library</import><br><br><script type=3D"loncapa/perl"><br>$KeyC=
odeAfterMain =3D &EXT('user.resource.resource.SetupKey.KeyCode.submissi=
on');<br>$whichScript=3D"AfterMain";<br></script><br><br><part id=
=3Djunk><br><startouttext /><br>whichScript is {$whichScript} <=
p/><br>statusKey is {$statusKey} <p/><br>KeyCodeBeforeMain is {$Ke=
yCodeBeforeMain} <p/><br>KeyCodeBefore is {$KeyCodeBefore} =
; <p/><br>KeyCodeAfter is {$KeyCodeAfter} <p/><br>KeyCode=
AfterMain is {$KeyCodeAfterMain} <p/><br><br><endouttext /&g=
t;<br><stringresponse answer=3D"yes" id=3D"stuff" type=3D"ci"><br><=
;textline readonly=3D"no"><br></textline><br></stringresponse&g=
t;<br></part><br></problem><br><br><br>FunctionCode.library: =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br><library><b=
r><br><script type=3D"loncapa/perl"><br>$KeyCodeBefore =3D &EXT('=
user.resource.resource.SetupKey.KeyCode.submission');<br>$statusKey =3D &am=
p;EXT('user.resource.resource.SetupKey.solved');<br>$whichScript=3D"BeforeS=
etupKey";<br></script><br><br><br><part id=3D"SetupKey"><br><=
;startouttext /><br>Enter the key<br><endouttext /><br><stringr=
esponse </font><font size=3D"2">id=3D"KeyCode" </font><font size=3D"2">answ=
er=3D"/.*/" type=3D"re"><br><textline readonly=3D"no"><br></tex=
tline><br></stringresponse><br></part><br><br><script typ=
e=3D"loncapa/perl"><br>$KeyCodeAfter =3D &EXT('user.resource.resourc=
e.SetupKey.KeyCode.submission');<br>$whichScript=3D"AfterSetupKey";<br><=
/script><br><br></library><br><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br></=
font><BR>