--- loncom/homework/grades.pm 2003/07/29 20:54:39 1.128 +++ loncom/homework/grades.pm 2003/08/17 18:36:46 1.130.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.128 2003/07/29 20:54:39 ng Exp $ +# $Id: grades.pm,v 1.130.2.1 2003/08/17 18:36:46 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -96,6 +96,18 @@ sub get_fullname { return $fullname; } +#--- Format fullname, username:domain if different for display +#--- Use anywhere where the student names are listed +sub nameUserString { + my ($type,$fullname,$uname,$udom) = @_; + if ($type eq 'header') { + return '<b> Fullname </b><font color="#999999">(Username)</font> '; + } else { + return ' '.$fullname.'<font color="#999999"> ('.$uname. + ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')</font>'; + } +} + #--- Get the partlist and the response type for a given problem. --- #--- Indicate if a response type is coded handgraded or not. --- sub response_type { @@ -539,8 +551,7 @@ LISTJAVASCRIPT my $loop = 0; while ($loop < 2) { $gradeTable.='<td><b> No.</b> </td><td><b> Select </b></td>'. - '<td><b> Fullname </b>'. - '<font color="#999999">(Username)</font> </td>'; + '<td>'.&nameUserString('header').'</td>'; if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') { foreach (sort(@$partlist)) { $gradeTable.='<td><b> Part '.(split(/_/))[0].' Status </b></td>'; @@ -577,8 +588,7 @@ LISTJAVASCRIPT $gradeTable.='<td align="right">'.$ctr.' </td>'. '<td align="center"><input type=checkbox name="stuinfo" value="'. $student.':'.$$fullname{$student}.' "></td>'."\n". - '<td> '.$$fullname{$student}.' '."\n". - '<font color="#999999">('.$uname.')</font></td>'."\n"; + '<td>'.&nameUserString(undef,$$fullname{$student},$uname,$udom).'</td>'."\n"; if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') { foreach (sort keys(%status)) { @@ -758,7 +768,9 @@ sub sub_page_js { var points = formname["GD_BOX"+i+"_"+partid].value; if (points == "") { var name = formname["name"+i].value; - var resp = confirm("You did not assign a score for "+name+", part "+partid+". Continue?"); + var studentID = (name != '' ? name : formname["unamedom"+i].value); + var resp = confirm("You did not assign a score for "+studentID+ + ", part "+partid+". Continue?"); if (resp == false) { formname["GD_BOX"+i+"_"+partid].focus(); return false; @@ -1351,9 +1363,7 @@ KEYWORDS my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'."\n". '<table border="0" width=100%><tr bgcolor="#edffff"><td>'."\n"; - $result.='<b>Fullname: </b>'.$ENV{'form.fullname'}. - '<font color="#999999"> Username: '.$uname. - ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').'</font><br />'."\n"; + $result.='<b>Fullname: </b>'.&nameUserString(undef,$ENV{'form.fullname'},$uname,$udom).'<br />'."\n"; $result.='<input type="hidden" name="name'.$counter. '" value="'.$ENV{'form.fullname'}.'" />'."\n"; @@ -1531,17 +1541,21 @@ KEYWORDS my %seen = (); my @partlist; + my @gradePartRespid; for (sort keys(%$handgrade)) { my ($partid,$respid) = split(/_/); next if ($seen{$partid} > 0); $seen{$partid}++; next if ($$handgrade{$_} =~ /:no$/ && $ENV{'form.lastSub'} =~ /^(hdgrade)$/); push @partlist,$partid; + push @gradePartRespid,$partid.'.'.$respid; $request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record)); } $result='<input type="hidden" name="partlist'.$counter. '" value="'.(join ":",@partlist).'" />'."\n"; + $result.='<input type="hidden" name="gradePartRespid'. + '" value="'.(join ":",@gradePartRespid).'" />'."\n" if ($counter == 0); my $ctr = 0; while ($ctr < scalar(@partlist)) { $result.='<input type="hidden" name="partid'.$counter.'_'.$ctr.'" value="'. @@ -1773,12 +1787,13 @@ sub processHandGrade { if ($ENV{'form.submitonly'} eq 'yes') { my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname); my $statusflg = ''; - foreach (split(/:/,$ENV{'form.partlist0'})){ - $statusflg = 1 if (exists ($record{'resource.'.$_.'.solved'})); + foreach (split(/:/,$ENV{'form.gradePartRespid'})){ + $statusflg = 1 if (exists ($record{'resource.'.$_.'.submission'})); } next if ($statusflg eq ''); } push @nextlist,$student if ($ctr < $ntstu); + last if ($ctr == $ntstu); $ctr++; } @@ -2116,7 +2131,7 @@ sub viewgrades { $result.= '<h3>Assign Grade to Specific Students in '.$sectionClass; $result.= '<table border=0><tr><td bgcolor="#777777">'."\n". '<table border=0><tr bgcolor="#deffff"><td> <b>No.</b> </td>'. - '<td> <b>Fullname</b> <font color="#999999">(Username)</font></td>'."\n"; + '<td>'.&nameUserString('header')."</td>\n"; my (@parts) = sort(&getpartlist($url)); foreach my $part (@parts) { my $display=&Apache::lonnet::metadata($url,$part.'.display'); @@ -2160,7 +2175,7 @@ sub viewgrades { #--- call by previous routine to display each student sub viewstudentgrade { - my ($$url,$symb,$courseid,$student,$fullname,$parts,$weight,$ctr) = @_; + my ($url,$symb,$courseid,$student,$fullname,$parts,$weight,$ctr) = @_; my ($uname,$udom) = split(/:/,$student); $student=~s/:/_/; my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname); @@ -2216,8 +2231,9 @@ sub editgrades { $title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n"; my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n"; - $result.= '<table border="0"><tr bgcolor="#deffff"><td rowspan=2> <b>No.</b> </td>'. - '<td rowspan=2> <b>Fullname</b> <font color="#999999">(username)</font></td>'."\n"; + $result.= '<table border="0"><tr bgcolor="#deffff">'. + '<td rowspan=2 valign="center"> <b>No.</b> </td>'. + '<td rowspan=2 valign="center">'.&nameUserString('header')."</td>\n"; my %scoreptr = ( 'correct' =>'correct_by_override', @@ -2276,8 +2292,7 @@ sub editgrades { my ($uname,$udom)=split(/_/,$user); my %newrecord; my $updateflag = 0; - $line .= '<td> '.$$fullname{$usercolon}. - ' <font color="#999999">('.$uname.($udom eq $ENV{'user.domain'} ? '' : '$udom').')</font></td>'; + $line .= '<td>'.&nameUserString(undef,$$fullname{$usercolon},$uname,$udom).'</td>'; my $usec=$classlist->{"$uname:$udom"}[5]; if (!&canmodify($usec)) { my $numcols=scalar(@partid)*4+2; @@ -2495,7 +2510,6 @@ to this page if the data selected is ins $javascript </script> ENDPICK - $request->print(&show_grading_menu_form($symb,$url)); return ''; } @@ -2756,9 +2770,9 @@ LISTJAVASCRIPT '<table border="0"><tr><td bgcolor="#777777">'. '<table border="0"><tr bgcolor="#e6ffff">'. '<td align="right"> <b>No.</b></td>'. - '<td><b> Fullname <font color="#999999">(username)</font></b></td>'. + '<td>'.&nameUserString('header').'</td>'. '<td align="right"> <b>No.</b></td>'. - '<td><b> Fullname <font color="#999999">(username)</font></b></td></tr>'; + '<td>'.&nameUserString('header').'</td></tr>'; my (undef,undef,$fullname) = &getclasslist($getsec,'1'); my $ptr = 1; @@ -2766,8 +2780,8 @@ LISTJAVASCRIPT my ($uname,$udom) = split(/:/,$student); $studentTable.=($ptr%2 == 1 ? '<tr bgcolor="#ffffe6">' : '</td>'); $studentTable.='<td align="right">'.$ptr.' </td>'; - $studentTable.='<td> <input type="radio" name="student" value="'.$student.'" /> '.$$fullname{$student}. - '<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font>'."\n"; + $studentTable.='<td> <input type="radio" name="student" value="'.$student.'" /> ' + .&nameUserString(undef,$$fullname{$student},$uname,$udom)."\n"; $studentTable.=($ptr%2 == 0 ? '</td></tr>' : ''); $ptr++; } @@ -2826,9 +2840,8 @@ sub displayPage { return; } my $result='<h3><font color="#339933"> '.$ENV{'form.title'}.'</font></h3>'; - $result.='<h3> Student: '.$$fullname{$ENV{'form.student'}}. - '<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font></h3>'."\n"; - + $result.='<h3> Student: '.&nameUserString(undef,$$fullname{$ENV{'form.student'}},$uname,$udom). + '</h3>'."\n"; &sub_page_js($request); $request->print($result); @@ -2990,8 +3003,8 @@ sub updateGradeByPage { return; } my $result='<h3><font color="#339933"> '.$ENV{'form.title'}.'</font></h3>'; - $result.='<h3> Student: '.$ENV{'form.fullname'}. - '<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font></h3>'."\n"; + $result.='<h3> Student: '.&nameUserString(undef,$ENV{'form.fullname'},$uname,$udom). + '</h3>'."\n"; $request->print($result);