--- loncom/homework/grades.pm 2007/06/15 22:12:49 1.408 +++ loncom/homework/grades.pm 2007/06/16 02:35:22 1.411 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.408 2007/06/15 22:12:49 albertel Exp $ +# $Id: grades.pm,v 1.411 2007/06/16 02:35:22 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6160,7 +6160,7 @@ sub gather_adv_clicker_ids { my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum); - foreach my $element (sort keys %coursepersonnel) { + foreach my $element (sort(keys(%coursepersonnel))) { foreach my $person (split(/\,/,$coursepersonnel{$element})) { my ($puname,$pudom)=split(/\:/,$person); my $clickers = @@ -6289,18 +6289,18 @@ sub process_clicker_file { $result.=&mt('Score based on attendance only'); } else { my $number=0; - $result.='

'.&mt('Correctness determined by the following IDs').'

'; + $result.='

'.&mt('Correctness determined by the following IDs').''; foreach my $id (sort(keys(%correct_ids))) { - $result.=''.$id.' - '; + $result.='
'.$id.' - '; if ($correct_ids{$id} eq 'specified') { $result.=&mt('specified'); } else { my ($uname,$udom)=split(/\:/,$correct_ids{$id}); $result.=&Apache::loncommon::plainname($uname,$udom); } - $result.='
'; $number++; } + $result.="

\n"; if ($number==0) { $result.=''.&mt('No IDs found to determine correct answer').''; return $result.&show_grading_menu_form($symb); @@ -6313,6 +6313,24 @@ sub process_clicker_file { ''.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').''); return $result.&show_grading_menu_form($symb); } + +# Were able to get all the info needed, now analyze the file + + $result.=&Apache::loncommon::studentbrowser_javascript(); + my $heading=&mt('Scanning clicker file'); + $result.=(<
+
+$heading
+
+ + + + + + + +ENDHEADER my %responses; my @questiontitles; my $errormsg=''; @@ -6320,10 +6338,34 @@ sub process_clicker_file { if ($env{'form.upfiletype'} eq 'iclicker') { ($errormsg,$number)=&iclicker_eval(\@questiontitles,\%responses); } - $result.='
'.&mt('Found [_1] questions',$number).'
'; - foreach my $id (keys %responses) { - $result.='
'.$id.' - '.$responses{$id}; + $result.='
'.&mt('Found [_1] question(s)',$number).'
'. + ''. + &mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses', + $env{'form.pcorrect'},$env{'form.pincorrect'}). + '
'; + my $correct_count=0; + my $student_count=0; + my $unknown_count=0; + foreach my $id (keys(%responses)) { + if ($correct_ids{$id}) { + $result.="\n".''; + $correct_count++; + } elsif ($clicker_ids{$id}) { + $result.="\n".''; + $student_count++; + } else { + $result.="\n
".&mt('Unregistered Clicker')." ".$id."
"; + $result.="\n".''. + "\n".&mt("Username").":  ". + "\n".&mt("Domain").": ". + &Apache::loncommon::select_dom_form($env{'course.'.$env{'request.course.id'}.'.domain'},'udom'.$id).' '. + &Apache::loncommon::selectstudent_link('clickeranalysis','uname'.$id,'udom'.$id); + $unknown_count++; + } } + $result.='

 

'; + $result.='
'."\n". + '


'."\n"; return $result.&show_grading_menu_form($symb); } @@ -6332,14 +6374,8 @@ sub iclicker_eval { my $number=0; my $errormsg=''; foreach my $line (split(/[\n\r]/,$env{'form.upfile'})) { - chomp($line); - foreach my $quoted ($line=~/\,\s*\"([^\"]*)\"\s*\,/g) { - my $replace=$quoted; - $replace=~s/\,//g; - &Apache::lonnet::logthis($quoted.' - '.$replace.'
'); - $line=~s/\,\s*\"\Q$quoted\E\"\s*\,/,$replace,/gs; - } - my @entries=split(/\,/,$line); + my %components=&Apache::loncommon::record_sep($line); + my @entries=map {$components{$_}} (sort(keys(%components))); if ($entries[0] eq 'Question') { for (my $i=3;$i<$#entries;$i+=6) { $$questiontitles[$number]=$entries[$i];