[LON-CAPA-users] Custom Response Partial Credit

Jacob Bond bond13 at purdue.edu
Fri May 18 19:44:42 EDT 2018

Hi Gene,

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,

if ($total_score == 1) {return 'EXACT_ANS';}

else {return ('ASSIGNED_SCORE', $total_score);}

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.)

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 (ID should be replaced by the part ID of the problem part):

$partial_credit = &stored_data('awarded', ID) ? &stored_data('awarded', ID) : 0.0;



From: LON-CAPA-users <lon-capa-users-bounces at mail.lon-capa.org> on behalf of Harding, Gene L <glhardin at purdue.edu>
Sent: Friday, May 18, 2018 5:54:22 PM
To: Discussion list for LON-CAPA users
Subject: [LON-CAPA-users] Custom Response Partial Credit


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:

         if ($total_score == 1) { return 'EXACT_ANS'; }

           elsif ($total_score > 0) { return ('ASSIGNED_SCORE',$total_score); }

           else  { return 'INCORRECT'; }

         return ('ASSIGNED_SCORE',$total_score);

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:

<parameter name="retrypartial" type="string_yesno" description="Partially correct is answerable" default="yes" />

Can anyone see what I am doing wrong?

Thanks for any help/advice you can provide.

Best regards,

Gene L. Harding, PE

Associate Professor of ECET


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20180518/d4320cc0/attachment-0001.html>

More information about the LON-CAPA-users mailing list