[LON-CAPA-users] Variables in libraries

Felicia Berryman lon-capa-users@mail.lon-capa.org
Sun, 27 Jul 2008 11:12:31 -0400


Hi Brew,

I didn't see Guy's message until today.  No bug report needed then.

There was an announcement about Guy posted to LON-CAPA-announce, see 
http://mail.lon-capa.org/pipermail/lon-capa-announce/2007/000054.html 
for all of the gossip!  :-)

Guy stay subscribed to the lists and sometimes pops in like an angel or 
fairy-god-parent.  Just be careful invoking Guy.  I try not to 
over-invoke him from the geek-mecca that is silicon valley.  I think 
your public apology will appease him.  Plus, I think he gets some sort 
of strange gratification helping others.

Felicia

Robert_Brewington@er.monroe.edu wrote:
> Felicia,
> 
> 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.
> 
> So, the answer is: as we were surmising, the import id is part of the 
> key, 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!
> 
> Thanks,
> brew
> -----lon-capa-users-admin@mail.lon-capa.org wrote: -----
> 
>     To: lon-capa-users@mail.lon-capa.org
>     From: Felicia Berryman <felicia@lon-capa.org>
>     Sent by: lon-capa-users-admin@mail.lon-capa.org
>     Date: 07/26/2008 05:37PM
>     Subject: Re: [LON-CAPA-users] Variables in libraries
> 
>     Hi Brew,
> 
>     The data displays in the spreadsheet in the order: part, import, then
>     submission.  This is also the way the order I coded it in my testing.
>     I'd file a bug report.
> 
>     Let me know if you want me to file one for you.
> 
>     Felicia
> 
> 
>     Robert_Brewington@er.monroe.edu wrote:
>      > Actually, I did try a few variations on this:
>      >
>      > user.resource.resource.ImportId.PartId.ResponseId
>      > user.resource.resource.ImportId.ResponseId
>      > user.resource.resource.ImportIdPartId.ResponseId
>      > user.resource.ImportId.PartId.ResponseId
>      > user.resource.resource.PartId.ImportId.ResponseId
>      > user.resource.resource.PartIdImportId.ResponseId
>      >
>      > 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
>      > to try.
>      >
>      > brew
>      > -----lon-capa-users-admin@mail.lon-capa.org wrote: -----
>      >
>      >     To: lon-capa-users@mail.lon-capa.org
>      >     From: Felicia Berryman <felicia@lon-capa.org>
>      >     Sent by: lon-capa-users-admin@mail.lon-capa.org
>      >     Date: 07/25/2008 04:59PM
>      >     Subject: Re: [LON-CAPA-users] Variables in libraries
>      >
>      >     Hi Brew,
>      >
>      >     I used <import id="IMPORT-ID">
>      >
>      >     Then, in the spreadsheet, the submissions shows as
>      >     stores_PART-ID_IMPORT-ID_SUBMISSION-ID_submission
>      >
>      >     I tried using the import id in the $Key definition but
>     couldn't get it
>      >     to work.  Try playing with this though.  It appears you need
>     to use the
>      >     import id to access the submission.
>      >
>      >     Felicia
>      >
>      >     Felicia Berryman wrote:
>      >      > Hi Brew,
>      >      >
>      >      > Just making your example simpler.  You can use my text
>     below to
>      >     create a
>      >      > bug report if no one has any ideas on how to make this work.
>      >      >
>      >      > $Key displays after submission using problem code below:
>      >      > ---------------------------------------------
>      >      > <problem>
>      >      > <script type="loncapa/perl">
>      >      > $Key
>      >     =&EXT('user.resource.resource.PART-ID.SUBMISSION-ID.submission');
>      >      > </script>
>      >      >
>      >      > <part id="PART-ID">
>      >      > <startouttext />Enter something<endouttext />
>      >      > <stringresponse answerdisplay="Got it" answer="/.*/"
>      >     id="SUBMISSION-ID"
>      >      > type="re">
>      >      > <textline readonly="no"></textline>
>      >      > </stringresponse>
>      >      > </part>
>      >      >
>      >      > <startouttext /><p>You entered $Key</p><endouttext />
>      >      > </problem>
>      >      > ---------------------------------------------
>      >      >
>      >      > $Key doesn't display after submission using problem code
>     below:
>      >      > ---------------------------------------------
>      >      > <problem>
>      >      > <script type="loncapa/perl">
>      >      > $Key
>      >     =&EXT('user.resource.resource.PART-ID.SUBMISSION-ID.submission');
>      >      > </script>
>      >      >
>      >      > <part id="PART-ID">
>      >      > <import>brew.library</import>
>      >      > </part>
>      >      >
>      >      > <startouttext /><p>You entered $Key</p><endouttext />
>      >      > </problem>
>      >      > ---------------------------------------------
>      >      > Where brew.library is:
>      >      > ---------------------------------------------
>      >      > <library>
>      >      > <startouttext />Enter something<endouttext />
>      >      > <stringresponse answerdisplay="Got it" answer="/.*/"
>      >     id="SUBMISSION-ID"
>      >      > type="re">
>      >      > <textline readonly="no"></textline>
>      >      > </stringresponse>
>      >      > </library>
>      >      > ---------------------------------------------
>      >      >
>      >      > Felicia
>      >      >
>      >      > Robert_Brewington@er.monroe.edu wrote:
>      >      >> I have been beating this for a couple of days, and am having
>      >     trouble
>      >      >> understanding a) what is going on, and b) what I should
>     do about
>      >     it:)
>      >      >>
>      >      >> 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 up with the same code copied into many problems; when
>     I want to
>      >      >> make a change, I have to somehow find all those problems
>     and change
>      >      >> them. Of course, LonCapa doesn't have any search tools,
>     so it is
>      >      >> awkward to do this over my 7000 problems.
>      >      >>
>      >      >> 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
>     order that
>      >      >> the main problem html versus the libraries are
>      >      >> parsed/evaluated/something.
>      >      >>
>      >      >> In the example below, the status of the problem part SetupKey
>      >     within
>      >      >> the FunctionCode library is retrieved fine. However, I do not
>      >     seem to
>      >      >> be able to retrieve the SetupKey submission at any time,
>     either
>      >     from
>      >      >> within the FunctionCode library (the ideal case) or from the
>      >      >> MainProblem code.
>      >      >>
>      >      >> So, 1) why doesn't this work? and
>      >      >> 2) how would I obtain the submission?
>      >      >>
>      >      >> Thanks for any clues,
>      >      >> brew
>      >      >>
>      >      >> MainProblem.problem:
>     =========================================
>      >      >> <problem>
>      >      >> <script type="loncapa/perl">
>      >      >> $KeyCodeBeforeMain =
>      >      >> &EXT('user.resource.resource.SetupKey.KeyCode.submission');
>      >      >> $whichScript="BeforeMain";
>      >      >> </script>
>      >      >>
>      >      >> <import id="SetKey">FunctionCode.library</import>
>      >      >>
>      >      >> <script type="loncapa/perl">
>      >      >> $KeyCodeAfterMain =
>      >      >> &EXT('user.resource.resource.SetupKey.KeyCode.submission');
>      >      >> $whichScript="AfterMain";
>      >      >> </script>
>      >      >>
>      >      >> <part id=junk>
>      >      >> <startouttext />
>      >      >> whichScript is {$whichScript} <p/>
>      >      >> statusKey is {$statusKey} <p/>
>      >      >> KeyCodeBeforeMain is {$KeyCodeBeforeMain}  <p/>
>      >      >> KeyCodeBefore is {$KeyCodeBefore}  <p/>
>      >      >> KeyCodeAfter is {$KeyCodeAfter}  <p/>
>      >      >> KeyCodeAfterMain is {$KeyCodeAfterMain}  <p/>
>      >      >>
>      >      >> <endouttext />
>      >      >> <stringresponse answer="yes" id="stuff" type="ci">
>      >      >> <textline readonly="no">
>      >      >> </textline>
>      >      >> </stringresponse>
>      >      >> </part>
>      >      >> </problem>
>      >      >>
>      >      >>
>      >      >> FunctionCode.library:
>     ===========================================
>      >      >> <library>
>      >      >>
>      >      >> <script type="loncapa/perl">
>      >      >> $KeyCodeBefore =
>      >      >> &EXT('user.resource.resource.SetupKey.KeyCode.submission');
>      >      >> $statusKey = &EXT('user.resource.resource.SetupKey.solved');
>      >      >> $whichScript="BeforeSetupKey";
>      >      >> </script>
>      >      >>
>      >      >>
>      >      >> <part id="SetupKey">
>      >      >> <startouttext />
>      >      >> Enter the key
>      >      >> <endouttext />
>      >      >> <stringresponse id="KeyCode" answer="/.*/" type="re">
>      >      >> <textline readonly="no">
>      >      >> </textline>
>      >      >> </stringresponse>
>      >      >> </part>
>      >      >>
>      >      >> <script type="loncapa/perl">
>      >      >> $KeyCodeAfter =
>      >      >> &EXT('user.resource.resource.SetupKey.KeyCode.submission');
>      >      >> $whichScript="AfterSetupKey";
>      >      >> </script>
>      >      >>
>      >      >> </library>
>      >      >>
>      >      >> ==========================================================
>      >      >>
>      >      >> _______________________________________________
>     LON-CAPA-users
>      >     mailing
>      >      >> list LON-CAPA-users@mail.lon-capa.org
>      >      >> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>      >      >
>      >
>      >     --
>      >     Felicia Berryman
>      >     Instructional Systems
>      >     Michigan State University
>      >     (517)432-7326
>      >     LON-CAPA Technical Support Available at:
>      >        http://www.loncapa.msu.edu - MSU Users
>      >        http://www.help.lon-capa.org - General
>      >     _______________________________________________
>      >     LON-CAPA-users mailing list
>      >     LON-CAPA-users@mail.lon-capa.org
>      >     http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>      >
>      >
>      >
>      > _______________________________________________ LON-CAPA-users
>     mailing
>      > list LON-CAPA-users@mail.lon-capa.org
>      > http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
> 
>     -- 
>      Felicia Berryman
>      LON-CAPA Support Coordinator
>      Michigan State University
>      Phone:  (517)432-9866
>      Technical Support Available at:
>        http://www.loncapa.msu.edu - MSU Users
>        http://www.help.lon-capa.org - General
>     _______________________________________________
>     LON-CAPA-users mailing list
>     LON-CAPA-users@mail.lon-capa.org
>     http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
> 
> 
> 
> _______________________________________________ LON-CAPA-users mailing 
> list LON-CAPA-users@mail.lon-capa.org 
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

-- 
  Felicia Berryman
  LON-CAPA Support Coordinator
  Michigan State University
  Phone:  (517)432-9866
  Technical Support Available at:
    http://www.loncapa.msu.edu - MSU Users
    http://www.help.lon-capa.org - General