<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">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,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">if ($total_score == 1) {return 'EXACT_ANS';}</p>
<p style="margin-top:0;margin-bottom:0">else {return ('ASSIGNED_SCORE', $total_score);}</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">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.)</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">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):</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span>$partial_credit = &stored_data('awarded',
<b>ID</b>) ? &stored_data('awarded', <b>ID</b>) : 0.0;</span><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span>Best,</span></p>
<p style="margin-top:0;margin-bottom:0"><span>Jacob</span></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 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</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:11.0pt;
        font-family:"Calibri",sans-serif}
a:x_link, span.x_MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
a:x_visited, span.x_MsoHyperlinkFollowed
        {color:#954F72;
        text-decoration:underline}
span.x_EmailStyle17
        {font-family:"Calibri",sans-serif;
        color:windowtext}
.x_MsoChpDefault
        {font-family:"Calibri",sans-serif}
@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">Hi,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">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_MsoNormal">         if ($total_score == 1) { return 'EXACT_ANS'; }</p>
<p class="x_MsoNormal">           elsif ($total_score > 0) { return ('ASSIGNED_SCORE',$total_score); }</p>
<p class="x_MsoNormal">           else  { return 'INCORRECT'; }</p>
<p class="x_MsoNormal">         return ('ASSIGNED_SCORE',$total_score);</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">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_MsoNormal"><parameter name="retrypartial" type="string_yesno" description="Partially correct is answerable" default="yes" /></p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Can anyone see what I am doing wrong?</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Thanks for any help/advice you can provide.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Best regards,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"><span style="color:black">Gene L. Harding, PE</span></p>
<p class="x_MsoNormal"><span style="color:black">Associate Professor of ECET</span></p>
<p class="x_MsoNormal"><span style="color:black">574-520-4190</span></p>
<p class="x_MsoNormal"> </p>
</div>
</div>
</body>
</html>