--- loncom/homework/grades.pm 2007/10/11 21:27:50 1.453 +++ loncom/homework/grades.pm 2007/10/17 09:40:49 1.460 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.453 2007/10/11 21:27:50 banghart Exp $ +# $Id: grades.pm,v 1.460 2007/10/17 09:40:49 foxr 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,8 +84,10 @@ 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++) { @@ -529,8 +529,8 @@ sub getclasslist { my @stu_groups = split(/,/,$group); if (@getgroup) { my $exclude = 1; - foreach my $grp(@getgroup) { - foreach my $stu_group(@stu_groups) { + foreach my $grp (@getgroup) { + foreach my $stu_group (@stu_groups) { if ($stu_group eq $grp) { $exclude = 0; } @@ -4893,11 +4893,10 @@ SCANTRONFORM SCANTRONFORM - $r->print(< -$grading_menu_button -SCANTRONFORM - + $r->print(''); + &Apache::lonpickcode::code_list($r,2); + $r->print(''); + $r->print($grading_menu_button); return } @@ -5269,7 +5268,12 @@ sub scantron_parse_scanline { || (&occurence_count($currentquest, "[A-Z]") > 1)) { push(@{$record{'scantron.doubleerror'}},$questnum); for (my $ans = 0; $ans < $answers_needed; $ans++) { - $record{"scantron.$ansnum.answer"}=''; + my $bubble = substr($currentquest, $ans, 1); + if ($bubble =~ /[A-Z]/ ) { + $record{"scantron.$ansnum.answer"} = $bubble; + } else { + $record{"scantron.$ansnum.answer"}=''; + } $ansnum++; } @@ -5304,7 +5308,12 @@ sub scantron_parse_scanline { || (&occurence_count($currentquest, '\d') > 1)) { push(@{$record{'scantron.doubleerror'}},$questnum); for (my $ans = 0; $ans < $answers_needed; $ans++) { - $record{"scantron.$ansnum.answer"}=''; + my $bubble = substr($currentquest, $ans, 1); + if ($bubble =~ /\d/) { + $record{"scantron.$ansnum.answer"} = $alphabet[$bubble]; + } else { + $record{"scantron.$ansnum.answer"}=''; + } $ansnum++; } @@ -5351,7 +5360,7 @@ sub scantron_parse_scanline { } } elsif (scalar(@array) lt 2) { - my $location = [length($array[0])]; + my $location = length($array[0]); my $line_num = $location / $$scantron_config{'Qlength'}; my $bubble = $alphabet[$location % $$scantron_config{'Qlength'}]; @@ -5747,7 +5756,6 @@ SCANTRONFORM my $line = 0; while (defined($env{"form.scantron.bubblelines.$line"})) { - &Apache::lonnet::logthis("Saving chunk for $line"); my $chunk = ''."\n"; $chunk .= @@ -5813,7 +5821,6 @@ sub scantron_validate_file { } my $currentphase=$env{'form.validatepass'}; - &Apache::lonnet::logthis("Phase: $currentphase"); my $stop=0; while (!$stop && $currentphase < scalar(@validate_phases)) { @@ -6325,7 +6332,7 @@ sub scantron_validate_ID { sub scantron_get_correction { my ($r,$i,$scan_record,$scan_config,$line,$error,$arg)=@_; -#FIXME in the case of a duplicated ID the previous line, probaly need +#FIXME in the case of a duplicated ID the previous line, probably need #to show both the current line and the previous one and allow skipping #the previous one or the current one @@ -6424,10 +6431,10 @@ ENDSCRIPT $r->print($message); $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"); @@ -6468,12 +6475,13 @@ sub scantron_bubble_selector { my $scmode=$$scan_config{'Qon'}; + my $bubble_length = scalar(@selected); + 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'); @@ -6484,10 +6492,6 @@ sub scantron_bubble_selector { $r->print(''); } - # 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. - for (my $i=0;$i<$max;$i++) { $r->print("\n".''); if ($selected[0] eq $alphabet[$i]) { @@ -6737,14 +6741,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 +6783,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. @@ -7223,29 +7224,15 @@ sub grading_menu { $fields{'command'} = 'scantron_selectphase'; $url = &Apache::lonhtmlcommon::build_url('grades/',\%fields); push (@menu, { url => $url, - name => &mt('Grade Scantron Forms'), + name => &mt('Grade/Manage Scantron Forms'), short_description => &mt('')}); $fields{'command'} = 'verify'; $url = &Apache::lonhtmlcommon::build_url('grades/',\%fields); push (@menu, { url => "", - jscript => ' onClick="javascript:checkChoice2(document.forms.gradingMenu,\'5\',\'verify\')" ', name => &mt('Verify Receipt'), short_description => &mt('')}); - $fields{'command'} = 'manage'; - $url = &Apache::lonhtmlcommon::build_url('/adm/helper/resettimes.helper',\%fields); - push (@menu, { url => $url, - name => &mt('Manage Access Times'), - short_description => - &mt('')}); - $fields{'command'} = 'view'; - $url = &Apache::lonhtmlcommon::build_url('/adm/pickcode',\%fields); - push (@menu, { url => $url, - name => &mt('View Saved CODEs'), - short_description => - &mt('')}); - # # Create the menu my $Str; @@ -7267,10 +7254,10 @@ sub grading_menu { $menudata->{'url'}.'" >'. $menudata->{'name'}."\n"; } else { - $Str .='

{'jscript'}. - ' href="javascript:checkChoice2(document.forms.gradingMenu,\'5\',\'verify\')" >'. - $menudata->{'name'}."

\n"; + ' onClick="javascript:checkChoice(document.forms.gradingMenu,\'5\',\'verify\')" '. + ' />'; $Str .= (' 'x8). ' receipt: '.&Apache::lonnet::recprefix($env{'request.course.id'}). '-'; @@ -7291,30 +7278,14 @@ sub grading_menu { cmdsave = 'submission'; } formname.command.value = cmd; - formname.saveState.value = "saveCmd="+cmdsave+":saveSec="+pullDownSelection(formname.section)+ - ":saveSub="+pullDownSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.Status); if (val < 5) formname.submit(); if (val == 5) { - if (!checkReceiptNo(formname,'notOK')) { return false;} - formname.submit(); - } - if (val < 7) formname.submit(); - } - function checkChoice2(formname,val,cmdx) { - if (val <= 2) { - var cmd = radioSelection(formname.radioChoice); - var cmdsave = cmd; - } else { - cmd = cmdx; - cmdsave = 'submission'; - } - formname.command.value = cmd; - if (val < 5) formname.submit(); - if (val == 5) { - if (!checkReceiptNo(formname,'notOK')) { return false;} - formname.submit(); + if (!checkReceiptNo(formname,'notOK')) { + return false; + } else { + formname.submit(); + } } - if (val < 7) formname.submit(); } function checkReceiptNo(formname,nospace) { @@ -7333,43 +7304,6 @@ sub grading_menu { GRADINGMENUJS &commonJSfunctions($request); - my $result='

 Manual Grading/View Submission

'; - $result.=$table; - my (undef,$sections) = &getclasslist('all','0'); - my $savedState = &savedState(); - my $saveCmd = ($$savedState{'saveCmd'} eq '' ? 'submission' : $$savedState{'saveCmd'}); - my $saveSec = ($$savedState{'saveSec'} eq '' ? 'all' : $$savedState{'saveSec'}); - my $saveSub = ($$savedState{'saveSub'} eq '' ? 'all' : $$savedState{'saveSub'}); - my $saveStatus = ($$savedState{'saveStatus'} eq '' ? 'Active' : $$savedState{'saveStatus'}); - - $result.='
'."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n"; - - $result.='
'."\n". - ''."\n". - '
'."\n". - ' Select a Grading/Viewing Option
'."\n"; - - $result.=''; - $result.=''."\n"; - $result.=''; -# $result.=''; - $result.=''."\n"; - $result.=''; - $result.=''; $result.=''; $result.=''."\n"; + $result.=''."\n"; $result.=''; $result.=''; - - $result.=''; + $result.=''."\n"; + ($saveSub eq 'all' ? 'selected="selected"' : '').'>'.&mt('with any status').''; - $result.=''."\n"; + + $result.=''."\n"; - $result.=''."\n"; + + + $result.=''."\n"; + 'The complete set/page/sequence/folder: For one student'."\n"; - $result.='
'.&mt('Sections').'Groups'.&mt('Access Status').'
'."\n". - '    '; return $Str; } @@ -7447,6 +7381,7 @@ GRADINGMENUJS $result.=''.&mt('Sections').''.&mt('Groups').''.&mt('Access Status').''.&mt('Submission Status').'
'."\n". ' '."\n"; $result.=&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,3,undef,'mult'); - $result.='
'. + $result.='
'. '
'. - '
'. + '

'. + $result.='

'. ''. '
'."\n"; @@ -8036,7 +7977,6 @@ ENDHEADER sub handler { my $request=$_[0]; - &reset_caches(); if ($env{'browser.mathml'}) { &Apache::loncommon::content_type($request,'text/xml'); @@ -8132,7 +8072,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));