[LON-CAPA-users] Variables in libraries
lon-capa-users@mail.lon-capa.org
lon-capa-users@mail.lon-capa.org
Sat, 26 Jul 2008 23:10:33 -0400
<div>Felicia,<br><br>I assume you saw the response from Guy. Having missed =
the last Conference, I was unaware that Guy had moved on to less-MSU-green =
pastures (sorry to bother you, Guy!) and had sent him a note directly.<br><=
br>So, the answer is: as we were surmising, the import id is part of the ke=
y, but is tacked on with an underscore instead of a period. I have tried it=
, and it is working, so I am now Fat, Dumb, and Happy!<br><br>Thanks,<br>br=
ew<br></div><font color=3D"#990099">-----lon-capa-users-admin@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; margin-left: 5px; mar=
gin-right: 0px;">To: lon-capa-users@mail.lon-capa.org<br>From: Felicia Berr=
yman <felicia@lon-capa.org><br>Sent by: lon-capa-users-admin@mail.lon=
-capa.org<br>Date: 07/26/2008 05:37PM<br>Subject: Re: [LON-CAPA-users] Vari=
ables in libraries<br><br><font face=3D"monospace" size=3D"3">Hi Brew,<br><=
br>The data displays in the spreadsheet in the order: part, import, then <b=
r>submission. This is also the way the order I coded it in my testing=
. <br>I'd file a bug report.<br><br>Let me know if you want me to file one =
for you.<br><br>Felicia<br><br><br>Robert=5FBrewington@er.monroe.edu wrote:=
<br>> Actually, I did try a few variations on this:<br>> <br>> use=
r.resource.resource.ImportId.PartId.ResponseId<br>> user.resource.resour=
ce.ImportId.ResponseId<br>> user.resource.resource.ImportIdPartId.Respon=
seId<br>> user.resource.ImportId.PartId.ResponseId<br>> user.resource=
.resource.PartId.ImportId.ResponseId<br>> user.resource.resource.PartIdI=
mportId.ResponseId<br>> <br>> I was hoping the answer would be someth=
ing like this, but since I don't <br>> understand the naming scheme in t=
he first place, it is hard to know what <br>> to try.<br>> <br>> b=
rew<br>> -----lon-capa-users-admin@mail.lon-capa.org wrote: -----<br>>=
; <br>> To: lon-capa-users@mail.lon-capa.org<br>>  =
; From: Felicia Berryman <felicia@lon-capa.org><br>> =
Sent by: lon-capa-users-admin@mail.lon-capa.org<br>> &nbs=
p; Date: 07/25/2008 04:59PM<br>> Subject: Re: [LON-CAPA-us=
ers] Variables in libraries<br>> <br>> Hi Brew,<br>>=
<br>> I used <import id=3D"IMPORT-ID"><br>> <br>=
> Then, in the spreadsheet, the submissions shows as<br>&g=
t; stores=5FPART-ID=5FIMPORT-ID=5FSUBMISSION-ID=5Fsubmission<=
br>> <br>> I tried using the import id in the $Key defi=
nition but couldn't get it<br>> to work. Try playing=
with this though. It appears you need to use the<br>> &nbs=
p; import id to access the submission.<br>> <br>> Felic=
ia<br>> <br>> Felicia Berryman wrote:<br>> &n=
bsp; > Hi Brew,<br>> ><br>> &n=
bsp; > Just making your example simpler. You can use my text=
below to<br>> create a<br>> > b=
ug report if no one has any ideas on how to make this work.<br>> =
><br>> > $Key displays after subm=
ission using problem code below:<br>> > ---------=
------------------------------------<br>> > <p=
roblem><br>> > <script type=3D"loncapa/perl=
"><br>> > $Key<br>> =3D&E=
XT('user.resource.resource.PART-ID.SUBMISSION-ID.submission');<br>> &nbs=
p; > </script><br>> ><br>&g=
t; > <part id=3D"PART-ID"><br>> &nbs=
p; > <startouttext />Enter something<endouttext /><br>=
> > <stringresponse answerdisplay=3D"Got it" a=
nswer=3D"/.*/"<br>> id=3D"SUBMISSION-ID"<br>> &n=
bsp; > type=3D"re"><br>> > <textli=
ne readonly=3D"no"></textline><br>> > &l=
t;/stringresponse><br>> > </part><br>>=
; ><br>> > <startouttex=
t /><p>You entered $Key</p><endouttext /><br>> &nbs=
p; > </problem><br>> > ----=
-----------------------------------------<br>> ><=
br>> > $Key doesn't display after submission usin=
g problem code below:<br>> > --------------------=
-------------------------<br>> > <problem><=
br>> > <script type=3D"loncapa/perl"><br>&g=
t; > $Key<br>> =3D&EXT('user.re=
source.resource.PART-ID.SUBMISSION-ID.submission');<br>> &=
nbsp;> </script><br>> ><br>> &=
nbsp; > <part id=3D"PART-ID"><br>> &g=
t; <import>brew.library</import><br>> &g=
t; </part><br>> ><br>> &nb=
sp;> <startouttext /><p>You entered $Key</p><endout=
text /><br>> > </problem><br>> =
> ---------------------------------------------<br>> &n=
bsp; > Where brew.library is:<br>> &=
gt; ---------------------------------------------<br>> &nb=
sp;> <library><br>> > <startouttext /=
>Enter something<endouttext /><br>> > &l=
t;stringresponse answerdisplay=3D"Got it" answer=3D"/.*/"<br>> &n=
bsp; id=3D"SUBMISSION-ID"<br>> > type=3D"re"><=
br>> > <textline readonly=3D"no"></textl=
ine><br>> > </stringresponse><br>> &n=
bsp; > </library><br>> > --=
-------------------------------------------<br>> >=
;<br>> > Felicia<br>> >=
<br>> > Robert=5FBrewington@er.monroe.edu wrote:<=
br>> >> I have been beating this for a couple =
of days, and am having<br>> trouble<br>> =
>> understanding a) what is going on, and b) what I should do a=
bout<br>> it:)<br>> >><br>>=
; >> The basic idea is that I want to put various=
pieces of code in<br>> >> libraries, which ar=
e then called from the main problems.<br>> Otherwise I<br>=
> >> end up with the same code copied into man=
y problems; when I want to<br>> >> make a chan=
ge, I have to somehow find all those problems and change<br>> &nb=
sp; >> them. Of course, LonCapa doesn't have any search tools, =
so it is<br>> >> awkward to do this over my 70=
00 problems.<br>> >><br>> &nb=
sp;>> The problem I am having is understanding when my script<br>>=
variables will<br>> >> work and=
when they won't. I know this has to do with the order that<br>> =
>> the main problem html versus the libraries are<br>>=
; >> parsed/evaluated/something.<br>> &=
nbsp; >><br>> >> In the example be=
low, the status of the problem part SetupKey<br>> within<b=
r>> >> the FunctionCode library is retrieved f=
ine. However, I do not<br>> seem to<br>> =
>> be able to retrieve the SetupKey submission at any time, eit=
her<br>> from<br>> >> within =
the FunctionCode library (the ideal case) or from the<br>> =
>> MainProblem code.<br>> >><br>&=
gt; >> So, 1) why doesn't this work? and<br>> =
>> 2) how would I obtain the submission?<br>> =
>><br>> >> Thanks fo=
r 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>> &nbs=
p;>> <problem><br>> >> <script =
type=3D"loncapa/perl"><br>> >> $KeyCodeBefo=
reMain =3D<br>> >> &EXT('user.resource.res=
ource.SetupKey.KeyCode.submission');<br>> >> $=
whichScript=3D"BeforeMain";<br>> >> </scrip=
t><br>> >><br>> >=
> <import id=3D"SetKey">FunctionCode.library</import><br>>=
; >><br>> >> <scr=
ipt type=3D"loncapa/perl"><br>> >> $KeyCode=
AfterMain =3D<br>> >> &EXT('user.resource.=
resource.SetupKey.KeyCode.submission');<br>> >>=
; $whichScript=3D"AfterMain";<br>> >> </scr=
ipt><br>> >><br>> &g=
t;> <part id=3Djunk><br>> >> <star=
touttext /><br>> >> whichScript is {$whichS=
cript} <p/><br>> >> statusKey is {$statu=
sKey} <p/><br>> >> KeyCodeBeforeMain is =
{$KeyCodeBeforeMain} <p/><br>> >> =
KeyCodeBefore is {$KeyCodeBefore} <p/><br>> &n=
bsp;>> KeyCodeAfter is {$KeyCodeAfter} <p/><br>>  =
; >> KeyCodeAfterMain is {$KeyCodeAfterMain} <p=
/><br>> >><br>> >=
> <endouttext /><br>> >> <stringre=
sponse answer=3D"yes" id=3D"stuff" type=3D"ci"><br>> &n=
bsp;>> <textline readonly=3D"no"><br>> &=
gt;> </textline><br>> >> </stringr=
esponse><br>> >> </part><br>> &nbs=
p; >> </problem><br>> >&=
gt;<br>> >><br>> >&g=
t; 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><br>> =
>><br>> >> <script type=
=3D"loncapa/perl"><br>> >> $KeyCodeBefore =
=3D<br>> >> &EXT('user.resource.resource.S=
etupKey.KeyCode.submission');<br>> >> $statusK=
ey =3D &EXT('user.resource.resource.SetupKey.solved');<br>> &=
nbsp; >> $whichScript=3D"BeforeSetupKey";<br>> =
>> </script><br>> >><br>>=
; >><br>> >> <par=
t id=3D"SetupKey"><br>> >> <startouttext=
/><br>> >> Enter the key<br>> &n=
bsp; >> <endouttext /><br>> >&g=
t; <stringresponse id=3D"KeyCode" answer=3D"/.*/" type=3D"re"><br>>=
; >> <textline readonly=3D"no"><br>> &nb=
sp; >> </textline><br>> >=
;> </stringresponse><br>> >> </par=
t><br>> >><br>> >=
> <script type=3D"loncapa/perl"><br>> >&=
gt; $KeyCodeAfter =3D<br>> >> &EXT('user.r=
esource.resource.SetupKey.KeyCode.submission');<br>>  =
;>> $whichScript=3D"AfterSetupKey";<br>> >&=
gt; </script><br>> >><br>> &nb=
sp; >> </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>> =
>><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 LON-CAPA-users<br>> =
mailing<br>> >> list LON-CAPA-us=
ers@mail.lon-capa.org<br>> >> <a href=3D"http:=
//mail.lon-capa.org/mailman/listinfo/lon-capa-users">http://mail.lon-capa.o=
rg/mailman/listinfo/lon-capa-users</a><br>> ><br>=
> <br>> -- <br>> Felicia Berryman<br>&=
gt; Instructional Systems<br>> Michigan Stat=
e University<br>> (517)432-7326<br>> LON-=
CAPA Technical Support Available at:<br>> <a =
href=3D"http://www.loncapa.msu.edu">http://www.loncapa.msu.edu</a> - MSU Us=
ers<br>> <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>> &nb=
sp; LON-CAPA-users mailing list<br>> LON-CAPA-users=
@mail.lon-capa.org<br>> <a href=3D"http://mail.lon-capa.or=
g/mailman/listinfo/lon-capa-users">http://mail.lon-capa.org/mailman/listinf=
o/lon-capa-users</a><br>> <br>> <br>> <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 LON-CAPA-users mailing <br=
>> list 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><br>-- <br> Felicia Berryman<br> =
LON-CAPA Support Coordinator<br> Michigan State University<br> =
Phone: (517)432-9866<br> Technical Support Available at:<=
br> <a href=3D"http://www.loncapa.msu.edu">http://www.loncapa.=
msu.edu</a> - MSU Users<br> <a href=3D"http://www.help.lon-cap=
a.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 lis=
t<br>LON-CAPA-users@mail.lon-capa.org<br><a href=3D"http://mail.lon-capa.or=
g/mailman/listinfo/lon-capa-users">http://mail.lon-capa.org/mailman/listinf=
o/lon-capa-users</a><br></font></blockquote><br><BR>