[LON-CAPA-users] Detecting What Part The Student Has Just Answered

Ray Batchelor lon-capa-users@mail.lon-capa.org
Thu, 19 Mar 2009 17:55:35 -0700


I suspect that you are expecting the function and variable to do more
meta stuff than it actually does.

I think that it simply returns the id value of the <part></part> in
which it is located rather than where the student is "at", whatever
that might mean.

 i.e. if you put it within a part such as:
<part id="2"><display>$external::part</display></part>, then it will
return "2".  Not very helpful when you have only a few lines of code
but could be of general use in a long piece of code, especially if you
decide to change ids while in the process of coding.

However you can use
<display>&EXT('user.resource.resource.2.solved')</display> to display
the solved status of part 2 (for example) and place it anywhere in
your problem.

 If you want to display  the id of the first part for which the
student still has tries left and which is still answerable, you'll
probably have to piece the logic together to determine the solved,
tries  and duedate status of each of the parts.  At least that is what
I think.... I could be wrong of course.  But I don't think there is
any a priori reason for the program to 'suspect' that the student is
progressing through the resources in the order you present them.

You'll probably want to use the returned value of any &EXT function as
a trigger for subsequent logical tests...



Anyway the simple example below should demonstrate what might be
returned for a couple of these variables ...  hope it helps.

<problem>

<startouttext />This is part <display>$external::part</display>.<br />
Here's a  way of returning the solved status of this part (if any):<br />
<display>$external::gradestatus</display><br />
This would only have a value if there were responses outside of  part
tags in the code. <br />
When part tags are used all responses are supposed to be within parts.
So I would expect to have seen nothing returned here, in this
example.<br /><br />

However, I could display the solved status of various different parts
like this:<br />
The solved status of part 1 is :<br
/>"<display>&EXT('user.resource.resource.1.solved')</display>"<br />
The solved status of part 2 is :<br
/>"<display>&EXT('user.resource.resource.2.solved')</display>"<br />
The solved status of part 3 is :<br
/>"<display>&EXT('user.resource.resource.3.solved')</display>"<br />
<hr /><endouttext />
<part id="1"><startouttext />Beginning of part
<display>$external::part</display>.<br />
Here's the solved status of this part:<br />
<display>$external::gradestatus</display><br /><endouttext />
<numericalresponse answer="10">
	<responseparam type="tolerance" default="5%" name="tol"
description="Numerical Tolerance" />
	<textline readonly="no" />
</numericalresponse></part>
<part id="2"><startouttext />Beginning of part
<display>$external::part</display>.<br />
Here's the solved status of this part:<br />
<display>$external::gradestatus</display><br /><endouttext />
<numericalresponse answer="20">
	<responseparam type="tolerance" default="5%" name="tol"
description="Numerical Tolerance" />
	<textline readonly="no" />
</numericalresponse></part>
<part id="3"><startouttext />Beginning of part
<display>$external::part</display>.<br />
Here's the solved status of this part:<br />
<display>$external::gradestatus</display><br /><endouttext />
<numericalresponse answer="30">
	<responseparam type="tolerance" default="5%" name="tol"
description="Numerical Tolerance" />
	<textline readonly="no" />
</numericalresponse></part>
</problem>


On 3/19/09, Sean Wolf <wolf.m.sean@gmail.com> wrote:
> I am now using
>
> <display>$external::part </display>
>
> To display the part, and it does return something.  However it always yields
> 0 and not the id of the part that the student is currently on.
>
> <display>&EXT('user.resource.resource.'..'.solved')
> </display>
>
> The above line doesn't display anything, however.
>
>
> On Thu, Mar 19, 2009 at 5:21 AM, H.K. Ng <hkng@fsu.edu> wrote:
>
> >
> > Hi,
> >
> >
> > At 09:30 PM 3/18/2009, you wrote:
> >
> > Right after the <problem> tag I have these for lines of code:
> >
> > &EXT('user.resource.resource.2.tries')<br />
> > &EXT('user.resource.resource.2.solved')<br />
> > &EXT('user.resource.resource.$external::part') <br />
> > $external::part<br />
> >
> > I complete the first part of the problem and then answer the second
> problem incorrectly thrice.  This is what shows up when I view the page as
> both an author and a student (both in the construction space and in the
> context of the course):
> >
> > 3
> > incorrect_attempted
> > &EXT('user.resource.resource.$external::part')
> > When calling this function, the argument should be something like
> >
> <display>&EXT('user.resource.resource.'.$external::part.'.solved')
> </display>  for example
> >
> > or assign it to a variable within the script tag.
> >
> >
> >
> > $external::part
> >
> > If you warped this with <display></display> it should show up. Or if you
> put it within the script tag and assign it to a variable then display the
> variable, it will work - I think.
> >
> > Hope that helps - hk
> >
> >
> >
> >
> >
> > I'm not sure if the $external function is not supported anymore or if I'm
> not calling it correctly.  I'm using Firefox 3 if this helps.
> >
> > On Wed, Mar 18, 2009 at 6:14 PM, Mark Lucas <lucasm@ohio.edu> wrote:
> > Sean Wolf wrote:
> > I'm having problems using $external::part from
> /res/msu/albertel/test/ext_examples.problem
> >
> > Basically, it doesn't do anything; it doesn't even return a blank, it just
> shows up as text.
> >
> > --
> > Sean Wolf
> > 2400 Ford St.
> > Golden, CO 80401
> > (720) 897-7763
> >
> > Sean,
> >
> > Can you give some context as to how you are using it and in what
> environment you are working (is this in construction space or in the context
> of a course?). I'm not sure if I can help, but whoever can will probably be
> looking for a snippet of code or the code to the sample problem in order to
> help debug.
> >
> > Later,
> > Mark
> >
> > _______________________________________________
> > LON-CAPA-users mailing list
> > LON-CAPA-users@mail.lon-capa.org
> >
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
> >
> >
> >
> >
> > --
> > Sean Wolf
> > 2400 Ford St.
> > Golden, CO 80401
> > (720) 897-7763
> >
>
>
>
> --
> Sean Wolf
> 2400 Ford St.
> Golden, CO 80401
> (720) 897-7763
>
>


-- 
Raymond J. Batchelor, Ph.D.
Department of Chemistry
Simon Fraser University
Burnaby, BC
Canada
V5A 1S8