[LON-CAPA-users] Variables in libraries

lon-capa-users@mail.lon-capa.org lon-capa-users@mail.lon-capa.org
Fri, 25 Jul 2008 17:30:40 -0400


<div>Actually, I did try a few variations on this:<br><br>user.resource.res=
ource.ImportId.PartId.ResponseId<br>user.resource.resource.ImportId.Respons=
eId<br>user.resource.resource.ImportIdPartId.ResponseId<br>user.resource.Im=
portId.PartId.ResponseId<br>user.resource.resource.PartId.ImportId.Response=
Id<br>


user.resource.resource.PartIdImportId.ResponseId<br>

<br>I was hoping the answer would be something like this, but since I don't=
 understand the naming scheme in the first place, it is hard to know what t=
o try.<br><br>brew<br></div><font color=3D"#990099">-----lon-capa-users-adm=
in@mail.lon-capa.org wrote: -----<br><br></font><blockquote style=3D"border=
-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margi=
n-left: 5px; margin-right: 0px;">To: lon-capa-users@mail.lon-capa.org<br>Fr=
om: Felicia Berryman &lt;felicia@lon-capa.org&gt;<br>Sent by: lon-capa-user=
s-admin@mail.lon-capa.org<br>Date: 07/25/2008 04:59PM<br>Subject: Re: [LON-=
CAPA-users] Variables in libraries<br><br><font face=3D"monospace" size=3D"=
3">Hi Brew,<br><br>I used &lt;import id=3D"IMPORT-ID"&gt;<br><br>Then, in t=
he spreadsheet, the submissions shows as <br>stores=5FPART-ID=5FIMPORT-ID=
=5FSUBMISSION-ID=5Fsubmission<br><br>I tried using the import id in the $Ke=
y definition but couldn't get it <br>to work. &nbsp;Try playing with this t=
hough. &nbsp;It appears you need to use the <br>import id to access the sub=
mission.<br><br>Felicia<br><br>Felicia Berryman wrote:<br>&gt; Hi Brew,<br>=
&gt; <br>&gt; Just making your example simpler. &nbsp;You can use my text b=
elow to create a <br>&gt; bug report if no one has any ideas on how to make=
 this work.<br>&gt; <br>&gt; $Key displays after submission using problem c=
ode below:<br>&gt; ---------------------------------------------<br>&gt; &l=
t;problem&gt;<br>&gt; &lt;script type=3D"loncapa/perl"&gt;<br>&gt; $Key =3D=
&amp;EXT('user.resource.resource.PART-ID.SUBMISSION-ID.submission');<br>&gt=
; &lt;/script&gt;<br>&gt; <br>&gt; &lt;part id=3D"PART-ID"&gt;<br>&gt; &lt;=
startouttext /&gt;Enter something&lt;endouttext /&gt;<br>&gt; &lt;stringres=
ponse answerdisplay=3D"Got it" answer=3D"/.*/" id=3D"SUBMISSION-ID" <br>&gt=
; type=3D"re"&gt;<br>&gt; &lt;textline readonly=3D"no"&gt;&lt;/textline&gt;=
<br>&gt; &lt;/stringresponse&gt;<br>&gt; &lt;/part&gt;<br>&gt; <br>&gt; &lt=
;startouttext /&gt;&lt;p&gt;You entered $Key&lt;/p&gt;&lt;endouttext /&gt;<=
br>&gt; &lt;/problem&gt;<br>&gt; ------------------------------------------=
---<br>&gt; <br>&gt; $Key doesn't display after submission using problem co=
de below:<br>&gt; ---------------------------------------------<br>&gt; &lt=
;problem&gt;<br>&gt; &lt;script type=3D"loncapa/perl"&gt;<br>&gt; $Key =3D&=
amp;EXT('user.resource.resource.PART-ID.SUBMISSION-ID.submission');<br>&gt;=
 &lt;/script&gt;<br>&gt; <br>&gt; &lt;part id=3D"PART-ID"&gt;<br>&gt; &lt;i=
mport&gt;brew.library&lt;/import&gt;<br>&gt; &lt;/part&gt;<br>&gt; <br>&gt;=
 &lt;startouttext /&gt;&lt;p&gt;You entered $Key&lt;/p&gt;&lt;endouttext /&=
gt;<br>&gt; &lt;/problem&gt;<br>&gt; --------------------------------------=
-------<br>&gt; Where brew.library is:<br>&gt; ----------------------------=
-----------------<br>&gt; &lt;library&gt;<br>&gt; &lt;startouttext /&gt;Ent=
er something&lt;endouttext /&gt;<br>&gt; &lt;stringresponse answerdisplay=
=3D"Got it" answer=3D"/.*/" id=3D"SUBMISSION-ID" <br>&gt; type=3D"re"&gt;<b=
r>&gt; &lt;textline readonly=3D"no"&gt;&lt;/textline&gt;<br>&gt; &lt;/strin=
gresponse&gt;<br>&gt; &lt;/library&gt;<br>&gt; ----------------------------=
-----------------<br>&gt; <br>&gt; Felicia<br>&gt; <br>&gt; Robert=5FBrewin=
gton@er.monroe.edu wrote:<br>&gt;&gt; I have been beating this for a couple=
 of days, and am having trouble <br>&gt;&gt; understanding a) what is going=
 on, and b) what I should do about it:)<br>&gt;&gt;<br>&gt;&gt; The basic i=
dea is that I want to put various pieces of code in <br>&gt;&gt; libraries,=
 which are then called from the main problems. Otherwise I <br>&gt;&gt; end=
 up with the same code copied into many problems; when I want to <br>&gt;&g=
t; make a change, I have to somehow find all those problems and change <br>=
&gt;&gt; them. Of course, LonCapa doesn't have any search tools, so it is <=
br>&gt;&gt; awkward to do this over my 7000 problems.<br>&gt;&gt;<br>&gt;&g=
t; The problem I am having is understanding when my script variables will <=
br>&gt;&gt; work and when they won't. I know this has to do with the order =
that <br>&gt;&gt; the main problem html versus the libraries are <br>&gt;&g=
t; parsed/evaluated/something.<br>&gt;&gt;<br>&gt;&gt; In the example below=
, the status of the problem part SetupKey within <br>&gt;&gt; the FunctionC=
ode library is retrieved fine. However, I do not seem to <br>&gt;&gt; be ab=
le to retrieve the SetupKey submission at any time, either from <br>&gt;&gt=
; within the FunctionCode library (the ideal case) or from the <br>&gt;&gt;=
 MainProblem code.<br>&gt;&gt;<br>&gt;&gt; So, 1) why doesn't this work? an=
d<br>&gt;&gt; 2) how would I obtain the submission?<br>&gt;&gt;<br>&gt;&gt;=
 Thanks for any clues,<br>&gt;&gt; brew<br>&gt;&gt;<br>&gt;&gt; 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>&gt;&gt; &l=
t;problem&gt;<br>&gt;&gt; &lt;script type=3D"loncapa/perl"&gt;<br>&gt;&gt; =
$KeyCodeBeforeMain =3D <br>&gt;&gt; &amp;EXT('user.resource.resource.SetupK=
ey.KeyCode.submission');<br>&gt;&gt; $whichScript=3D"BeforeMain";<br>&gt;&g=
t; &lt;/script&gt;<br>&gt;&gt;<br>&gt;&gt; &lt;import id=3D"SetKey"&gt;Func=
tionCode.library&lt;/import&gt;<br>&gt;&gt;<br>&gt;&gt; &lt;script type=3D"=
loncapa/perl"&gt;<br>&gt;&gt; $KeyCodeAfterMain =3D <br>&gt;&gt; &amp;EXT('=
user.resource.resource.SetupKey.KeyCode.submission');<br>&gt;&gt; $whichScr=
ipt=3D"AfterMain";<br>&gt;&gt; &lt;/script&gt;<br>&gt;&gt;<br>&gt;&gt; &lt;=
part id=3Djunk&gt;<br>&gt;&gt; &lt;startouttext /&gt;<br>&gt;&gt; whichScri=
pt is {$whichScript} &lt;p/&gt;<br>&gt;&gt; statusKey is {$statusKey} &lt;p=
/&gt;<br>&gt;&gt; KeyCodeBeforeMain is {$KeyCodeBeforeMain} &nbsp;&lt;p/&gt=
;<br>&gt;&gt; KeyCodeBefore is {$KeyCodeBefore} &nbsp;&lt;p/&gt;<br>&gt;&gt=
; KeyCodeAfter is {$KeyCodeAfter} &nbsp;&lt;p/&gt;<br>&gt;&gt; KeyCodeAfter=
Main is {$KeyCodeAfterMain} &nbsp;&lt;p/&gt;<br>&gt;&gt;<br>&gt;&gt; &lt;en=
douttext /&gt;<br>&gt;&gt; &lt;stringresponse answer=3D"yes" id=3D"stuff" t=
ype=3D"ci"&gt;<br>&gt;&gt; &lt;textline readonly=3D"no"&gt;<br>&gt;&gt; &lt=
;/textline&gt;<br>&gt;&gt; &lt;/stringresponse&gt;<br>&gt;&gt; &lt;/part&gt=
;<br>&gt;&gt; &lt;/problem&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; Function=
Code.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>&g=
t;&gt; &lt;library&gt;<br>&gt;&gt;<br>&gt;&gt; &lt;script type=3D"loncapa/p=
erl"&gt;<br>&gt;&gt; $KeyCodeBefore =3D <br>&gt;&gt; &amp;EXT('user.resourc=
e.resource.SetupKey.KeyCode.submission');<br>&gt;&gt; $statusKey =3D &amp;E=
XT('user.resource.resource.SetupKey.solved');<br>&gt;&gt; $whichScript=3D"B=
eforeSetupKey";<br>&gt;&gt; &lt;/script&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;=
&gt; &lt;part id=3D"SetupKey"&gt;<br>&gt;&gt; &lt;startouttext /&gt;<br>&gt=
;&gt; Enter the key<br>&gt;&gt; &lt;endouttext /&gt;<br>&gt;&gt; &lt;string=
response id=3D"KeyCode" answer=3D"/.*/" type=3D"re"&gt;<br>&gt;&gt; &lt;tex=
tline readonly=3D"no"&gt;<br>&gt;&gt; &lt;/textline&gt;<br>&gt;&gt; &lt;/st=
ringresponse&gt;<br>&gt;&gt; &lt;/part&gt;<br>&gt;&gt;<br>&gt;&gt; &lt;scri=
pt type=3D"loncapa/perl"&gt;<br>&gt;&gt; $KeyCodeAfter =3D <br>&gt;&gt; &am=
p;EXT('user.resource.resource.SetupKey.KeyCode.submission');<br>&gt;&gt; $w=
hichScript=3D"AfterSetupKey";<br>&gt;&gt; &lt;/script&gt;<br>&gt;&gt;<br>&g=
t;&gt; &lt;/library&gt;<br>&gt;&gt;<br>&gt;&gt; =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=
>&gt;&gt;<br>&gt;&gt; =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=
=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=
=5F=5F=5F=5F=5F LON-CAPA-users mailing <br>&gt;&gt; list LON-CAPA-users@mai=
l.lon-capa.org <br>&gt;&gt; <a href=3D"http://mail.lon-capa.org/mailman/lis=
tinfo/lon-capa-users">http://mail.lon-capa.org/mailman/listinfo/lon-capa-us=
ers</a><br>&gt; <br><br>-- <br>Felicia Berryman<br>Instructional Systems<br=
>Michigan State University<br>(517)432-7326<br>LON-CAPA Technical Support A=
vailable at:<br> &nbsp; &nbsp;<a href=3D"http://www.loncapa.msu.edu">http:/=
/www.loncapa.msu.edu</a> - MSU Users<br> &nbsp; &nbsp;<a href=3D"http://www=
.help.lon-capa.org">http://www.help.lon-capa.org</a> - General<br>=5F=5F=5F=
=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=
=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F<br>LON-CAPA-users=
 mailing list<br>LON-CAPA-users@mail.lon-capa.org<br><a href=3D"http://mail=
.lon-capa.org/mailman/listinfo/lon-capa-users">http://mail.lon-capa.org/mai=
lman/listinfo/lon-capa-users</a><br></font></blockquote><br><BR>