--- loncom/homework/grades.pm 2011/01/23 01:04:21 1.643 +++ loncom/homework/grades.pm 2011/02/07 00:53:10 1.644 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.643 2011/01/23 01:04:21 www Exp $ +# $Id: grades.pm,v 1.644 2011/02/07 00:53:10 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -8841,7 +8841,7 @@ sub process_clicker_file { if ($env{'form.gradingmechanism'} eq 'given') { $env{'form.givenanswer'}=~s/^\s*//gs; $env{'form.givenanswer'}=~s/\s*$//gs; - $env{'form.givenanswer'}=~s/[^a-zA-Z0-9\.\*\-]+/\,/g; + $env{'form.givenanswer'}=~s/[^a-zA-Z0-9\.\*\-\+]+/\,/g; $env{'form.givenanswer'}=uc($env{'form.givenanswer'}); my @answers=split(/\,/,$env{'form.givenanswer'}); $foundgiven=$#answers+1; @@ -9019,6 +9019,7 @@ sub iclicker_eval { $id=~s/^[\#0]+//; for (my $i=0;$i<$number;$i++) { my $idx=3+$i*6; + $entries[$idx]=~s/[^a-zA-Z0-9\.\*\-\+]+//g; push(@idresponses,$entries[$idx]); } $$responses{$id}=join(',',@idresponses); @@ -9090,20 +9091,20 @@ sub assign_clicker_grades { $result.='
'. &mt('More than one correct result given for question "[_1]": [_2] versus [_3].', $env{'form.question:'.$i},$correct[$i],$input[$i]).''; - } elsif ($input[$i]) { + } elsif (($input[$i]) || ($input[$i] eq '0')) { $correct[$i]=$input[$i]; } } } } for (my $i=0;$i<$number;$i++) { - if (!$correct[$i]) { + if ((!$correct[$i]) && ($correct[$i] ne '0')) { $result.='
'. &mt('No correct result given for question "[_1]"!', $env{'form.question:'.$i}).''; } } - $result.='
'.&mt("Correct answer: [_1]",join(', ',map { ($_?$_:'-') } @correct)); + $result.='
'.&mt("Correct answer: [_1]",join(', ',map { ((($_) || ($_ eq '0'))?$_:'-') } @correct)); } # Start grading my $pcorrect=$env{'form.pcorrect'}; @@ -9136,17 +9137,29 @@ sub assign_clicker_grades { for (my $i=0;$i<$number;$i++) { if ($correct[$i] eq '-') { $realnumber--; - } elsif ($answer[$i]) { + } elsif (($answer[$i]) || ($answer[$i]=~/^[0\.]+$/)) { if ($gradingmechanism eq 'attendance') { $sum+=$pcorrect; } elsif ($correct[$i] eq '*') { $sum+=$pcorrect; } else { - if ($answer[$i] eq $correct[$i]) { - $sum+=$pcorrect; - } else { - $sum+=$pincorrect; +# We actually grade if correct or not + my $increment=$pincorrect; +# Special case: numerical answer "0" + if ($correct[$i] eq '0') { + if ($answer[$i]=~/^[0\.]+$/) { + $increment=$pcorrect; + } +# General numerical answer, both evaluate to something non-zero + } elsif ((1.0*$correct[$i]!=0) && (1.0*$answer[$i]!=0)) { + if (1.0*$correct[$i]==1.0*$answer[$i]) { + $increment=$pcorrect; + } +# Must be just alphanumeric + } elsif ($answer[$i] eq $correct[$i]) { + $increment=$pcorrect; } + $sum+=$increment; } } }