Had another duh moment, figure it out, and finished the problem. Apologize for 
spamming the listserv.
Best regards,

Gene L. Harding, PE
Associate Professor of ECET
Purdue University
574-520-4190
https://polytechnic.purdue.edu/south-bend/


-----Original Message-----
From: Harding, Gene L 
Sent: Thursday, March 26, 2020 3:14 PM
To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org>
Subject: RE: [LON-CAPA-users] Custom Response Question

That worked. But now, when the problem is processed as correct, it displays 
blanks instead of the correct values in the matrix. Is there a way to get it to 
display the correct values? I know how to also test the conditions for correct 
answer or maxtries exceeded, but how do I display the matrix element values 
instead of blanks...?

Gene L. Harding, PE
Associate Professor of ECET
Purdue University
574-520-4190
https://polytechnic.purdue.edu/south-bend/


-----Original Message-----
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> On Behalf Of 
Harding, Gene L
Sent: Thursday, March 26, 2020 2:53 PM
To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org>
Subject: Re: [LON-CAPA-users] Custom Response Question

Ooooh. I just remembered that I must use eq, not == when evaluating strings. 
I'm redoing that portion right now, and it seems to be working.

I am, however, open to ideas how to do it better, if anyone wants to offer them.

BR,

Gene L. Harding, PE
Associate Professor of ECET
Purdue University
574-520-4190
https://polytechnic.purdue.edu/south-bend/


-----Original Message-----
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> On Behalf Of 
Harding, Gene L
Sent: Thursday, March 26, 2020 2:41 PM
To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org>
Subject: Re: [LON-CAPA-users] Custom Response Question

Hi Mark,

Sure. The problem requires students to "write" a matrix equation. I was going 
to include a snip of the displayed XML, but this email format will not allow me 
to paste a figure.

This is the perl script:
    <answer type="loncapa/perl"> 
         $total_score = 0;
         # These submission variables appear to be local to this perl script 
section only.
         ($ZR11,$ZX11,$ZR12,$ZX12,$ZR13,$ZX13,$I11,$E11mag,$E11ph,
          $ZR21,$ZX21,$ZR22,$ZX22,$ZR23,$ZX23,$I21,$E21mag,$E21ph,
          $ZR31,$ZX31,$ZR32,$ZX32,$ZR33,$ZX33,$I31,$E31mag,$E31ph) = 
@$submission;

   # In these if stmts, conditionals cannot distinguish between 0 and null, 
   # and counts null or any string as correct for "I1", "I2", or "I3"
        if ($ZR11==$R1      && $ZX11==-$X_C1)       {$total_score = 1/15;}
        if ($ZR12==-$R1     && $ZX12=="0")          {$total_score = 
$total_score + 1/15;} 
        if ($ZR13=="0"      && $ZX13=="0")          {$total_score = 
$total_score + 1/15;}
        if ($ZR21==-$R1     && $ZX21==0)            {$total_score = 
$total_score + 1/15;}
        if ($ZR22==$R1      && $ZX22==$X_L1-$X_C2)  {$total_score = 
$total_score + 1/15;}
        if ($ZR23==0        && $ZX23==$X_C2)        {$total_score = 
$total_score + 1/15;}
        if ($ZR31==0        && $ZX31==0)            {$total_score = 
$total_score + 1/15;}
        if ($ZR32==0        && $ZX32==$X_C2)        {$total_score = 
$total_score + 1/15;}
        if ($ZR33==$R2      && $ZX33==-$X_C2-$X_C3) {$total_score = 
$total_score + 1/15;}
        if ($I11=="I1")                             {$total_score = 
$total_score + 1/15;}
        if ($I21=="I2")                             {$total_score = 
$total_score + 1/15;}
        if ($I31=="I3")                             {$total_score = 
$total_score + 1/15;}
        if ($E11mag==$E1mag && $E11ph==$E1ph)       {$total_score = 
$total_score + 1/15;}
        if ($E21mag==$E2mag && $E21ph==$E2ph)       {$total_score = 
$total_score + 1/15;}
        if ($E31mag==0      && $E31ph==0)           {$total_score = 
$total_score + 1/15;}

        return ('ASSIGNED_SCORE',$total_score); 
    </answer>

The equation is a 3x3 impedance (Z) matrix multiplied by a 3-element current 
column vector to get a 3-element voltage column vector. The Z matrix elements 
are complex values in rectangular form, but the real and imaginary parts are 
processed separately as real integers. That part works fine. The problem is 
that nothing needs to be entered at all for the zero values; no entry is still 
evaluated as correct. As you can see above, I have tried processing them as 
both numeric (0) and text ("0") but neither approach works.

The intent of the current column vector elements (the variables in this 
equation) is for students to enter the variables as text values: I1, I2, and I3.

The voltage column vector elements are complex values in polar form, magnitude 
in V and phase in degrees. Both values are processed as real numbers.

The XML displays appropriate units by each element of the Z matrix and V column 
vector, so no units processing is needed.

The order of the variables in the submission input/assignment statement is 
dictated by the XML display of the matrix. The other variables, like $R1, 
$X_C2, $E2ph, etc., are given variables from the perl script at the beginning 
of the problem.

BR,

Gene L. Harding, PE
Associate Professor of ECET
Purdue University
574-520-4190
https://polytechnic.purdue.edu/south-bend/

-----Original Message-----
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> On Behalf Of 
Lucas, Mark
Sent: Thursday, March 26, 2020 2:18 PM
To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org>
Subject: Re: [LON-CAPA-users] Custom Response Question

Gene,

Could you post sample variables and perhaps an example of the perl you are 
trying to use?
What does the array look like? What are some typical variables? (or at least 
analogs if you don’t want to give away content).

Mark

> On Mar 26, 2020, at 2:14 PM, Harding, Gene L <glhar...@purdue.edu> wrote:
> 
> Hi,
>  
> I am trying to do something with a customresponse part that I cannot do 
> really cleanly with normal response types, but am having some trouble 
> evaluating the inputs. The inputs include numeric and text values as part of 
> a single array input. I am having to problems:
> 1.       I have not been able to figure out a way, in the “if” statements, to 
> distinguish between a zero (0) answer and a null (“”) answer.
> 2.       The string components evaluate to true for any text value. Only 
> numeric entries evaluate as false.
>  
> My questions:
> 1.       Is there a way to distinguish between a 0 and a null (i.e., no) 
> response?
> 2.       Is it possible to input both numeric and string values in separate 
> textline inputs within one customresponse section?
>  
> Best regards,
>  
> Gene L. Harding, PE
> Associate Professor of ECET
> Purdue University
> 574-520-4190
> https://polytechnic.purdue.edu/south-bend/
>  
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> https://nam03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.
> lon-capa.org%2Fmailman%2Flistinfo%2Flon-capa-users&amp;data=02%7C01%7C
> lucasm%40ohio.edu%7Ce9661e81abe94f8dee6a08d7d1b1a400%7Cf3308007477c4a7
> 0888934611817c55a%7C0%7C0%7C637208433204394095&amp;sdata=pc8Q9TIuMr9Jn
> d6QU5ew62C9XjFU7XKCzY%2BcXlc40Mg%3D&amp;reserved=0

-- 
Mark Lucas                                                              email: 
luc...@ohio.edu
252D Clippinger Lab                                             phone: 
(740)597-2984
Department of Physics and Astronomy                     fax: (740)593-0433
Ohio University
Athens, OH 45701

_______________________________________________
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
_______________________________________________
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

Reply via email to