--- loncom/homework/grades.pm 2007/10/11 22:34:33 1.454 +++ 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.454 2007/10/11 22:34:33 banghart Exp $ +# $Id: grades.pm,v 1.464 2007/10/25 20:05:52 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use Apache::loncommon; use Apache::lonhtmlcommon; use Apache::lonnavmaps; use Apache::lonhomework; +use Apache::lonpickcode; use Apache::loncoursedata; use Apache::lonmsg(); use Apache::Constants qw(:common); @@ -56,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}; @@ -71,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"}; @@ -86,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; @@ -1960,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". '
'.$env{'form.fullname'}.' | ||
---|---|---|
');
@@ -1990,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.='
| ||
'); + &Apache::lonpickcode::code_list($r,2); + $r->print(' |
Please indicate which bubble should be used for grading
"); foreach my $question (@{$arg}) { - my $selected = &get_response_bubbles($scan_record, $question); + my @select_array = split(/:/,$selected); &scantron_bubble_selector($r,$scan_config,$question, - split('',$selected)); + @select_array); } } elsif ($error eq 'missingbubble') { $r->print("There have been no bubbles scanned for some question(s)
\n"); @@ -6458,22 +6477,24 @@ ENDSCRIPT $r - Apache request object $scan_config - hash from &get_scantron_config() $quest - number of the bubble line to make a corrector for - $selected - array of letters of previously selected bubbles + $lines - array of answer lines. =cut sub scantron_bubble_selector { - my ($r,$scan_config,$quest,@selected)=@_; + my ($r,$scan_config,$quest,@lines)=@_; my $max=$$scan_config{'Qlength'}; + my $scmode=$$scan_config{'Qon'}; + my $bubble_length = scalar(@lines); + if ($scmode eq 'number' || $scmode eq 'letter') { $max=10; } my $response = $quest-1; my $lines = $bubble_lines_per_response{$response}; - &Apache::lonnet::logthis("Question $quest, lines: $lines"); my $total_lines = $lines*2; my @alphabet=('A'..'Z'); @@ -6483,11 +6504,7 @@ sub scantron_bubble_selector { if ($l != 0) { $r->print('