--- loncom/homework/grades.pm 2004/12/04 00:03:24 1.204.2.10 +++ loncom/homework/grades.pm 2004/07/16 19:50:23 1.205 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.204.2.10 2004/12/04 00:03:24 albertel Exp $ +# $Id: grades.pm,v 1.205 2004/07/16 19:50:23 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -167,21 +167,6 @@ sub response_type { return \@partlist,\%handgrade,\%responseType; } -sub get_display_part { - my ($partID,$url,$symb)=@_; - if (!defined($symb) || $symb eq '') { - $symb=$ENV{'form.symb'}; - if ($symb eq '') { $symb=&Apache::lonnet::symbread($url) } - } - my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb); - &Apache::lonnet::logthis("\nsymb $symb\n url $url\npartID $partID\ndisplay $display \n"); - if (defined($display) and $display ne '') { - $display.= " (id $partID)"; - } else { - $display=$partID; - } - return $display; -} #--- Show resource title #--- and parts and response type sub showResourceInfo { @@ -209,8 +194,7 @@ sub showResourceInfo { } $partsseen{$partID}=1; } - my $display_part=&get_display_part($partID,$url); - $result.='Part: '.$display_part.' '. + $result.='Part '.$partID.' '. $resID.''. 'Type: '.$responsetype.''; # 'Handgrade: '.$handgrade.''; @@ -365,27 +349,36 @@ sub getclasslist { # my %sections; my %fullnames; - foreach (keys(%$classlist)) { - # the following undefs are for 'domain', and 'username' respectively. - my (undef,undef,$end,$start,$id,$section,$fullname,$status)= - @{$classlist->{$_}}; + foreach my $student (keys(%$classlist)) { + my $end = + $classlist->{$student}->[&Apache::loncoursedata::CL_END()]; + my $start = + $classlist->{$student}->[&Apache::loncoursedata::CL_START()]; + my $id = + $classlist->{$student}->[&Apache::loncoursedata::CL_ID()]; + my $section = + $classlist->{$student}->[&Apache::loncoursedata::CL_SECTION()]; + my $fullname = + $classlist->{$student}->[&Apache::loncoursedata::CL_FULLNAME()]; + my $status = + $classlist->{$student}->[&Apache::loncoursedata::CL_STATUS()]; # filter students according to status selected if ($filterlist && $ENV{'form.Status'} ne 'Any') { if ($ENV{'form.Status'} ne $status) { - delete ($classlist->{$_}); + delete ($classlist->{$student}); next; } } - $section = ($section ne '' ? $section : 'no'); + $section = ($section ne '' ? $section : 'none'); if (&canview($section)) { if ($getsec eq 'all' || $getsec eq $section) { $sections{$section}++; - $fullnames{$_}=$fullname; + $fullnames{$student}=$fullname; } else { - delete($classlist->{$_}); + delete($classlist->{$student}); } } else { - delete($classlist->{$_}); + delete($classlist->{$student}); } } my %seen = (); @@ -698,9 +691,7 @@ LISTJAVASCRIPT ''.&nameUserString('header').''; if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') { foreach (sort(@$partlist)) { - my $display_part=&get_display_part((split(/_/))[0],$url,$symb); - $gradeTable.=' Part: '.$display_part. - ' Status '; + $gradeTable.=' Part '.(split(/_/))[0].' Status '; } } $loop++; @@ -1102,7 +1093,7 @@ sub sub_page_kw_js { var ypos = (screen.height-height)/2-30; ypos = (ypos < 0) ? '0' : ypos; - pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height); + pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height); pWin.focus(); pDoc = pWin.document; pDoc.open('text/html','replace'); @@ -1233,7 +1224,7 @@ sub sub_page_kw_js { var ypos = (screen.height-330)/2-30; ypos = (ypos < 0) ? '0' : ypos; - hwdWin = window.open('', 'KeywordHighlightCentral', 'resizeable=yes,toolbar=no,location=no,scrollbars=no,width=400,height=300,screenx='+xpos+',screeny='+ypos); + hwdWin = window.open('', 'KeywordHighlightCentral', 'toolbar=no,location=no,scrollbars=no,width=400,height=300,screenx='+xpos+',screeny='+ypos); hwdWin.focus(); var hDoc = hwdWin.document; hDoc.open('text/html','replace'); @@ -1307,9 +1298,8 @@ sub gradeBox { '' : $$record{'resource.'.$partid.'.awarded'}*$wgt); my $result=''."\n"; - my $display_part=&get_display_part($partid,undef,$symb); $result.='
'. - 'Part: '.$display_part.' Points: '."\n"; + 'Part '.$partid.' Points: '."\n"; my $ctr = 0; $result.=''."\n"; # display radio buttons in a nice table 10 across @@ -1641,12 +1631,11 @@ KEYWORDS my %seenparts; for my $part (sort keys(%$handgrade)) { my ($partid,$respid) = split(/_/,$part); - my $display_part=&get_display_part($partid,$url,$symb); if ($ENV{"form.$uname:$udom:$partid:submitted_by"}) { if (exists($seenparts{$partid})) { next; } $seenparts{$partid}=1; - my $submitby='Part: '.$display_part. - ' Collaborative submission by: '. + my $submitby='Part '.$partid. + ' Collaborative submission by: '. ''. @@ -1656,8 +1645,8 @@ KEYWORDS } my $responsetype = $responseType->{$partid}->{$respid}; if (!exists($record{"resource.$partid.$respid.submission"})) { - $lastsubonly.='
Part: '. - $display_part.' ( ID '.$respid. + $lastsubonly.='
Part '. + $partid.' ( ID '.$respid. ' )   '. 'Nothing submitted - no attempts

'; next; @@ -1685,9 +1674,8 @@ KEYWORDS if ($ENV{'form.lastSub'} eq 'lastonly' || ($ENV{'form.lastSub'} eq 'hdgrade' && $$handgrade{$part} eq 'yes')) { - my $display_part=&get_display_part($partid,$url,$symb); - $lastsubonly.='
Part: '. - $display_part.' ( ID '.$respid. + $lastsubonly.='
Part '. + $partid.' ( ID '.$respid. ' )   '; if ($record{"resource.$partid.$respid.uploadedurl"}) { &Apache::lonnet::allowuploaded('/adm/grades', @@ -2320,7 +2308,7 @@ sub viewgrades { my $sectionClass; if ($ENV{'form.section'} eq 'all') { $sectionClass='Class '; - } elsif ($ENV{'form.section'} eq 'no') { + } elsif ($ENV{'form.section'} eq 'none') { $sectionClass='Students in no Section '; } else { $sectionClass='Students in Section '.$ENV{'form.section'}.''; @@ -2347,8 +2335,7 @@ sub viewgrades { $ctsparts.'" value="'.$partid.'" />'."\n"; $result.=''."\n"; - my $display_part=&get_display_part($partid,$url,$symb); - $result.='
Part: '.$display_part.'   Point: '; + $result.='
Part '.$partid.'   Point: '; $result.=''; my $ctr = 0; while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across @@ -2387,17 +2374,14 @@ sub viewgrades { my $display=&Apache::lonnet::metadata($url,$part.'.display'); $display =~ s|^Number of Attempts|Tries
|; # makes the column narrower if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); } - my ($partid) = &split_part_type($part); - my $display_part=&get_display_part($partid,$url,$symb); if ($display =~ /^Partial Credit Factor/) { - $result.=''."\n"; + my ($partid) = &split_part_type($part); + $result.=''."\n"; next; - } else { - $display =~s/\[Part: \Q$partid\E\]/Part:<\/b> $display_part/; } $display =~ s|Problem Status|Grade Status
|; - $result.=''."\n"; + $result.=''."\n"; } $result.=''; @@ -2527,10 +2511,9 @@ sub editgrades { } } foreach my $partid (@partid) { - my $display_part=&get_display_part($partid,$url,$symb); $result .= ''; + '" align="center">Part '.$partid. + ' (Weight = '.$weight{$partid}.')'; } $result .= ''; @@ -3219,12 +3202,9 @@ sub displayPage { sub displaySubByDates { my ($symb,$record,$parts,$responseType,$checkIcon,$uname,$udom) = @_; - my $isCODE=0; - if (exists($record->{'resource.CODE'})) { $isCODE=1; } my $studentTable='
Score Part: '.$display_part. - '
(weight = '.$weight{$partid}.')
Score Part '.$partid.'
(weight = '. + $weight{$partid}.')
'.$display.''.$display.'
Part: '.$display_part. - ' (Weight = '.$weight{$partid}.')
'. ''. ''. - ($isCODE?'':''). ''. ''; my ($version); @@ -3237,22 +3217,18 @@ sub displaySubByDates { for ($version=1;$version<=$$record{'version'};$version++) { my $timestamp = scalar(localtime($$record{$version.':timestamp'})); $studentTable.=''; - if ($isCODE) { - $studentTable.=''; - } my @versionKeys = split(/\:/,$$record{$version.':keys'}); my @displaySub = (); foreach my $partid (@{$parts}) { my @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys); # next if ($$record{"$version:resource.$partid.solved"} eq ''); - my $display_part=&get_display_part($partid,undef,$symb); foreach my $matchKey (@matchKey) { if (exists($$record{$version.':'.$matchKey}) && $$record{$version.':'.$matchKey} ne '') { my ($responseId)=($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/); - $displaySub[0].='Part: '.$display_part.' '; + $displaySub[0].='Part '.$partid.' '; $displaySub[0].='(ID '. - $responseId.') '; + $responseId.') '; if ($$record{"$version:resource.$partid.tries"} eq '') { $displaySub[0].='Trial not counted'; } else { @@ -3270,14 +3246,14 @@ sub displaySubByDates { } } if (exists $$record{"$version:resource.$partid.award"}) { - $displaySub[1].='Part: '.$display_part.'  '. + $displaySub[1].='Part '.$partid.'  '. lc($$record{"$version:resource.$partid.award"}).' '. $mark{$$record{"$version:resource.$partid.solved"}}. '
'; } if (exists $$record{"$version:resource.$partid.regrader"}) { $displaySub[2].=$$record{"$version:resource.$partid.regrader"}. - ' ('.&mt('Part').': '.$display_part.')'; + ' ('.&mt('Part').': '.$partid.')'; } } # needed because old essay regrader has not parts info @@ -3374,13 +3350,12 @@ sub updateGradeByPage { $changeflag++; $newpts = ''; } - my $display_part=&get_display_part($partid,undef, - $curRes->symb()); + my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid}; - $displayPts[0].=' Part: '.$display_part.' = '. + $displayPts[0].=' Part '.$partid.' = '. (($oldstatus eq 'excused') ? 'excused' : $oldpts). ' 
'; - $displayPts[1].=' Part: '.$display_part.' = '. + $displayPts[1].=' Part '.$partid.' = '. (($score eq 'excused') ? 'excused' : $newpts). ' 
'; @@ -3470,11 +3445,10 @@ sub scantron_filenames { } sub scantron_uploads { - my ($file2grade) = @_; my $result= '"; return $result; @@ -3520,13 +3494,13 @@ sub scantron_CODEunique { } sub scantron_selectphase { - my ($r,$file2grade) = @_; + my ($r) = @_; my ($symb,$url)=&get_symb_and_url($r); if (!$symb) {return '';} my $sequence_selector=&getSequenceDropDown($r,$symb); my $default_form_data=&defaultFormData($symb,$url); my $grading_menu_button=&show_grading_menu_form($symb,$url); - my $file_selector=&scantron_uploads($file2grade); + my $file_selector=&scantron_uploads(); my $format_selector=&scantron_scantab(); my $CODE_selector=&scantron_CODElist(); my $CODE_unique=&scantron_CODEunique(); @@ -3853,8 +3827,7 @@ sub scantron_find_student { sub scantron_filter { my ($curres)=@_; - # randomout is dysfunctional at best for this purpose - if (ref($curres) && $curres->is_problem()) { #&& !$curres->randomout) { + if (ref($curres) && $curres->is_problem() && !$curres->randomout) { return 1; } return 0; @@ -4006,7 +3979,7 @@ sub scantron_form_start { - + @@ -4326,8 +4299,8 @@ sub scantron_get_correction { } elsif ($error eq 'duplicateCODE') { $r->print("

The encoded CODE has also been used by a previous paper ".join(', ',@{$arg}).", and CODEs are supposed to be unique

\n"); } - $r->print("

The CODE on the form is '". - $$scan_record{'scantron.CODE'}."'
\n"); + $r->print("

The CODE on the form is ". + $$scan_record{'scantron.CODE'}."
\n"); $r->print("

The ID on the form is ". $$scan_record{'scantron.ID'}."
\n"); $r->print("The name on the paper is ". @@ -4473,21 +4446,13 @@ sub scantron_validate_CODE { $scan_data); my $CODE=$$scan_record{'scantron.CODE'}; my $error=0; - if (!&Apache::lonnet::validCODE($CODE)) { - &scantron_get_correction($r,$i,$scan_record, - \%scantron_config, - $line,'incorrectCODE',\%allcodes); - return(1,$currentphase); - } - if (%allcodes && !exists($allcodes{$CODE}) - && !$$scan_record{'scantron.useCODE'}) { + if (!exists($allcodes{$CODE}) && !$$scan_record{'scantron.useCODE'}) { &scantron_get_correction($r,$i,$scan_record, \%scantron_config, $line,'incorrectCODE',\%allcodes); return(1,$currentphase); } - if (exists($usedCODEs{$CODE}) - && $ENV{'form.scantron_CODEunique'} eq 'yes' + if (exists($usedCODEs{$CODE}) && $ENV{'form.scantron_CODEunique'} && !$$scan_record{'scantron.CODE_ignore_dup'}) { &scantron_get_correction($r,$i,$scan_record, \%scantron_config, @@ -4535,7 +4500,7 @@ sub scantron_get_maxbubble { my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); &Apache::lonnet::delenv('form.counter'); foreach my $resource (@resources) { - my $result=&Apache::lonnet::ssi($resource->src().'?symb='.&Apache::lonnet::escape($resource->symb())); + my $result=&Apache::lonnet::ssi($resource->src()); } &Apache::lonnet::delenv('scantron\.'); my $envfile=$ENV{'user.environment'}; @@ -4652,14 +4617,11 @@ SCANTRONFORM if (exists($scan_record->{'scantron.CODE'}) && $scan_record->{'scantron.CODE'}) { $form{'CODE'}=$scan_record->{'scantron.CODE'}; - } else { - $form{'CODE'}=''; } my $result=&Apache::lonnet::ssi($resource->src(),%form); - if (&Apache::loncommon::connection_aborted($r)) { last; } + } $completedstudents{$uname}={'line'=>$line}; - if (&Apache::loncommon::connection_aborted($r)) { last; } } continue { &Apache::lonnet::delenv('form.counter'); &Apache::lonnet::delenv('scantron\.'); @@ -4729,7 +4691,7 @@ sub scantron_upload_scantron_data_save { } return ''; } -# $r->print("Doing upload to ".$ENV{'form.courseid'}."
"); + $r->print("Doing upload to ".$ENV{'form.courseid'}."
"); my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'}, $ENV{'form.domainid'}); my $fname=$ENV{'form.upfile.filename'}; @@ -4746,23 +4708,19 @@ sub scantron_upload_scantron_data_save { $fname=~s/[^\w\.\-]//g; # See if there is anything left unless ($fname) { return 'error: no uploaded file'; } - my $uploadedfile=$fname; $fname='scantron_orig_'.$fname; if (length($ENV{'form.upfile'}) < 2) { $r->print("Error: The file you attempted to upload, ".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"').", contained no information. Please check that you entered the correct filename."); } else { my $result=&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},$ENV{'form.domainid'},$home,'upfile',$fname); -# if ($result =~ m|^/uploaded/|) { - if ($result !~ m|^/uploaded/|) { -# $r->print("Success: Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location ".$result.""); -# } else { - $r->print("Error: An error (".$result.") occurred when attempting to upload the file, ".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"').""); + if ($result =~ m|^/uploaded/|) { + $r->print("Success: Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location ".$result.""); + } else { + $r->print("Error: An error (".$result.") occured when attempting to upload the file, ".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"').""); } } if ($symb) { -# $r->print(&show_grading_menu_form($symb,$url)); - $r->print(&scantron_selectphase($r,$uploadedfile)); - + $r->print(&show_grading_menu_form($symb,$url)); } else { $r->print($doanotherupload); } @@ -4927,9 +4885,6 @@ GRADINGMENUJS $result.=&mt('Student Status').':
'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef); - if (ref($sections) && (grep /no/,@$sections)) { - $result.=' (Section "no" implies the students were not assigned a section.)
'; - } $result.='

'; $result.='
Date/TimeCODESubmissionStatus 
'.$timestamp.''.$record->{$version.':resource.CODE'}.'
'. @@ -5129,7 +5084,8 @@ sub send_header { sub send_footer { my ($request)= @_; - $request->print(''); + $request->print(''); + $request->print(&Apache::lontexconvert::footer()); } 1;