--- loncom/homework/grades.pm 2007/06/16 20:24:25 1.414
+++ loncom/homework/grades.pm 2007/06/16 23:00:09 1.415
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.414 2007/06/16 20:24:25 www Exp $
+# $Id: grades.pm,v 1.415 2007/06/16 23:00:09 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6463,7 +6463,9 @@ ENDHEADER
# Get correct result
# FIXME: Possibly need delimiter other than ":"
my @correct=();
- if ($env{'form.gradingmechanism'} ne 'attendance') {
+ my $gradingmechanism=$env{'form.gradingmechanism'};
+ my $number=$env{'form.number'};
+ if ($gradingmechanism ne 'attendance') {
foreach my $key (keys(%env)) {
if ($key=~/^form\.correct\:/) {
my @input=split(/\,/,$env{$key});
@@ -6479,7 +6481,7 @@ ENDHEADER
}
}
}
- for (my $i=0;$i<$env{'form.number'};$i++) {
+ for (my $i=0;$i<$number;$i++) {
if (!$correct[$i]) {
$result.='
'.
&mt('No correct result given for question "[_1]"!',
@@ -6489,6 +6491,31 @@ ENDHEADER
$result.='
'.&mt("Correct answer: [_1]",join(', ',map { ($_?$_:'-') } @correct));
}
# Start grading
+ my $pcorrect=$env{'form.pcorrect'};
+ my $pincorrect=$env{'form.pincorrect'};
+ foreach my $key (keys(%env)) {
+ if ($key=~/^form\.student\:(.*)$/) {
+ my $user=$1;
+ my @answer=split(/\,/,$env{$key});
+ my $sum=0;
+ for (my $i=0;$i<$number;$i++) {
+ if ($answer[$i]) {
+ if ($gradingmechanism eq 'attendance') {
+ $sum+=$pcorrect;
+ } else {
+ if ($answer[$i] eq $correct[$i]) {
+ $sum+=$pcorrect;
+ } else {
+ $sum+=$pincorrect;
+ }
+ }
+ }
+ }
+ my $ave=$sum/$number;
+ $result.='
'.$user.' - '.$env{$key}.': '.$ave;
+ }
+ }
+# We are done
$result.=''."\n".
'
'."\n";
return $result.&show_grading_menu_form($symb);