--- loncom/homework/grades.pm 2003/07/19 15:11:27 1.120 +++ loncom/homework/grades.pm 2003/07/22 18:59:57 1.122 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.120 2003/07/19 15:11:27 ng Exp $ +# $Id: grades.pm,v 1.122 2003/07/22 18:59:57 ng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -123,23 +123,25 @@ sub showResourceInfo { my $result =''. ''."\n"; my ($partlist,$handgrade) = &response_type($url); - my ($resptype,$hdgrade)=('','no'); + my %resptype = (); #,$hdgrade)=('','no'); + my $hdgrade='no'; for (sort keys(%$handgrade)) { my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_}); - $resptype = $responsetype; + my $partID = (split(/_/))[0]; + $resptype{$partID} = $responsetype; $hdgrade = $handgrade if ($handgrade eq 'yes'); - $result.=''. + $result.=''. ''; # ''; } $result.='
Current Resource: '.$probTitle.'
Part '.(split(/_/))[0].'
Part '.$partID.'Type: '.$responsetype.'
Handgrade: '.$handgrade.'
'."\n"; - return $result,$resptype,$hdgrade,$partlist,$handgrade; + return $result,\%resptype,$hdgrade,$partlist,$handgrade; } #--- Clean response type for display #--- Currently filters option response type only. sub cleanRecord { - my ($answer,$response) = @_; + my ($answer,$response,$symb) = @_; if ($response eq 'option') { my (@IDs,@ans); foreach (split(/\&/,&Apache::lonnet::unescape($answer))) { @@ -155,6 +157,21 @@ sub cleanRecord { (join ''.$grayFont,@IDs).''. ''; } + if ($response eq 'essay') { + if (! exists ($ENV{'form.'.$symb})) { + my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + + my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'}; + $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : ''; + $ENV{'form.kwclr'} = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red'; + $ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0'; + $ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : ''; + $ENV{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob. + } + return &keywords_highlight($answer); + } return $answer; } @@ -197,6 +214,7 @@ COMMONJSFUNCTIONS #--- section, ids and fullnames for each user. sub getclasslist { my ($getsec,$filterlist) = @_; + $getsec = $getsec eq '' ? 'all' : $getsec; my $classlist=&Apache::loncoursedata::get_classlist(); # Bail out if we were unable to get the classlist return if (! defined($classlist)); @@ -430,7 +448,7 @@ sub listStudents { my $result='

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

'; - my ($table,$resptype,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'}); + my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'}); $result.=$table; $request->print(< last sub only'."\n". ' last sub & parts info'."\n". + ' by dates and submissions'."\n". ' all details'."\n". ''."\n". ''."\n". - ''."\n". '
'."\n". '
'."\n". ''."\n". @@ -721,9 +739,9 @@ sub sub_page_js { return; } -//=========== Check that a point is assigned for all the parts (essay grading only) ============ +//=========== Check that a point is assigned for all the parts ============ function checksubmit(formname,val,total,parttot) { - document.SCORE.gradeOpt.value = val; + formname.gradeOpt.value = val; if (val == "Save & Next") { for (i=0;i<=total;i++) { for (j=0;j //===================== Show list of keywords ==================== - function keywords(keyform) { - var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keyform.value); + function keywords(formname) { + var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",formname.keywords.value); if (nret==null) return; - keyform.value = nret; + formname.keywords.value = nret; - document.SCORE.refresh.value = "on"; - if (document.SCORE.keywords.value != "") { - document.SCORE.submit(); + formname.refresh.value = "on"; + if (formname.keywords.value != "") { + formname.submit(); } return; } @@ -1183,8 +1200,10 @@ sub submission { return; } - $ENV{'form.lastSub'} = ($ENV{'form.lastSub'} eq '' ? 'all' : $ENV{'form.lastSub'}); + $ENV{'form.lastSub'} = ($ENV{'form.lastSub'} eq '' ? 'datesub' : $ENV{'form.lastSub'}); my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : ''); + my $checkIcon = ''; # header info if ($counter == 0) { @@ -1197,8 +1216,6 @@ sub submission { ' Resource: '.$ENV{'form.probTitle'}.''."\n"); if ($ENV{'form.handgrade'} eq 'no') { - my $checkIcon = ''; my $checkMark='

 Note: Part(s) graded correct by the computer is marked with a '. $checkIcon.' symbol.'."\n"; $request->print($checkMark); @@ -1246,7 +1263,6 @@ sub submission { ''."\n". ''."\n". ''."\n". - ''."\n". ''."\n". ''."\n". ''."\n". @@ -1274,7 +1290,7 @@ sub submission { # $request->print(<Keyword Options:  -List    +List    Paste Selection to List    Highlight Attribute

@@ -1393,7 +1409,7 @@ KEYWORDS if (!exists($record{'resource.'.$partid.'.'.$respid.'.submission'})) { $lastsubonly.='Part '. $partid.' ( ID '.$respid. - ' )   Nothing submitted

'; + ' )   Nothing submitted - no attempts

'; } else { foreach (@$string) { my ($partid,$respid) = /^resource\.(\w+)\.(\w+)\.submission/; @@ -1420,7 +1436,8 @@ KEYWORDS 'this file may contain virusses
':''). 'Submitted Answer: '.($responsetype =~ /^(essay|option)$/ ? '
' : ''). - &cleanRecord(&keywords_highlight($subval),$responsetype). +# &cleanRecord(&keywords_highlight($subval),$responsetype). + &cleanRecord($subval,$responsetype,$symb). ($responsetype =~ /^(essay|option)$/ ? '

' : '

').$similar."\n" if ($ENV{'form.lastSub'} eq 'lastonly' || @@ -1434,23 +1451,24 @@ KEYWORDS $lastsubonly.=''."\n"; $request->print($lastsubonly); } - } else { + } elsif ($ENV{'form.lastSub'} eq 'datesub') { + my (undef,$responseType,undef,$parts) = &showResourceInfo($url); + $request->print(&displaySubByDates(\$symb,\%record,$parts,$responseType,$checkIcon)); + } elsif ($ENV{'form.lastSub'} =~ /^(last|all)$/) { $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom, $ENV{'request.course.id'}, $last,'.submission', 'Apache::grades::keywords_highlight')); } - $result=''."\n". - ''."\n". - ''."\n"; - $request->print($result); + $request->print(''."\n"); # return if view submission with no grading option if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) { my $toGrade.='  '."\n"; + 'onClick="javascript:checksubmit(this.form,\'Grade Student\',\'' + .$counter.'\');" TARGET=_self>  '."\n" if (&canmodify($usec)); $toGrade.=''."\n"; $toGrade.=&show_grading_menu_form($symb,$url) if (($ENV{'form.command'} eq 'submission') || @@ -1459,7 +1477,7 @@ KEYWORDS return; } - # essay grading options + # essay grading message center if ($ENV{'form.handgrade'} eq 'yes') { my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'}); my $msgfor = $givenn.' '.$lastname; @@ -1469,15 +1487,17 @@ KEYWORDS } $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript # $result.=''."\n". - $result=' '."\n". + ''."\n"; + $result.=' '. 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'  '. ''."\n". '
 (Message will be sent when you click on Save & Next below.)'."\n" if ($ENV{'form.handgrade'} eq 'yes'); + $request->print($result); } - $request->print($result); my %seen = (); my @partlist; @@ -1503,7 +1523,6 @@ KEYWORDS # print end of form if ($counter == $total) { my $endform='\n"; -# } else { -# $result.=''. -# "\n"; -# $result.=''."\n"; + } else { + $result.=''. + "\n"; + $result.=''."\n"; } } $result.=''; @@ -2276,7 +2295,7 @@ sub editgrades { my $awarded = $ENV{'form.GD_'.$user.'_'.$part.'_'.$type}; if ($awarded ne '' && $awarded ne $old_aw) { $newrecord{'resource.'.$part.'.'.$type}= $awarded; - $newrecord{'resource.'.$part.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; + $newrecord{'resource.'.$part.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; $updateflag=1; } $line .= ''. @@ -2405,7 +2424,7 @@ sub csvuploadmap_header { $javascript=&csvupload_javascript_forward_associate(); } - my ($result,$resptype,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'}); + my ($result) = &showResourceInfo($url,$ENV{'form.probTitle'}); $request->print(< @@ -2617,7 +2636,7 @@ sub csvuploadassign { # #------------------------------------------------------------------- # -#-------------- Next few routines handles grading by page/sequence +#-------------- Next few routines handle grading by page/sequence # #--- Select a page/sequence and a student to grade sub pickStudentPage { @@ -2676,7 +2695,7 @@ LISTJAVASCRIPT $result.=' Submission Details: '. ' none'."\n". - ' dates and submissions'."\n". + ' by dates and submissions'."\n". ' all details'."\n"; $result.=''."\n". @@ -2837,7 +2856,7 @@ sub displayPage { foreach my $partid (@{$parts}) { $responseType{$partid} = $curRes->responseType($partid); } - $studentTable.= &displaySubByDates(\%record,$parts,\%responseType,$checkIcon); + $studentTable.= &displaySubByDates(\$symbx,\%record,$parts,\%responseType,$checkIcon); } } elsif ($ENV{'form.lastSub'} eq 'all') { my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : ''); @@ -2872,7 +2891,7 @@ sub displayPage { } sub displaySubByDates { - my ($record,$parts,$responseType,$checkIcon) = @_; + my ($symbx,$record,$parts,$responseType,$checkIcon) = @_; my $studentTable='
'."\n"; -# ''."\n"; $endform.='  '."\n"; @@ -1666,7 +1685,6 @@ sub processHandGrade { $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); } # Called by Save & Refresh from Highlight Attribute Window -# my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0'); my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1'); if ($ENV{'form.refresh'} eq 'on') { my ($ctr,$total) = (0,0); @@ -1686,8 +1704,9 @@ sub processHandGrade { return ''; } -# Go directly to grade student - from submission page +# Go directly to grade student - from submission or link from chart page if ($button eq 'Grade Student') { + (undef,undef,$ENV{'form.handgrade'},undef,undef) = &showResourceInfo($url); my $processUser = $ENV{'form.unamedom'.$ENV{'form.studentNo'}}; ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$processUser); $ENV{'form.fullname'} = $$fullname{$processUser}; @@ -1795,7 +1814,7 @@ sub saveHandGrade { } $newrecord{'resource.'.$_.'.submitted_by'} = $submitter if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter)); - $newrecord{'resource.'.$_.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; + $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; } } @@ -2074,7 +2093,7 @@ sub viewgrades { my (@parts) = sort(&getpartlist($url)); foreach my $part (@parts) { my $display=&Apache::lonnet::metadata($url,$part.'.display'); - next if ($display =~ /Number of Attempts/); + $display =~ s/^Number of Attempts/Tries/; # makes the column narrower if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); } if ($display =~ /^Partial Credit Factor/) { my ($partid) = &split_part_type($part); @@ -2146,13 +2165,13 @@ sub viewstudentgrade { if ($status eq 'excused'); $result.=$optsel; $result.="
'.$old_aw.' 
'. ''. ''. @@ -2881,6 +2900,8 @@ sub displaySubByDates { my ($version); my %mark; $mark{'correct_by_student'} = $checkIcon; + return '
 Nothing submitted - no attempts
' + if (!exists($$record{'1:timestamp'})); for ($version=1;$version<=$$record{'version'};$version++) { my $timestamp = scalar(localtime($$record{$version.':timestamp'})); $studentTable.=''; @@ -2888,17 +2909,16 @@ sub displaySubByDates { my @displaySub = (); foreach my $partid (@{$parts}) { my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys; - next if ($$record{"$version:resource.$partid.solved"} eq ''); +# next if ($$record{"$version:resource.$partid.solved"} eq ''); $displaySub[0].=(exists $$record{$version.':'.$matchKey[0]}) ? 'Part '.$partid.' '. ($$record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' : 'Trial '.$$record{"$version:resource.$partid.tries"}).'  '. - &cleanRecord($$record{$version.':'.$matchKey[0]},$$responseType{$partid}).'
' : ''; + &cleanRecord($$record{$version.':'.$matchKey[0]},$$responseType{$partid},$$symbx).'
' : ''; $displaySub[1].=(exists $$record{"$version:resource.$partid.award"}) ? 'Part '.$partid.'  '. lc($$record{"$version:resource.$partid.award"}).' '. $mark{$$record{"$version:resource.$partid.solved"}}.'
' : ''; -# $$record{"$version:resource.$partid.solved"}.'
' : ''; $displaySub[2].=(exists $$record{"$version:resource.$partid.regrader"}) ? $$record{"$version:resource.$partid.regrader"}.' (Part: '.$partid.')' : ''; } @@ -3413,7 +3433,7 @@ sub gradingmenu { GRADINGMENUJS &commonJSfunctions($request); my $result='

 Manual Grading/View Submission

'; - my ($table,$resptype,$hdgrade) = &showResourceInfo($url,$probTitle); + my ($table,undef,$hdgrade) = &showResourceInfo($url,$probTitle); $result.=$table; my (undef,$sections) = &getclasslist('all','0'); my $savedState = &savedState(); @@ -3425,7 +3445,6 @@ GRADINGMENUJS $result.=''."\n". ''."\n". ''."\n". - ''."\n". ''."\n". ''."\n". ''."\n".
Date/Time
'.$timestamp.'