--- loncom/homework/grades.pm 2007/06/16 14:38:45 1.413 +++ loncom/homework/grades.pm 2007/06/16 20:24:25 1.414 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.413 2007/06/16 14:38:45 www Exp $ +# $Id: grades.pm,v 1.414 2007/06/16 20:24:25 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6144,7 +6144,7 @@ sub gather_clicker_ids { my $clickers = (&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1]; foreach my $id (split(/\,/,$clickers)) { - $id=~s/^0+//; + $id=~s/^[\#0]+//; if (exists($clicker_ids{$id})) { $clicker_ids{$id}.=','.$username.':'.$domain; } else { @@ -6166,7 +6166,7 @@ sub gather_adv_clicker_ids { my $clickers = (&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1]; foreach my $id (split(/\,/,$clickers)) { - $id=~s/^0+//; + $id=~s/^[\#0]+//; if (exists($clicker_ids{$id})) { $clicker_ids{$id}.=','.$puname.':'.$pudom; } else { @@ -6219,7 +6219,7 @@ sub process_clicker { my $type=&mt("Type"); my $attendance=&mt("Award points just for participation"); my $personnel=&mt("Correctness determined from response by course personnel"); - my $specific=&mt("Correctness determined from response with clicker ID"); + my $specific=&mt("Correctness determined from response with clicker ID(s)"); my $pcorrect=&mt("Percentage points for correct solution"); my $pincorrect=&mt("Percentage points for incorrect solution"); my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype', @@ -6275,7 +6275,7 @@ function sanitycheck() {


- +

@@ -6308,11 +6308,14 @@ sub process_clicker_file { %correct_ids=&gather_adv_clicker_ids(); } if ($env{'form.gradingmechanism'} eq 'specific') { - my $correct_id=$env{'form.specificid'}; - $correct_id=~tr/a-z/A-Z/; - $correct_id=~s/\s//gs; - $correct_id=~s/^0+//; - $correct_ids{$correct_id}='specified'; + foreach my $correct_id (split(/[\s\,]/,$env{'form.specificid'})) {; + $correct_id=~tr/a-z/A-Z/; + $correct_id=~s/\s//gs; + $correct_id=~s/^[\#0]+//; + if ($correct_id) { + $correct_ids{$correct_id}='specified'; + } + } } if ($env{'form.gradingmechanism'} eq 'attendance') { $result.=&mt('Score based on attendance only'); @@ -6372,12 +6375,20 @@ ENDHEADER &mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses', $env{'form.pcorrect'},$env{'form.pincorrect'}). '
'; +# Remember Question Titles +# FIXME: Possibly need delimiter other than ":" + for (my $i=0;$i<$number;$i++) { + $result.='').'" />'; + } my $correct_count=0; my $student_count=0; my $unknown_count=0; +# Match answers with usernames +# FIXME: Possibly need delimiter other than ":" foreach my $id (keys(%responses)) { if ($correct_ids{$id}) { - $result.="\n".''; + $result.="\n".''; $correct_count++; } elsif ($clicker_ids{$id}) { $result.="\n".''; @@ -6398,7 +6409,7 @@ ENDHEADER if ($correct_count==0) { $errormsg.="Found no correct answers answers for grading!"; } elsif ($correct_count>1) { - $result.='
'.&mt("Found [_1] entries for grading!").''; + $result.='
'.&mt("Found [_1] entries for grading!",$correct_count).''; } } if ($errormsg) { @@ -6438,6 +6449,51 @@ sub iclicker_eval { return ($errormsg,$number); } +sub assign_clicker_grades { + my ($r)=@_; + my ($symb)=&get_symb($r); + if (!$symb) {return '';} + my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); + my $heading=&mt('Assigning grades based on clicker file'); + $result.=(<
+
+$heading
+ENDHEADER +# Get correct result +# FIXME: Possibly need delimiter other than ":" + my @correct=(); + if ($env{'form.gradingmechanism'} ne 'attendance') { + foreach my $key (keys(%env)) { + if ($key=~/^form\.correct\:/) { + my @input=split(/\,/,$env{$key}); + for (my $i=0;$i<=$#input;$i++) { + if (($correct[$i]) && ($input[$i]) && + ($correct[$i] ne $input[$i])) { + $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]) { + $correct[$i]=$input[$i]; + } + } + } + } + for (my $i=0;$i<$env{'form.number'};$i++) { + if (!$correct[$i]) { + $result.='
'. + &mt('No correct result given for question "[_1]"!', + $env{'form.question:'.$i}).''; + } + } + $result.='
'.&mt("Correct answer: [_1]",join(', ',map { ($_?$_:'-') } @correct)); + } +# Start grading + $result.='
'."\n". + '


'."\n"; + return $result.&show_grading_menu_form($symb); +} + sub handler { my $request=$_[0]; @@ -6509,6 +6565,8 @@ sub handler { $request->print(&process_clicker($request)); } elsif ($command eq 'processclickerfile' && $perm{'mgr'}) { $request->print(&process_clicker_file($request)); + } elsif ($command eq 'assignclickergrades' && $perm{'mgr'}) { + $request->print(&assign_clicker_grades($request)); } elsif ($command eq 'csvform' && $perm{'mgr'}) { $request->print(&upcsvScores_form($request)); } elsif ($command eq 'csvupload' && $perm{'mgr'}) {