[LON-CAPA-users] Custom Response Partial Credit

Harding, Gene L glhardin at purdue.edu
Fri May 18 22:27:33 EDT 2018

Hi Jacob,

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:
        return ('ASSIGNED_SCORE',$total_score);

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.

Best regards,

Gene L. Harding, PE
Associate Professor of ECET

From: LON-CAPA-users <lon-capa-users-bounces at mail.lon-capa.org> On Behalf Of Jacob Bond
Sent: Friday, May 18, 2018 7:45 PM
To: Discussion list for LON-CAPA users <lon-capa-users at mail.lon-capa.org>
Subject: Re: [LON-CAPA-users] Custom Response Partial Credit

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<mailto:lon-capa-users-bounces at mail.lon-capa.org>> on behalf of Harding, Gene L <glhardin at purdue.edu<mailto: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/20180519/3277127c/attachment.html>

More information about the LON-CAPA-users mailing list