--- loncom/homework/grades.pm 2007/10/15 09:47:47 1.459 +++ loncom/homework/grades.pm 2007/10/25 20:05:52 1.464 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.459 2007/10/15 09:47:47 foxr Exp $ +# $Id: grades.pm,v 1.464 2007/10/25 20:05:52 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -57,9 +57,7 @@ my %first_bubble_line = (); # First bubb sub save_bubble_lines { - &Apache::lonnet::logthis("Saving bubble_lines..."); foreach my $line (keys(%bubble_lines_per_response)) { - &Apache::lonnet::logthis("Saving form.scantron.bubblelines.$line value: $bubble_lines_per_response{$line}"); $env{"form.scantron.bubblelines.$line"} = $bubble_lines_per_response{$line}; $env{"form.scantron.first_bubble_line.$line"} = $first_bubble_line{$line}; @@ -72,7 +70,6 @@ sub restore_bubble_lines { %bubble_lines_per_response = (); while ($env{"form.scantron.bubblelines.$line"}) { my $value = $env{"form.scantron.bubblelines.$line"}; - &Apache::lonnet::logthis("Restoring form.scantron.bubblelines.$line value: $value"); $bubble_lines_per_response{$line} = $value; $first_bubble_line{$line} = $env{"form.scantron.first_bubble_line.$line"}; @@ -87,12 +84,14 @@ sub restore_bubble_lines { sub get_response_bubbles { my ($parsed_line, $response) = @_; - my $bubble_line = $first_bubble_line{$response}; - my $bubble_lines= $bubble_lines_per_response{$response}; + + my $bubble_line = $first_bubble_line{$response-1} +1; + my $bubble_lines= $bubble_lines_per_response{$response-1}; + my $selected = ""; for (my $bline = 0; $bline < $bubble_lines; $bline++) { - $selected .= $$parsed_line{"scantron.$bubble_line.answer"}; + $selected .= $$parsed_line{"scantron.$bubble_line.answer"}.":"; $bubble_line++; } return $selected; @@ -1961,7 +1960,7 @@ KEYWORDS # This is where output for one specific student would start my $bgcolor='#DDEEDD'; - if (int($counter/2) eq $counter) { $bgcolor='#DDDDEE'; } + if ($counter%2) { $bgcolor='#DDDDEE'; } $request->print("\n\n". '

'); } - - # FIXME: This loop probably has to be considerably more clever for - # multiline bubbles: User can multibubble by having bubbles in - # several lines. User can skip lines legitimately etc. etc. - + my @selected = split(//,$lines[$l]); for (my $i=0;$i<$max;$i++) { $r->print("\n".'
'.$env{'form.fullname'}.'
'); @@ -1991,60 +1990,13 @@ KEYWORDS '" value="'.$env{'form.fullname'}.'" />'."\n"; # If any part of the problem is an essay-response (handgraded), then check for collaborators - my @col_fullnames; - my ($classlist,$fullname); + my $fullname; + my $col_fullnames = []; if ($env{'form.handgrade'} eq 'yes') { - ($classlist,undef,$fullname) = &getclasslist('all','0'); - for (keys (%$handgrade)) { - my $ncol = &Apache::lonnet::EXT('resource.'.$_. - '.maxcollaborators', - $symb,$udom,$uname); - next if ($ncol <= 0); - s/\_/\./g; - next if ($record{'resource.'.$_.'.collaborators'} eq ''); - my @goodcollaborators = (); - my @badcollaborators = (); - foreach (split(/,?\s+/,$record{'resource.'.$_.'.collaborators'})) { - $_ =~ s/[\$\^\(\)]//g; - next if ($_ eq ''); - my ($co_name,$co_dom) = split /\@|:/,$_; - $co_dom = $udom if (! defined($co_dom) || $co_dom =~ /^domain$/i); - next if ($co_name eq $uname && $co_dom eq $udom); - # Doing this grep allows 'fuzzy' specification - my @Matches = grep /^$co_name:$co_dom$/i,keys %$classlist; - if (! scalar(@Matches)) { - push @badcollaborators,$_; - } else { - push @goodcollaborators, @Matches; - } - } - if (scalar(@goodcollaborators) != 0) { - $result.='Collaborators: '; - foreach (@goodcollaborators) { - my ($lastname,$givenn) = split(/,/,$$fullname{$_}); - push @col_fullnames, $givenn.' '.$lastname; - $result.=$$fullname{$_}.'     '; - } - $result.='
'."\n"; - my ($part)=split(/\./,$_); - $result.=''. - "\n"; - } - if (scalar(@badcollaborators) > 0) { - $result.='
'; - $result.='This student has submitted '; - $result.=(scalar(@badcollaborators) == 1) ? 'an invalid collaborator' : 'invalid collaborators'; - $result .= ': '.join(', ',@badcollaborators); - $result .= '
'; - } - if (scalar(@badcollaborators > $ncol)) { - $result .= '
'; - $result .= 'This student has submitted too many '. - 'collaborators. Maximum is '.$ncol.'.'; - $result .= '
'; - } - } + (my $sub_result,$fullname,$col_fullnames)= + &check_collaborators($symb,$uname,$udom,\%record,$handgrade, + $counter); + $result.=$sub_result; } $request->print($result."\n"); @@ -2180,16 +2132,16 @@ KEYWORDS if ($env{'form.handgrade'} eq 'yes') { my ($lastname,$givenn) = split(/,/,$env{'form.fullname'}); my $msgfor = $givenn.' '.$lastname; - if (scalar(@col_fullnames) > 0) { - my $lastone = pop @col_fullnames; - $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.'; + if (scalar(@$col_fullnames) > 0) { + my $lastone = pop(@$col_fullnames); + $msgfor .= ', '.(join ', ',@$col_fullnames).' and '.$lastone.'.'; } $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript $result=''."\n". ''."\n"; $result.=' '. - &mt('Compose message to student').(scalar(@col_fullnames) >= 1 ? 's' : '').'
'); if ($selected[0] eq $alphabet[$i]) { @@ -6737,14 +6754,11 @@ sub scantron_validate_doublebubble { =cut sub scantron_get_maxbubble { - &Apache::lonnet::logthis("get_max_bubble"); if (defined($env{'form.scantron_maxbubble'}) && $env{'form.scantron_maxbubble'}) { - &Apache::lonnet::logthis("cached"); &restore_bubble_lines(); return $env{'form.scantron_maxbubble'}; } - &Apache::lonnet::logthis("computing"); my (undef, undef, $sequence) = &Apache::lonnet::decode_symb($env{'form.selectpage'}); @@ -6782,9 +6796,9 @@ sub scantron_get_maxbubble { foreach my $part_id (@{$analysis{'parts'}}) { - my ($trash, $part) = split(/\./, $part_id); - my $lines = $analysis{"$part_id.bubble_lines"}[0]; + + my $lines = $analysis{"$part_id.bubble_lines"};; # TODO - make this a persistent hash not an array. @@ -7190,10 +7204,6 @@ sub grading_menu { my $probTitle = &Apache::lonnet::gettitle($symb); my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle); - # - # Define menu data - $env{'form.probTitle'} = &Apache::lonnet::gettitle($symb); - my ($table) = &showResourceInfo($symb,$env{'form.probTitle'}); $request->print($table); my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb), 'handgrade'=>$hdgrade, @@ -8071,7 +8081,6 @@ sub handler { } elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) { $request->print(&csvuploadassign($request)); } elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) { - &Apache::lonnet::logthis("Selecting pyhase"); $request->print(&scantron_selectphase($request)); } elsif ($command eq 'scantron_warning' && $perm{'mgr'}) { $request->print(&scantron_do_warning($request));