--- loncom/homework/grades.pm 2002/07/18 21:27:57 1.39 +++ loncom/homework/grades.pm 2002/07/19 20:42:18 1.40 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.39 2002/07/18 21:27:57 ng Exp $ +# $Id: grades.pm,v 1.40 2002/07/19 20:42:18 ng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -167,7 +167,8 @@ sub listStudents {  View Problem: no yes
 Submissions: - last sub only + handgrade only + last sub only last sub & parts info all details @@ -486,14 +487,16 @@ KEYWORDS # Student info $request->print(($counter == 0 ? '' : '
')); my $fullname = ($ENV{'form.fullname'} ne '' ? $ENV{'form.fullname'} : &get_fullname($uname,$udom)); - my $result.='
'. + my $result=''."\n"; $result.='
'. '
'; + $result.=''; if ($ENV{'form.handgrade'} eq 'yes') { # my $subonly = &get_last_submission($symb,$uname,$udom,$ENV{'request.course.id'}); - my ($classlist) = &getclasslist('all','0'); +# my ($classlist) = &getclasslist('all','0'); + my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0'); my @collaborators; # foreach ( sort(@{ $$classlist{'all'} }) ) { # my ($uname,$udom) = split(/:/); @@ -503,24 +506,22 @@ KEYWORDS if (scalar(@collaborators) != 0) { $result.=''."\n"; $result.=''."\n"; } } - $result.='
Fullname: '.$fullname. '   Username: '.$uname. '   Domain: '.$udom.'
Collaborators: '; foreach (@collaborators) { - $result.=$_.' ('.&get_fullname($_,$udom).')    '; + $result.=$_.' ('.$$fullname{$_.':'.$udom}.')    '; +# $result.=$_.' ('.&get_fullname($_,$udom).')    '; } $result.='
'."\n"; - $request->print($result); + $request->print($result.'
'."\n"); my ($partlist,$handgrade) = &response_type($url); - # print student answer - if ($ENV{'form.lastSub'} eq 'lastonly') { + # print student answer + if ($ENV{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) { my ($string,$timestamp)=&get_last_submission ($symb,$uname,$udom,$ENV{'request.course.id'}); - my $lastsubonly='
'; - $lastsubonly.=''; - $lastsubonly.=''; if ($$timestamp eq '') { $lastsubonly.=''; @@ -532,12 +533,14 @@ KEYWORDS my ($ressub,$subval) = split(/:/,$_,2); $lastsubonly.=''; + ' Submission '.&keywords_highlight($subval).'' + if ($ENV{'form.lastSub'} eq 'lastonly' || + ($ENV{'form.lastSub'} eq 'hdgrade' && $$handgrade{$part} =~ /:yes$/)); } } } } - $lastsubonly.='
Last Submission Only'. + my $lastsubonly.='
Last Submission Only'. ($$timestamp eq '' ? '' : '    Date Submitted: '.$$timestamp).'
'.$$string[0].'
Part ID '. $partid.' Response ID '.$respid. - ' Submission '.&keywords_highlight($subval).'
'."\n"; + $lastsubonly.='
'."\n"; $request->print($lastsubonly); } else { $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom, @@ -554,6 +557,10 @@ KEYWORDS my %seen = (); my @partlist; + my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname); +# while (my ($k,$v) = each (%record)){ +# print "key=$k ==> value=$v
"; +# } for (sort keys(%$handgrade)) { my ($partid,$respid) = split(/_/); next if ($seen{$partid} > 0); @@ -563,12 +570,10 @@ KEYWORDS my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname); my $wgtmsg = ($wgt > 0 ? '(problem weight)' : 'problem weight assigned by computer'); $wgt = ($wgt > 0 ? $wgt : '1'); - my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname); - my $score = ($record{'resource.0.awarded'} eq '' ? '' : $record{'resource.0.awarded'}*$wgt); + my $score = ($record{'resource.'.$partid.'.awarded'} eq '' ? '' : $record{'resource.'.$partid.'.awarded'}*$wgt); # display grading options $result=''; - $result.='
Part '.$partid.' Points'; my $ctr = 0; @@ -612,18 +617,17 @@ KEYWORDS my $endform.='
'; my $ntstu =''."\n"; + ''. + ''."\n"; my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1'); - $ntstu =~ s/
'; + $ntstu =~ s/
'; $request->print($endform); } - return ''; } @@ -672,12 +676,12 @@ sub processHandGrade { my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'}; my %keyhash = (); - $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g; - $ENV{'form.keywords'} =~ s/^\s+|\s+$//; - $keyhash{$symb.'_keywords'} = $ENV{'form.keywords'}; - $keyhash{$symb.'_subject'} = $ENV{'form.msgsub'}; - $keyhash{$loginuser.'_kwclr'} = $ENV{'form.kwclr'}; - $keyhash{$loginuser.'_kwsize'} = $ENV{'form.kwsize'}; + $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g; + $ENV{'form.keywords'} =~ s/^\s+|\s+$//; + $keyhash{$symb.'_keywords'} = $ENV{'form.keywords'}; + $keyhash{$symb.'_subject'} = $ENV{'form.msgsub'}; + $keyhash{$loginuser.'_kwclr'} = $ENV{'form.kwclr'}; + $keyhash{$loginuser.'_kwsize'} = $ENV{'form.kwsize'}; $keyhash{$loginuser.'_kwstyle'} = $ENV{'form.kwstyle'}; my ($ctr,$idx) = (1,1); @@ -706,9 +710,10 @@ sub processHandGrade { if ($ENV{'form.refresh'} eq 'on') { my $ctr = 0; - while ($ctr < $ntstu) { + $ENV{'form.NTSTU'}=$ngrade; + while ($ctr < $ngrade) { ($ENV{'form.student'},my $udom) = split(/:/,$ENV{'form.unamedom'.$ctr}); - &submission($request,$ctr,$ntstu-1); + &submission($request,$ctr,$ngrade-1); $ctr++; } return ''; @@ -745,51 +750,50 @@ sub processHandGrade { } } my $firststu = $ENV{'form.unamedom0'}; - my $laststu = $ENV{'form.unamedom'.($ngrade-1)}; - - my ($classlist) = &getclasslist($ENV{'form.section'},'0'); - my (@nextlist,@prevlist); - my ($nextflg,$ctr,$ctprev) = (0,0,0); - my ($partlist,$handgrade) = &response_type($ENV{'form.url'}); - foreach my $student ( sort(@{ $$classlist{$ENV{'form.section'}} }) ) { - my ($uname,$udom) = split(/:/,$student); - my (%status) = &student_gradeStatus($ENV{'form.url'},$udom,$uname,$partlist); - my $statusflg = ''; - foreach (keys(%status)) { - $statusflg = 1 if ($status{$_} ne 'nothing'); - } - next if ($statusflg eq '' && $ENV{'form.submitonly'} eq 'yes'); + my $laststu = $ENV{'form.unamedom'.($ngrade-1)}; + $ctr = 2; + while ($laststu eq '') { + $laststu = $ENV{'form.unamedom'.($ngrade-$ctr)}; + $ctr++; + $laststu = $firststu if ($ctr > $ngrade); + } + my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0'); + my (@parsedlist,@nextlist); + my ($nextflg) = 0; + foreach ( sort(@{ $$classlist{$ENV{'form.section'}} }) ) { if ($nextflg == 1 && $button =~ /Next$/) { - push @nextlist,$uname if ($ctr < $ntstu); - $ctr++; - last if ($ctr == $ntstu); + push @parsedlist,$_; } - $nextflg = 1 if ($student eq $laststu); + $nextflg = 1 if ($_ eq $laststu); if ($button eq 'Previous') { - last if ($student eq $firststu); - push @prevlist,$uname; - $ctprev++; + last if ($_ eq $firststu); + push @parsedlist,$_; } } - - if ($button eq 'Previous') { - if ($ctprev <= $ntstu) { - @nextlist = @prevlist; - } else { - my $idx = 0; - my $start = $ctprev - $ntstu; - while ($idx < $ntstu) { - $nextlist[$idx] = $prevlist[$start+$idx]; - $idx++; + $ctr = 0; + my ($partlist,$handgrade) = &response_type($ENV{'form.url'}); + @parsedlist = reverse @parsedlist if ($button eq 'Previous'); + foreach my $student (@parsedlist) { + my ($uname,$udom) = split(/:/,$student); + if ($ENV{'form.submitonly'} eq 'yes') { + my (%status) = &student_gradeStatus($ENV{'form.url'},$udom,$uname,$partlist) ; + my $statusflg = ''; + foreach (keys(%status)) { + $statusflg = 1 if ($status{$_} ne 'nothing'); } + next if ($statusflg eq ''); } + push @nextlist,$student if ($ctr < $ntstu); + $ctr++; } $ctr = 0; my $total = scalar(@nextlist)-1; - foreach my $student (@nextlist) { - $ENV{'form.student'} = $student; + foreach (sort @nextlist) { + my ($uname,$udom) = split(/:/); + $ENV{'form.student'} = $uname; + $ENV{'form.fullname'} = $$fullname{$_}; &submission($request,$ctr,$total); $ctr++; } @@ -830,10 +834,10 @@ sub saveHandGrade { if ( scalar(keys(%newrecord)) > 0 ) { $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; - while (my ($k,$v) = each %newrecord) { - print "k=$k:v=$v:
\n"; - } -# &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},$domain,$stuname); +# while (my ($k,$v) = each %newrecord) { +# print "k=$k:v=$v:
\n"; +# } + &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},$domain,$stuname); } return ''; } @@ -974,11 +978,11 @@ sub viewGradeaStu_form { $result.=' View/Grade an Individual Student\'s Submission
'."\n"; $result.='
'."\n". - ''."\n". + ''."\n". ''."\n". - ''."\n". - ''."\n". - ''."\n"; + ''."\n". + ''."\n". + ''."\n"; $result.=' Select section: '."\n"; $result.='  Display students who has: '. ' submitted'. - ' everybody
'; + ' everybody
'; $result.=' (Section "no" implies the students were not assigned a section.)
' if (grep /no/,@$sections); @@ -1341,9 +1345,15 @@ function displaySavedMsg(ctr,msg,shwsel) hwdWin.document.write(" opener.document.SCORE.kwclr.value = radioSelection(document.hlCenter.kwdclr);"); hwdWin.document.write(" opener.document.SCORE.kwsize.value = radioSelection(document.hlCenter.kwdsize);"); hwdWin.document.write(" opener.document.SCORE.kwstyle.value = radioSelection(document.hlCenter.kwdstyle);"); +// hwdWin.document.write(" var kwords=opener.document.SCORE.keywords.value;"); +// hwdWin.document.write(" alert(\\"keywords=\\"+opener.document.SCORE.keywords.value);"); +// hwdWin.document.write(" return;"); + hwdWin.document.write(" if (flag==1){"); hwdWin.document.write(" opener.document.SCORE.refresh.value = \\"on\\";"); - hwdWin.document.write(" opener.document.SCORE.submit();"); + hwdWin.document.write(" if (opener.document.SCORE.keywords.value!=\\"\\"){"); + hwdWin.document.write(" opener.document.SCORE.submit();"); + hwdWin.document.write(" }"); hwdWin.document.write(" }"); hwdWin.document.write(" self.close()"); hwdWin.document.write("}"); @@ -1385,8 +1395,8 @@ function displaySavedMsg(ctr,msg,shwsel) function highlightend() { hwdWin.document.write("
"); hwdWin.document.write("
 "); - hwdWin.document.write("  "); - hwdWin.document.write("  "); + hwdWin.document.write("  "); + hwdWin.document.write("  "); hwdWin.document.write("

"); hwdWin.document.write(""); hwdWin.document.write("");