Forum archive 2000-2006

Gregg Klein - Partial Credit Scenerio

by Arnold Pizer -
Number of replies: 0
 Partial Credit Scenerio topic started 7/2/2002; 6:17:44 PMlast post 7/5/2002; 5:26:40 AM
 Gregg Klein - Partial Credit Scenerio  7/2/2002; 6:17:44 PM (reads: 1184, responses: 3) Can WebWorK be set up so that a particular problem set (or problem) is scored in the following manner. Let's say a problem is worth 5 points initially, but for each time a user tries to submit an answer (wrong one of course) a specified number of points is subtracted. Thanks in advance. Gregg <| Post or View Comments |>

 Gavin LaRose - Re: Partial Credit Scenerio  7/3/2002; 1:08:23 AM (reads: 1454, responses: 0) Hi Gregg, I wrote an incremental_grader which we used for a while and then dropped in favor of just limiting the number of submissions allowed for a problem. The idea is essentially what you've said: on the first however many submissions full credit should be possible, and then after some number the amount of credit one can get should decrease. We used it to give full credit for up to four submissions, then drop to 70%, 50%, 30% or 10% on the next four, with no credit given after that. I wrote it a while ago, so I won't swear that it's the most elegant way of doing this, but I append it below for your information. I do think it works, at least. @penalty is actually the amount of credit that one can get on each submission, @penPerc is the same thing but written as a percent because I'm lazy and didn't bother to format the entries in @penalty for printing out. Note that the values of @penPerc are explicitly referenced in the body of the routine, so that if the length of the array changed it would be necessary to also edit that. Also, I had this in a macro file for the course, so all of the backslashes are backslashes instead of double tildes. I hope this is useful. Cheers, Gavin sub incremental_grader {# grader to give partial credit on subsequent attempts. all parts of # the problem must be correct to get credit; if this is done on the # attempt $n,$penalty[$n] credit is given. # standard input my$rh_evaluated_answers = shift; my $rh_problem_state = shift; my %form_options = @_; # the hash %$rh_evaluated_answers contains the answers supplied: # 'AnSwEr1' => 'supplied answer', 'AnSwEr2' => 'next answer', # etc. # the hash %$rh_problem_state is the current state of the problem. # %form_options might include the user login name, the permission # level of the user, the studentLogin name for this psvn, # whether the form is asking for a refresh or is submitting # a new answer, etc. # by default, return current problem state my %problem_state = %$rh_problem_state; # penalty for subsequent submissions my @penalty = ( 1, 1, 1, 1, 0.7, 0.5, 0.3, 0.1, 0 ); my @penPerc = ( '100%', '100%', '100%', '100%', '70%', '50%', '30%', '10%' ); my %problem_result = # initialize result (score => 0, errors => '', type => 'incremental_grader', msg => "Credit for this problem decreases with " . "subsequent attempts: on the first four, $penPerc[0] " . "is possible; " . "after that,$penPerc[4], $penPerc[5],$penPerc[6]," . " and " . "$penPerc[7] may be earned."); # if answers were submitted, figure out which were correct if ($form_options{'answers_submitted'} ) { my $total = 0; foreach ( keys %$rh_evaluated_answers ) { $total += $$rh_evaluated_answers{_}->{'score'} if ( defined($$rh_evaluated_answers{$_}->{'score'}) ); } my $numPossible = scalar(keys %$rh_evaluated_answers); my $numTimes =$main::envir{'numOfAttempts'} - 1; $numTimes = @penalty if ($numTimes > @penalty); # update score for problem; check if the problem is already # correct, and if not update it accordingly my ($inCorrect,$correct, $probScore) = (0, 0, 0);$correct = $problem_state{'num_of_correct_ans'} if ( defined($problem_state{'num_of_correct_ans'}) ); $inCorrect =$problem_state{'num_of_incorrect_ans'} if ( defined($problem_state{'num_of_incorrect_ans'}) );$probScore = $problem_state{'recorded_score'} if ( defined($problem_state{'recorded_score'}) ); if ( $total ==$numPossible ) { $probScore =$penalty[$numTimes] if ( !$correct ); $correct++; } else {$inCorrect++; } # and we return... $problem_result{'score'} =$total/$numPossible;$problem_result{'errors'} = ''; $problem_result{'type'} = 'incremental_grader';$problem_result{'msg'} = "Credit for this problem decreases" . " with " . "subsequent attempts: on the first four, $penPerc[0] is" . " possible; " . "after that,$penPerc[4], $penPerc[5],$penPerc[6], " . "and $penPerc[7] may be earned.";$problem_state{'recorded_score'} = $probScore;$problem_state{'num_of_correct_ans'} = $correct;$problem_state{'num_of_incorrect_ans'} = $inCorrect; } return ( %problem_result, %problem_state );} <| Post or View Comments |>  Gregg Klein - Re: Partial Credit Scenerio 7/4/2002; 5:16:03 AM (reads: 1438, responses: 0) Gavin,Thanks! I will try it. I'm not real sure how to implement (make it work) it but I will take a stab at it. Any advice will be helpful. I am new to webwork. I have not worked with macros before. I tried to make it work but could not. Please help! Regards, Gregg <| Post or View Comments |>  Gavin LaRose - Re: Partial Credit Scenerio 7/5/2002; 5:26:40 AM (reads: 1462, responses: 0) Hi Gregg, I ended up with a file of local macros for the course that I was working on and put the incremental grader there. That is, in my .../webwork/courses/CourseName/templates/macros directory I had a file which I called PGextensions.pl that contained the incremental grader subroutine. If you do this, also check in the webworkCourse.ph file in the course directory that the line$macroDirectory = "\${templateDirectory}macros/"; is not commented out. Then in your problem file include PGextensions.pl in the list of arguments for the loadMacros command at the top of the file and include the line install_problem_grader(~~&incremental_grader); to select the incremental grader. Let me know if that doesn't work. As a side note, I think I might have edited something to make the problem always display the number of attempts that had been made at the problem (I think the default is to do it after some number of attempts) so that students at least theoretically could always figure out where they were in terms of the credit they could get for submitting a problem. If you notice that this would be useful I can figure out where that was. Cheers, Gavin <| Post or View Comments |>