[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 <felicia@lon-capa.org><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 <import id=3D"IMPORT-ID"><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. Try playing with this t=
hough. It appears you need to use the <br>import id to access the sub=
mission.<br><br>Felicia<br><br>Felicia Berryman wrote:<br>> Hi Brew,<br>=
> <br>> Just making your example simpler. You can use my text b=
elow to create a <br>> bug report if no one has any ideas on how to make=
this work.<br>> <br>> $Key displays after submission using problem c=
ode below:<br>> ---------------------------------------------<br>> &l=
t;problem><br>> <script type=3D"loncapa/perl"><br>> $Key =3D=
&EXT('user.resource.resource.PART-ID.SUBMISSION-ID.submission');<br>>=
; </script><br>> <br>> <part id=3D"PART-ID"><br>> <=
startouttext />Enter something<endouttext /><br>> <stringres=
ponse answerdisplay=3D"Got it" answer=3D"/.*/" id=3D"SUBMISSION-ID" <br>>=
; type=3D"re"><br>> <textline readonly=3D"no"></textline>=
<br>> </stringresponse><br>> </part><br>> <br>> <=
;startouttext /><p>You entered $Key</p><endouttext /><=
br>> </problem><br>> ------------------------------------------=
---<br>> <br>> $Key doesn't display after submission using problem co=
de below:<br>> ---------------------------------------------<br>> <=
;problem><br>> <script type=3D"loncapa/perl"><br>> $Key =3D&=
amp;EXT('user.resource.resource.PART-ID.SUBMISSION-ID.submission');<br>>=
</script><br>> <br>> <part id=3D"PART-ID"><br>> <i=
mport>brew.library</import><br>> </part><br>> <br>>=
<startouttext /><p>You entered $Key</p><endouttext /&=
gt;<br>> </problem><br>> --------------------------------------=
-------<br>> Where brew.library is:<br>> ----------------------------=
-----------------<br>> <library><br>> <startouttext />Ent=
er something<endouttext /><br>> <stringresponse answerdisplay=
=3D"Got it" answer=3D"/.*/" id=3D"SUBMISSION-ID" <br>> type=3D"re"><b=
r>> <textline readonly=3D"no"></textline><br>> </strin=
gresponse><br>> </library><br>> ----------------------------=
-----------------<br>> <br>> Felicia<br>> <br>> Robert=5FBrewin=
gton@er.monroe.edu wrote:<br>>> I have been beating this for a couple=
of days, and am having trouble <br>>> understanding a) what is going=
on, and b) what I should do about it:)<br>>><br>>> The basic i=
dea is that I want to put various pieces of code in <br>>> libraries,=
which are then called from the main problems. Otherwise I <br>>> end=
up with the same code copied into many problems; when I want to <br>>&g=
t; make a change, I have to somehow find all those problems and change <br>=
>> them. Of course, LonCapa doesn't have any search tools, so it is <=
br>>> awkward to do this over my 7000 problems.<br>>><br>>&g=
t; The problem I am having is understanding when my script 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>>&g=
t; parsed/evaluated/something.<br>>><br>>> In the example below=
, the status of the problem part SetupKey within <br>>> the FunctionC=
ode library is retrieved fine. However, I do not seem to <br>>> be ab=
le to retrieve the SetupKey submission at any time, either from <br>>>=
; within the FunctionCode library (the ideal case) or from the <br>>>=
MainProblem code.<br>>><br>>> So, 1) why doesn't this work? an=
d<br>>> 2) how would I obtain the submission?<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>>> &l=
t;problem><br>>> <script type=3D"loncapa/perl"><br>>> =
$KeyCodeBeforeMain =3D <br>>> &EXT('user.resource.resource.SetupK=
ey.KeyCode.submission');<br>>> $whichScript=3D"BeforeMain";<br>>&g=
t; </script><br>>><br>>> <import id=3D"SetKey">Func=
tionCode.library</import><br>>><br>>> <script type=3D"=
loncapa/perl"><br>>> $KeyCodeAfterMain =3D <br>>> &EXT('=
user.resource.resource.SetupKey.KeyCode.submission');<br>>> $whichScr=
ipt=3D"AfterMain";<br>>> </script><br>>><br>>> <=
part id=3Djunk><br>>> <startouttext /><br>>> whichScri=
pt is {$whichScript} <p/><br>>> statusKey is {$statusKey} <p=
/><br>>> KeyCodeBeforeMain is {$KeyCodeBeforeMain} <p/>=
;<br>>> KeyCodeBefore is {$KeyCodeBefore} <p/><br>>>=
; KeyCodeAfter is {$KeyCodeAfter} <p/><br>>> KeyCodeAfter=
Main is {$KeyCodeAfterMain} <p/><br>>><br>>> <en=
douttext /><br>>> <stringresponse answer=3D"yes" id=3D"stuff" t=
ype=3D"ci"><br>>> <textline readonly=3D"no"><br>>> <=
;/textline><br>>> </stringresponse><br>>> </part>=
;<br>>> </problem><br>>><br>>><br>>> 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;> <library><br>>><br>>> <script type=3D"loncapa/p=
erl"><br>>> $KeyCodeBefore =3D <br>>> &EXT('user.resourc=
e.resource.SetupKey.KeyCode.submission');<br>>> $statusKey =3D &E=
XT('user.resource.resource.SetupKey.solved');<br>>> $whichScript=3D"B=
eforeSetupKey";<br>>> </script><br>>><br>>><br>>=
> <part id=3D"SetupKey"><br>>> <startouttext /><br>>=
;> Enter the key<br>>> <endouttext /><br>>> <string=
response id=3D"KeyCode" answer=3D"/.*/" type=3D"re"><br>>> <tex=
tline readonly=3D"no"><br>>> </textline><br>>> </st=
ringresponse><br>>> </part><br>>><br>>> <scri=
pt type=3D"loncapa/perl"><br>>> $KeyCodeAfter =3D <br>>> &am=
p;EXT('user.resource.resource.SetupKey.KeyCode.submission');<br>>> $w=
hichScript=3D"AfterSetupKey";<br>>> </script><br>>><br>&g=
t;> </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 mailing <br>>> list LON-CAPA-users@mai=
l.lon-capa.org <br>>> <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>> <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> <a href=3D"http://www.loncapa.msu.edu">http:/=
/www.loncapa.msu.edu</a> - MSU Users<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>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>