[system] / trunk / webwork / system / courseScripts / PGgraders.pl Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

Revision 164 Revision 165
151 (\%problem_result, \%problem_state); 151 (\%problem_result, \%problem_state);
152 152
153 153
154} 154}
155 155
156################################################################
157# This problem grader was contributed by Prof. Zig Fiedorowicz,
158# Dept. of Mathematics, Ohio State University on 8/25/01.
159# As written, the problem grader should be put in a separate macro file.
160# If actually inserted into a problem, you need to replace a couple
161# of backslashes by double tildes.
162
163# This is a generalization of the previous custom grader.
164# This grader expects two array references to be passed to it, eg.
167# Both arrays should be of the same length, and in strictly
168# increasing order. The first array is an array of possible
169# raw scores, the number of parts of the problem the student might
170# get right. The second array is the corresponding array of scores
171# the student would be credited with for getting that many parts
172# right. The scores should be real numbers between 0 and 1.
173# The last element of the 'grader_scores' array should be 1 (perfect
174# score). The corresponding last element of 'grader_numright' would
175# be the total number of parts of the problem the student would have
176# to get right for a perfect score. Normally this would be the total
177# number of parts to the problem. In the example shown above, the
178# student would get 10% credit for getting 2-4 parts right, 40%
179# credit for getting 5-6 parts right, 60% credit for getting 7-9 parts
180# right, and 100% credit for getting 10 (or more) parts right.
181# A message to be displayed to the student about the grading policy
182# for the problems should be passed via
184# or something similar.
185################################################################
186
187
190 my \$rh_problem_state = shift;
191 my %form_options = @_;
193 # The hash \$rh_evaluated_answers typically contains:
195
196 # By default the old problem state is simply passed back out again.
197 my %problem_state = %\$rh_problem_state;
198
199
200 # %form_options might include
201 # The user login name
202 # The permission level of the user
203 # The studentLogin name for this psvn.
204 # Whether the form is asking for a refresh or
205 # is submitting a new answer.
206
207 # initial setup of the answer
208 my \$total=0;
209 my %problem_result = ( score => 0,
210 errors => '',
213 );
214
215
216 # Return unless answers have been submitted
217 unless (\$form_options{answers_submitted} == 1) {
218
219 # Since this code is in a .pg file we must use double tildes
220 # instead of Perl's backslash on the next line.
221 return(\%problem_result,\%problem_state);
222 }
223 # Answers have been submitted -- process them.
224
225 ########################################################
226 # Here's where we compute the score. The variable #
227 # \$numright is the number of correct answers. #
228 ########################################################
229
230
231 my \$numright=0;
232 my \$i;
233 my \$ans_ref;
236
237
239 WARN("Scoring guidelines inconsistent: unequal arrays!");
240 }
243 WARN("Scoring guidelines inconsistent: raw scores not increasing!");
244 }
246 WARN("Scoring guidelines inconsistent: scores not increasing!");
247 }
248 }
250 WARN("Scoring guidelines inconsistent: best score < 1");
251 }
252 \$i = 1;
254 \$numright += \$ans_ref->{score};
255 \$i++;
256 }
257
261 }
262 }
263
264
265
266 \$problem_result{score} = \$total;
267 # increase recorded score if the current score is greater.
268 \$problem_state{recorded_score} = \$problem_result{score} if \$problem_result{score} > \$problem_state{recorded_score};
269
270
271
272 \$problem_state{num_of_correct_ans}++ if \$total == 1;
273 \$problem_state{num_of_incorrect_ans}++ if \$total < 1 ;
274
275 # Since this code is in a .pg file we must use double tildes
276 # instead of Perl's backslash on the next line.
277 (\%problem_result, \%problem_state);
278
279
280}
156 281
157 282
158# return 1 so that this file can be included with require 283# return 1 so that this file can be included with require
1591 2841

Legend:
 Removed from v.164 changed lines Added in v.165