<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi Gene,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">It looks like</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">stored_data('tries', <b>ID</b>)</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">should get you what you want.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best,</p>
<p style="margin-top:0;margin-bottom:0">Jacob</p>
<p style="margin-top:0;margin-bottom:0"></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> LON-CAPA-users <lon-capa-users-bounces@mail.lon-capa.org> on behalf of Harding, Gene L <glhardin@purdue.edu><br>
<b>Sent:</b> Friday, May 18, 2018 10:27:33 PM<br>
<b>To:</b> Discussion list for LON-CAPA users<br>
<b>Subject:</b> Re: [LON-CAPA-users] Custom Response Partial Credit</font>
<div> </div>
</div>
<meta content="text/html; charset=us-ascii">
<meta name="x_Generator" content="Microsoft Word 15 (filtered medium)">
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
a:x_link, span.x_MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
a:x_visited, span.x_MsoHyperlinkFollowed
        {color:#954F72;
        text-decoration:underline}
p
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
p.x_msonormal0, li.x_msonormal0, div.x_msonormal0
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
p.x_xmsonormal, li.x_xmsonormal, div.x_xmsonormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
p.x_xmsochpdefault, li.x_xmsochpdefault, div.x_xmsochpdefault
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif}
span.x_xemailstyle17
        {font-family:"Calibri",sans-serif;
        color:windowtext}
span.x_EmailStyle22
        {font-family:"Calibri",sans-serif;
        color:#1F497D}
.x_MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
        {}
-->
</style>
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D">Hi Jacob,</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D">Thank you. I have managed to get it to respond correctly (red incorrect of total_score==0, tan partial credit if 0<total_score<1, and green correct if total_score==1).
 I have run quite a few tests and it seems to work fine with only this statement:</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D">        return ('ASSIGNED_SCORE',$total_score);</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D">I am still having one problem. There is a conditional block that shows a gnuplot of the correct answer if it is wrong and maxtries has been met. Before I
 converted to the customresponse the block worked fine, but now the &check_status function returns 1 no matter what, whether wrong, correct, or partially correct. Does that function not work with customresponse? If not, is there a LON-CAPA parameter for number
 of tries used? If so, I could compare that parameter to maxtries and do the same thing.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D">Best regards,</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<div>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:black">Gene L. Harding, PE</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:black">Associate Professor of ECET</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:black">574-520-4190</span><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"></span></p>
</div>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> LON-CAPA-users <lon-capa-users-bounces@mail.lon-capa.org>
<b>On Behalf Of </b>Jacob Bond<br>
<b>Sent:</b> Friday, May 18, 2018 7:45 PM<br>
<b>To:</b> Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org><br>
<b>Subject:</b> Re: [LON-CAPA-users] Custom Response Partial Credit</span></p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div id="x_divtagdefaultwrapper">
<p><span style="font-family:"Calibri",sans-serif; color:black">Hi Gene,</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">You're right that the last return statement shouldn't be there.  Also, there is a subtlety about returning 'INCORRECT' in a partial credit problem.  If a student submits an answer that gets 1/2
 credit, then changes it to an answer that gets 0 credit, returning 'INCORRECT' will leave the student with 1/2 credit.  Perhaps this is what you want, but if not,</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">if ($total_score == 1) {return 'EXACT_ANS';}</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">else {return ('ASSIGNED_SCORE', $total_score);}</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">will suffice (if you know $total_score is between 0 and 1, inclusive).  (Also, it's possible that you can forget about the if statement entirely, in case LON-CAPA knows that ('ASSIGNED_SCORE', 1)
 is the same as 'EXACT_ANS', but I've never bothered testing this.)</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">As for the real issue, it's tough to say what might be going wrong without seeing the rest of the code, but you might try computing $total_score locally in the answer block and see if that fixes
 anything.  If you want to check what credit the student has received, this will set $partial_credit to what credit the student has received, or 0 if the student hasn't attempted the problem yet (<b>ID</b> should be replaced by the part ID of the problem part):</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">$partial_credit = &stored_data('awarded',
<b>ID</b>) ? &stored_data('awarded', <b>ID</b>) : 0.0;</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">Best,</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">Jacob</span></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:black">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:black"> LON-CAPA-users <<a href="mailto:lon-capa-users-bounces@mail.lon-capa.org">lon-capa-users-bounces@mail.lon-capa.org</a>>
 on behalf of Harding, Gene L <<a href="mailto:glhardin@purdue.edu">glhardin@purdue.edu</a>><br>
<b>Sent:</b> Friday, May 18, 2018 5:54:22 PM<br>
<b>To:</b> Discussion list for LON-CAPA users<br>
<b>Subject:</b> [LON-CAPA-users] Custom Response Partial Credit</span> </p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal">Hi,</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">I rewrote the problem I have been working on so that it is now a custom response, but am having trouble getting it to properly grade the problem submission. This is the code for grading inside the answer block:</p>
<p class="x_xmsonormal">         if ($total_score == 1) { return 'EXACT_ANS'; }</p>
<p class="x_xmsonormal">           elsif ($total_score > 0) { return ('ASSIGNED_SCORE',$total_score); }</p>
<p class="x_xmsonormal">           else  { return 'INCORRECT'; }</p>
<p class="x_xmsonormal">         return ('ASSIGNED_SCORE',$total_score);</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">I have tried it with and without the second return statement, but either way the Correct/Partially Correct/Incorrect grading seems almost random. $total_score is computed in a perl script higher up in the program, and I am outputting
 it to verify that it is being computed correctly. I also have a retrypartial parameter at the top of the program because I want the students to be able to take three tries at it on the practice version:</p>
<p class="x_xmsonormal"><parameter name="retrypartial" type="string_yesno" description="Partially correct is answerable" default="yes" /></p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Can anyone see what I am doing wrong?</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Thanks for any help/advice you can provide.</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Best regards,</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal"><span style="color:black">Gene L. Harding, PE</span></p>
<p class="x_xmsonormal"><span style="color:black">Associate Professor of ECET</span></p>
<p class="x_xmsonormal"><span style="color:black">574-520-4190</span></p>
<p class="x_xmsonormal"> </p>
</div>
</div>
</div>
</div>
</body>
</html>