--- loncom/homework/grades.pm 2007/04/26 22:29:50 1.397 +++ loncom/homework/grades.pm 2007/05/02 01:17:37 1.398 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.397 2007/04/26 22:29:50 albertel Exp $ +# $Id: grades.pm,v 1.398 2007/05/02 01:17:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -102,10 +102,10 @@ sub get_symb { sub nameUserString { my ($type,$fullname,$uname,$udom) = @_; if ($type eq 'header') { - return ' Fullname (Username)'; + return ' Fullname (Username)'; } else { - return ' '.$fullname.' ('.$uname. - ($env{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')'; + return ' '.$fullname.' ('.$uname. + ($env{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')'; } } @@ -151,7 +151,7 @@ sub get_display_part { my ($partID,$symb)=@_; my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb); if (defined($display) and $display ne '') { - $display.= " (id $partID)"; + $display.= " (id $partID)"; } else { $display=$partID; } @@ -164,9 +164,8 @@ sub showResourceInfo { my ($symb,$probTitle,$checkboxes) = @_; my $col=3; if ($checkboxes) { $col=4; } - my $result =''. - ''."\n"; + my $result = '

'.&mt('Current Resource').': '.$probTitle.'

'."\n"; + $result .='
'.&mt('Current Resource').': '. - $probTitle.'
'; my ($partlist,$handgrade,$responseType) = &response_type($symb); my %resptype = (); my $hdgrade='no'; @@ -186,8 +185,8 @@ sub showResourceInfo { $partsseen{$partID}=1; } my $display_part=&get_display_part($partID,$symb); - $result.=''. + $result.=''. ''; # ''; } @@ -218,7 +217,7 @@ sub get_order { sub cleanRecord { my ($answer,$response,$symb,$partid,$respid,$record,$order,$version, $uname,$udom) = @_; - my $grayFont = ''; + my $grayFont = ''; if ($response =~ /^(option|rank)$/) { my %answer=&Apache::lonnet::str2hash($answer); my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"}); @@ -229,11 +228,11 @@ sub cleanRecord { } else { $toprow.=''; } - $bottomrow.=''; + $bottomrow.=''; } return '
Part: '.$display_part.' '. - $resID.'Part: '.$display_part.' '. + $resID.'Type: '.$responsetype.'
Handgrade: '.$handgrade.'
'.$answer{$foil}.' '.$grayFont.$foil.' '.$grayFont.$foil.' 
'. ''.$toprow.''. - ''. + ''. $grayFont.$bottomrow.''.'
Answer
'.$grayFont.'Option ID
'.$grayFont.'Option ID
'; } elsif ($response eq 'match') { my %answer=&Apache::lonnet::str2hash($answer); @@ -244,18 +243,18 @@ sub cleanRecord { my $item=shift(@items); if ($grading{$foil} == 1) { $toprow.=''.$item.' '; - $middlerow.=''.$grayFont.$answer{$foil}.' '; + $middlerow.=''.$grayFont.$answer{$foil}.' '; } else { $toprow.=''.$item.' '; - $middlerow.=''.$grayFont.$answer{$foil}.' '; + $middlerow.=''.$grayFont.$answer{$foil}.' '; } - $bottomrow.=''.$grayFont.$foil.' '; + $bottomrow.=''.$grayFont.$foil.' '; } return '
'. ''.$toprow.''. - ''. + ''. $middlerow.''. - ''. + ''. $bottomrow.''.'
Answer
'.$grayFont.'Item ID
'.$grayFont.'Item ID
'.$grayFont.'Option ID
'.$grayFont.'Option ID
'; } elsif ($response eq 'radiobutton') { my %answer=&Apache::lonnet::str2hash($answer); @@ -272,11 +271,11 @@ sub cleanRecord { } else { $toprow.='false'; } - $bottomrow.=''.$grayFont.$foil.' '; + $bottomrow.=''.$grayFont.$foil.' '; } return '
'. ''.$toprow.''. - ''. + ''. $grayFont.$bottomrow.''.'
Answer
'.$grayFont.'Option ID
'.$grayFont.'Option ID
'; } elsif ($response eq 'essay') { if (! exists ($env{'form.'.$symb})) { @@ -595,9 +594,9 @@ sub verifyreceipt { $receipt =~ s/[^\-\d]//g; my ($symb) = &get_symb($request); - my $title.='

Verifying Submission Receipt '. - $receipt.'

'."\n". - 'Resource: '.$env{'form.probTitle'}.'

'."\n"; + my $title.='

Verifying Submission Receipt '. + $receipt.'

'."\n". + '

Resource: '.$env{'form.probTitle'}.'



'."\n"; my ($string,$contents,$matches) = ('','',0); my (undef,undef,$fullname) = &getclasslist('all','0'); @@ -668,8 +667,8 @@ sub listStudents { $env{'form.probTitle'} = $env{'form.probTitle'} eq '' ? &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'}; - my $result='

 '.$viewgrade. - ' Submissions for a Student or a Group of Students

'; + my $result='

 '.$viewgrade. + ' Submissions for a Student or a Group of Students

'; my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes')); @@ -881,15 +880,15 @@ LISTJAVASCRIPT if ($ctr == 0) { my $num_students=(scalar(keys(%$fullname))); if ($num_students eq 0) { - $gradeTable='
 There are no students currently enrolled.'; + $gradeTable='
 There are no students currently enrolled.'; } else { my $submissions='submissions'; if ($submitonly eq 'incorrect') { $submissions = 'incorrect submissions'; } if ($submitonly eq 'graded' ) { $submissions = 'ungraded submissions'; } if ($submitonly eq 'queued' ) { $submissions = 'queued submissions'; } - $gradeTable='
 '. + $gradeTable='
 '. 'No '.$submissions.' found for this resource for any students. ('.$num_students. - ' students checked for '.$submissions.')

'; + ' students checked for '.$submissions.')
'; } } elsif ($ctr == 1) { $gradeTable =~ s/type=checkbox/type=checkbox checked/; @@ -1344,7 +1343,7 @@ INNERJS pDoc.write("
"); pDoc.write(""); - pDoc.write(" Compose Message for \"+fullname+\"

"); + pDoc.write("

 Compose Message for \"+fullname+\"



"); pDoc.write("
"); pDoc.write(""); @@ -1429,7 +1428,7 @@ INNERJS hDoc.$docopen; hDoc.write('$start_page_highlight_central'); hDoc.write(""); - hDoc.write(" Keyword Highlight Options

"); + hDoc.write("

 Keyword Highlight Options



"); hDoc.write("
"); hDoc.write(""); @@ -1480,7 +1479,7 @@ sub gradeBox { '/check.gif" height="16" border="0" />'; my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname); my $wgtmsg = ($wgt > 0 ? '(problem weight)' : - 'problem weight assigned by computer'); + 'problem weight assigned by computer'); $wgt = ($wgt > 0 ? $wgt : '1'); my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ? '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt)); @@ -1677,9 +1676,9 @@ sub submission { if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; } if (!&canview($usec)) { - $request->print('Unable to view requested student.('. - $uname.'@'.$udom.' in section '.$usec.' in course id '. - $env{'request.course.id'}.')'); + $request->print('Unable to view requested student.('. + $uname.':'.$udom.' in section '.$usec.' in course id '. + $env{'request.course.id'}.')'); $request->print(&show_grading_menu_form($symb)); return; } @@ -1701,8 +1700,8 @@ sub submission { if ($env{'form.handgrade'} eq 'yes' && &files_exist($request, $symb)) { &download_all_link($request, $symb); } - $request->print('

 Submission Record

'."\n". - ' Resource: '.$env{'form.probTitle'}.''."\n"); + $request->print('

 Submission Record

'."\n". + '

 Resource: '.$env{'form.probTitle'}.'

'."\n"); if ($env{'form.handgrade'} eq 'no') { my $checkMark='

 Note: Part(s) graded correct by the computer is marked with a '. @@ -1931,9 +1930,9 @@ KEYWORDS my $responsetype = $responseType->{$partid}->{$respid}; if (!exists($record{"resource.$partid.$respid.submission"})) { $lastsubonly.=''."\n"; + '('.$uname.($env{'user.domain'} eq $udom ? '' : ':'.$udom).')'."\n"; $student=~s/:/_/; # colon doen't work in javascript for names foreach my $apart (@$parts) { my ($part,$type) = &split_part_type($apart); @@ -3170,9 +3169,9 @@ sub editgrades { my ($request) = @_; my $symb=&get_symb($request); - my $title='

Current Grade Status

'; - $title.='Current Resource: '.$env{'form.probTitle'}.'
'."\n"; - $title.='Section: '.$env{'form.section'}.''."\n"; + my $title='

Current Grade Status

'; + $title.='

Current Resource: '.$env{'form.probTitle'}.'


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

Section: '.$env{'form.section'}.'

'."\n"; my $result= '
Part: '. - $display_part.' ( ID '.$respid. - ' )   '. - 'Nothing submitted - no attempts

'; + $display_part.' ( ID '.$respid. + ' )   '. + 'Nothing submitted - no attempts

'; next; } foreach (@$string) { @@ -1947,10 +1946,10 @@ KEYWORDS &most_similar($uname,$udom,$subval); if ($osim) { $osim=int($osim*100.0); - $similar="

Essay". + $similar="

Essay". " is $osim% similar to an essay by ". &Apache::loncommon::plainname($oname,$odom). - '

'. + '

'. &keywords_highlight($oessay). '

'; } @@ -1961,11 +1960,11 @@ KEYWORDS $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) { my $display_part=&get_display_part($partid,$symb); $lastsubonly.='
Debug -'.'Part: '. - $display_part.' ( hhhh ID '.$respid. - ' )   '; + $display_part.' ( hhhh ID '.$respid. + ' )   '; my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record); if (@$files) { - $lastsubonly.='
Like all files provided by users, this file may contain virusses
'; + $lastsubonly.='
Like all files provided by users, this file may contain virusses
'; my $file_counter = 0; foreach my $file (@$files) { $file_counter ++; @@ -2119,13 +2118,13 @@ sub get_last_submission { my ($partid,$foo) = split(/submission$/,$key); my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ? - 'Draft Copy ' : ''; + 'Draft Copy ' : ''; push(@string, join(':', $key, $draft.$lasthash{$key})); } } if (!@string) { $string[0] = - 'Nothing submitted - no attempts.'; + 'Nothing submitted - no attempts.'; } return (\@string,\$timestamp); } @@ -2137,8 +2136,8 @@ sub keywords_highlight { my $styleon = $env{'form.kwstyle'} eq '' ? '' : $env{'form.kwstyle'}; (my $styleoff = $styleon) =~ s/\$styleon$_$styleoff<\/font>/gi; + foreach my $keyword (@keylist) { + $string =~ s/\b\Q$keyword\E(\b|\.)/$styleon$keyword$styleoff<\/font>/gi; } return $string; } @@ -2164,7 +2163,7 @@ sub processHandGrade { next; } if ($errorflag eq 'not_allowed') { - $request->print("Not allowed to modify grades for $uname:$udom"); + $request->print("Not allowed to modify grades for $uname:$udom"); $ctr++; next; } @@ -2393,7 +2392,7 @@ sub processHandGrade { $ctr++; } if ($total < 0) { - my $the_end = '

LON-CAPA User Message


'."\n"; + my $the_end = '

LON-CAPA User Message


'."\n"; $the_end.='Message: No more students for this section or class.

'."\n"; $the_end.='Click on the button below to return to the grading menu.

'."\n"; $the_end.=&show_grading_menu_form($symb); @@ -2566,8 +2565,8 @@ sub handback_files { $newflg.'_'.$part_resp.'_returndoc'.$file_counter, $save_file_name); if ($result !~ m|^/uploaded/|) { - $request->print(' An errror occured ('.$result. - ') while trying to upload '.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'
'); + $request->print('An errror occured ('.$result. + ') while trying to upload '.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'
'); } else { # mark the file as read only my @files = ($save_file_name); @@ -2963,8 +2962,8 @@ sub viewgrades { $env{'course.'.$env{'request.course.id'}.'.domain'}); &Apache::lonnet::clear_EXT_cache_status(); - my $result='

'.&mt('Manual Grading').'

'; - $result.='Current Resource: '.$env{'form.probTitle'}.''."\n"; + my $result='

'.&mt('Manual Grading').'

'; + $result.='

Current Resource: '.$env{'form.probTitle'}.'

'."\n"; #view individual student submission form - called using Javascript viewOneStudent $result.=&jscriptNform($symb); @@ -3092,8 +3091,8 @@ sub viewgrades { 'onClick="javascript:submit();" TARGET=_self />'."\n"; if (scalar(%$fullname) eq 0) { my $colspan=3+scalar(@parts); - $result='There are no students in section "'.$env{'form.section'}. - '" with enrollment status "'.$env{'form.Status'}.'" to modify or grade.'; + $result='There are no students in section "'.$env{'form.section'}. + '" with enrollment status "'.$env{'form.Status'}.'" to modify or grade.'; } $result.=&show_grading_menu_form($symb); return $result; @@ -3110,7 +3109,7 @@ sub viewstudentgrade { "\n".$ctr.' 
 '. ''.$fullname.' '. - '('.$uname.($env{'user.domain'} eq $udom ? '' : ':'.$udom).')
'."\n"; $result.= ''. @@ -3240,7 +3239,7 @@ sub editgrades { my $usec=$classlist->{"$uname:$udom"}[5]; if (!&canmodify($usec)) { my $numcols=scalar(@partid)*4+2; - $noupdate.=$line.""; + $noupdate.=$line.""; next; } my %aggregate = (); @@ -3475,7 +3474,7 @@ sub csvuploadmap_header { my $ignore=&mt('Ignore First Line'); $request->print(< -

Uploading Class Grades

+

Uploading Class Grades

$result

Identify fields

@@ -3638,7 +3637,7 @@ sub csvuploadoptions { my $ignore=&mt('Ignore First Line'); $request->print(< -

Uploading Class Grade Options

+

Uploading Class Grade Options

Not allowed to modify student
Not allowed to modify student