--- loncom/homework/grades.pm 2003/07/16 19:28:08 1.117
+++ loncom/homework/grades.pm 2003/07/29 20:54:39 1.128
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.117 2003/07/16 19:28:08 bowersj2 Exp $
+# $Id: grades.pm,v 1.128 2003/07/29 20:54:39 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@
# June-August H.K. Ng
# Year 2003
# February, March H.K. Ng
+# July, H. K. Ng
#
package Apache::grades;
@@ -98,7 +99,8 @@ sub get_fullname {
#--- Get the partlist and the response type for a given problem. ---
#--- Indicate if a response type is coded handgraded or not. ---
sub response_type {
- my ($url) = shift;
+ my ($url,$symb) = shift;
+ $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url))) if ($symb eq '');
my $allkeys = &Apache::lonnet::metadata($url,'keys');
my %seen = ();
my (@partlist,%handgrade);
@@ -106,7 +108,9 @@ sub response_type {
if (/^\w+response_\w+.*/) {
my ($responsetype,$part) = split(/_/,$_,2);
my ($partid,$respid) = split(/_/,$part);
- $handgrade{$part} = $responsetype.':'.($allkeys =~ /parameter_$part\_handgrade/ ? 'yes' : 'no');
+ $responsetype =~ s/response$//; # make it compatible w/ navmaps - should move to that!!
+ my ($value) = &Apache::lonnet::EXT('resource.'.$part.'.handgrade',$symb);
+ $handgrade{$part} = $responsetype.':'.($value eq 'yes' ? 'yes' : 'no');
next if ($seen{$partid} > 0);
$seen{$partid}++;
push @partlist,$partid;
@@ -115,10 +119,105 @@ sub response_type {
return \@partlist,\%handgrade;
}
+#--- Show resource title
+#--- and parts and response type
+sub showResourceInfo {
+ my ($url,$probTitle) = @_;
+ my $result ='
'."\n".
- ' '.
- '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);
+ # essay grading message center
+ if ($ENV{'form.handgrade'} eq 'yes') {
+ my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
+ my $msgfor = $givenn.' '.$lastname;
+ if (scalar(@col_fullnames) > 0) {
+ my $lastone = pop @col_fullnames;
+ $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
+ }
+ $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
+ $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);
+ }
my %seen = ();
my @partlist;
@@ -1394,7 +1535,7 @@ KEYWORDS
my ($partid,$respid) = split(/_/);
next if ($seen{$partid} > 0);
$seen{$partid}++;
-# next if ($$handgrade{$_} =~ /:no$/);
+ next if ($$handgrade{$_} =~ /:no$/ && $ENV{'form.lastSub'} =~ /^(hdgrade)$/);
push @partlist,$partid;
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
@@ -1411,28 +1552,22 @@ KEYWORDS
# print end of form
if ($counter == $total) {
- my $endform=''.
- ' '."\n";
- if ($ENV{'form.handgrade'} eq 'yes') {
- $endform.=' '."\n";
- my $ntstu =''.
- '1 2 '.
- '3 5 '.
- '7 10 '."\n";
- my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1');
- $ntstu =~ s/$nsel $nsel;
- $endform.=$ntstu.'student(s) ';
- } else {
- $endform.=' '."\n";
- }
- $endform.=' '."\n".
- ' ';
- $endform.='(Next and Previous do not save the scores.)'."\n"
- if ($ENV{'form.handgrade'} eq 'yes');
+ my $endform='';
$endform.=&show_grading_menu_form($symb,$url);
$request->print($endform);
@@ -1442,15 +1577,15 @@ KEYWORDS
#--- Retrieve the last submission for all the parts
sub get_last_submission {
- my (%returnhash)=@_;
+ my ($returnhash)=@_;
my (@string,$timestamp);
- if ($returnhash{'version'}) {
+ if ($$returnhash{'version'}) {
my %lasthash=();
my ($version);
- for ($version=1;$version<=$returnhash{'version'};$version++) {
- foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
- $lasthash{$_}=$returnhash{$version.':'.$_};
- $timestamp = scalar(localtime($returnhash{$version.':timestamp'}));
+ for ($version=1;$version<=$$returnhash{'version'};$version++) {
+ foreach (sort(split(/\:/,$$returnhash{$version.':keys'}))) {
+ $lasthash{$_}=$$returnhash{$version.':'.$_};
+ $timestamp = scalar(localtime($$returnhash{$version.':timestamp'}));
}
}
foreach ((keys %lasthash)) {
@@ -1462,7 +1597,7 @@ sub get_last_submission {
}
}
}
- @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
+ @string = $string[0] eq '' ? 'Nothing submitted - no attempts. ' : @string;
return \@string,\$timestamp;
}
@@ -1474,13 +1609,8 @@ sub keywords_highlight {
(my $styleoff = $styleon) =~ s/\\<\//;
my @keylist = split(/[,\s+]/,$ENV{'form.keywords'});
foreach (@keylist) {
- $string =~ s/\b\Q$_\E(\b|\.)/\$styleon$_$styleoff\<\/font\>/gi;
+ $string =~ s/\b\Q$_\E(\b|\.)/$styleon$_$styleoff<\/font>/gi;
}
- # This is not really the right place to do this, but I cannot find a
- # better one at this time. So here we go - the m in the s:::mg causes
- # ^ to match the beginning of a new line. So we replace(???) the beginning
- # of the line with to make things formatted a little better.
- $string =~ s:^: :mg;
return $string;
}
@@ -1492,7 +1622,6 @@ sub processHandGrade {
my $button = $ENV{'form.gradeOpt'};
my $ngrade = $ENV{'form.NCT'};
my $ntstu = $ENV{'form.NTSTU'};
-
if ($button eq 'Save & Next') {
my $ctr = 0;
while ($ctr < $ngrade) {
@@ -1526,7 +1655,8 @@ sub processHandGrade {
if ($ENV{'form.collaborator'.$ctr}) {
my (@collaborators) = split(/:/,$ENV{'form.collaborator'.$ctr});
foreach (@collaborators) {
- my ($errorflag,$pts,$wgt) = &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,$ENV{'form.unamedom'.$ctr});
+ my ($errorflag,$pts,$wgt) =
+ &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,$ENV{'form.unamedom'.$ctr});
if ($errorflag eq 'not_allowed') {
$request->print("Not allowed to modify grades for $_:$udom ");
next;
@@ -1543,48 +1673,49 @@ sub processHandGrade {
}
}
- # Keywords sorted in alphabatical order
- my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
- my %keyhash = ();
- $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
- $ENV{'form.keywords'} =~ s/^\s+|\s+$//;
- my (@keywords) = sort(split(/\s+/,$ENV{'form.keywords'}));
- $ENV{'form.keywords'} = join(' ',@keywords);
- $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'};
-
- # message center - Order of message gets changed. Blank line is eliminated.
- # New messages are saved in ENV for the next student.
- # All messages are saved in nohist_handgrade.db
- my ($ctr,$idx) = (1,1);
- while ($ctr <= $ENV{'form.savemsgN'}) {
- if ($ENV{'form.savemsg'.$ctr} ne '') {
- $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.savemsg'.$ctr};
- $idx++;
+ if ($ENV{'form.handgrade'} eq 'yes') {
+ # Keywords sorted in alphabatical order
+ my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+ my %keyhash = ();
+ $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
+ $ENV{'form.keywords'} =~ s/^\s+|\s+$//;
+ my (@keywords) = sort(split(/\s+/,$ENV{'form.keywords'}));
+ $ENV{'form.keywords'} = join(' ',@keywords);
+ $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'};
+
+ # message center - Order of message gets changed. Blank line is eliminated.
+ # New messages are saved in ENV for the next student.
+ # All messages are saved in nohist_handgrade.db
+ my ($ctr,$idx) = (1,1);
+ while ($ctr <= $ENV{'form.savemsgN'}) {
+ if ($ENV{'form.savemsg'.$ctr} ne '') {
+ $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.savemsg'.$ctr};
+ $idx++;
+ }
+ $ctr++;
}
- $ctr++;
- }
- $ctr = 0;
- while ($ctr < $ngrade) {
- if ($ENV{'form.newmsg'.$ctr} ne '') {
- $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
- $ENV{'form.savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
- $idx++;
+ $ctr = 0;
+ while ($ctr < $ngrade) {
+ if ($ENV{'form.newmsg'.$ctr} ne '') {
+ $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
+ $ENV{'form.savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
+ $idx++;
+ }
+ $ctr++;
}
- $ctr++;
+ $ENV{'form.savemsgN'} = --$idx;
+ $keyhash{$symb.'_savemsgN'} = $ENV{'form.savemsgN'};
+ my $putresult = &Apache::lonnet::put
+ ('nohist_handgrade',\%keyhash,
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
}
- $ENV{'form.savemsgN'} = --$idx;
- $keyhash{$symb.'_savemsgN'} = $ENV{'form.savemsgN'};
- my $putresult = &Apache::lonnet::put
- ('nohist_handgrade',\%keyhash,
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $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);
while ($ctr < $ngrade) {
@@ -1603,10 +1734,20 @@ sub processHandGrade {
return '';
}
+# 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};
+ &submission($request,0,0);
+ return '';
+ }
+
# Get the next/previous one or group of students
my $firststu = $ENV{'form.unamedom0'};
my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
- $ctr = 2;
+ my $ctr = 2;
while ($laststu eq '') {
$laststu = $ENV{'form.unamedom'.($ngrade-$ctr)};
$ctr++;
@@ -1626,17 +1767,14 @@ sub processHandGrade {
}
}
$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'},$symb,$udom,$uname,$partlist) ;
+ my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
my $statusflg = '';
- foreach (keys(%status)) {
- $statusflg = 1 if ($status{$_} ne 'nothing');
- my ($foo,$partid,$foo1) = split(/\./);
- $statusflg = '' if ($status{'resource.'.$partid.'.submitted_by'} ne '');
+ foreach (split(/:/,$ENV{'form.partlist0'})){
+ $statusflg = 1 if (exists ($record{'resource.'.$_.'.solved'}));
}
next if ($statusflg eq '');
}
@@ -1675,14 +1813,23 @@ sub saveHandGrade {
my %newrecord = ();
my ($pts,$wgt) = ('','');
foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
- if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') {
+ my $dropMenu = $ENV{'form.GD_SEL'.$newflg.'_'.$_};
+ if ($dropMenu eq 'excused') {
if ($record{'resource.'.$_.'.solved'} ne 'excused') {
$newrecord{'resource.'.$_.'.solved'} = 'excused';
if (exists($record{'resource.'.$_.'.awarded'})) {
$newrecord{'resource.'.$_.'.awarded'} = '';
}
+ $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
}
- } else {
+ } elsif ($dropMenu eq 'reset status'
+ && exists($record{'resource.'.$_.'.solved'})) { #don't bother if no old records -> no attempts
+ $newrecord{'resource.'.$_.'.tries'} = 0;
+ $newrecord{'resource.'.$_.'.solved'} = '';
+ $newrecord{'resource.'.$_.'.award'} = '';
+ $newrecord{'resource.'.$_.'.awarded'} = 0;
+ $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ } elsif ($dropMenu eq '') {
$pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ?
$ENV{'form.GD_BOX'.$newflg.'_'.$_} :
$ENV{'form.RADVAL'.$newflg.'_'.$_});
@@ -1690,6 +1837,7 @@ sub saveHandGrade {
$wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :
$ENV{'form.WGT'.$newflg.'_'.$_};
my $partial= $pts/$wgt;
+ next if ($partial eq $record{'resource.'.$_.'.awarded'}); #do not update score for part if not changed.
$newrecord{'resource.'.$_.'.awarded'} = $partial
if ($record{'resource.'.$_.'.awarded'} ne $partial);
my $reckey = 'resource.'.$_.'.solved';
@@ -1702,7 +1850,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'}";
}
}
@@ -1724,10 +1872,10 @@ sub viewgrades_js {
$request->print(<
function writePoint(partid,weight,point) {
- var radioButton = eval("document.classgrade.RADVAL_"+partid);
- var textbox = eval("document.classgrade.TEXTVAL_"+partid);
+ var radioButton = document.classgrade["RADVAL_"+partid];
+ var textbox = document.classgrade["TEXTVAL_"+partid];
if (point == "textval") {
- var point = eval("document.classgrade.TEXTVAL_"+partid+".value");
+ point = document.classgrade["TEXTVAL_"+partid].value;
if (isNaN(point) || parseFloat(point) < 0) {
alert("A number equal or greater than 0 is expected. Entered value = "+parseFloat(point));
var resetbox = false;
@@ -1758,15 +1906,13 @@ sub viewgrades_js {
}
} else {
- textbox.value = point;
+ textbox.value = parseFloat(point);
}
for (i=0;iManual Grading ';
- $result.='Problem: '.$ENV{'form.probTitle'}.' '."\n";
+ $result.='Current Resource: '.$ENV{'form.probTitle'}.' '."\n";
#view individual student submission form - called using Javascript viewOneStudent
$result.=&jscriptNform($url,$symb);
@@ -1907,21 +2050,23 @@ sub viewgrades {
' '."\n".
' '."\n".
' '."\n".
+ ' '."\n".
' '."\n";
- $result.='Assign Common Grade To ';
+ my $sectionClass;
if ($ENV{'form.section'} eq 'all') {
- $result.='Class ';
+ $sectionClass='Class ';
} elsif ($ENV{'form.section'} eq 'no') {
- $result.='Students in no Section ';
+ $sectionClass='Students in no Section ';
} else {
- $result.='Students in Section '.$ENV{'form.section'}.'';
+ $sectionClass='Students in Section '.$ENV{'form.section'}.'';
}
+ $result.='Assign Common Grade To '.$sectionClass;
$result.= ' '."\n".
'';
#radio buttons/text box for assigning points for a section or class.
#handles different parts of a problem
- my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
+ my ($partlist,$handgrade) = &response_type($url,$symb);
my %weight = ();
my $ctsparts = 0;
$result.='';
@@ -1957,33 +2102,25 @@ sub viewgrades {
'onChange="javascript:writeRadText(\''.$partid.'\','.
$weight{$partid}.')"> '.
' '.
- 'excused '."\n";
+ 'excused '.
+ 'reset status '."\n";
$ctsparts++;
}
$result.='
'.'
'.'
'."\n".
' ';
$result.=' ';
-# $result.=' '."\n";
#table listing all the students in a section/class
#header of table
- $result.= 'Assign Grade to Specific Students in ';
- if ($ENV{'form.section'} eq 'all') {
- $result.='the Class ';
- } elsif ($ENV{'form.section'} eq 'no') {
- $result.='no Section ';
- } else {
- $result.='Section '.$ENV{'form.section'}.'';
- }
+ $result.= 'Assign Grade to Specific Students in '.$sectionClass;
$result.= ' '."\n".
- ''.
- 'Fullname (Username) '."\n";
+ ' No. '.
+ ' Fullname (Username) '."\n";
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);
@@ -2004,13 +2141,13 @@ sub viewgrades {
my $uname = $_;
$uname=~s/:/_/;
$result.=' '."\n";
- $result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
- $_,$$fullname{$_},\@parts,\%weight);
$ctr++;
+ $result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
+ $_,$$fullname{$_},\@parts,\%weight,$ctr);
}
$result.='
';
$result.=' '."\n";
- $result.=' '."\n";
if (scalar(%$fullname) eq 0) {
my $colspan=3+scalar(@parts);
@@ -2023,11 +2160,11 @@ sub viewgrades {
#--- call by previous routine to display each student
sub viewstudentgrade {
- my ($url,$symb,$courseid,$student,$fullname,$parts,$weight) = @_;
+ 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);
- my $result=' '.
+ my $result=' '.$ctr.' '.
''.$fullname.' '.
'('.$uname.($ENV{'user.domain'} eq $udom ? '' : ':'.$udom).') '."\n";
@@ -2047,21 +2184,20 @@ sub viewstudentgrade {
$status = 'nothing' if ($status eq '');
$result.=' '."\n";
- $result.=' '."\n";
- my $optsel = ' excused '."\n";
- $optsel = ' excused '."\n"
- if ($status eq 'excused');
- $result.=$optsel;
- $result.=" \n";
-# } else {
-# $result.=' '.
-# "\n";
-# $result.=' '."\n";
+ $result.= (($status eq 'excused') ? ' excused '
+ : ' excused ')."\n";
+ $result.='reset status ';
+ $result.=" \n";
+ } else {
+ $result.=' '.
+ "\n";
+ $result.=' '."\n";
}
}
$result.=' ';
@@ -2076,11 +2212,12 @@ sub editgrades {
my $symb=$ENV{'form.symb'};
my $url =$ENV{'form.url'};
my $title='Current Grade Status ';
- $title.='Problem: '.$ENV{'form.probTitle'}.' '."\n";
+ $title.='Current Resource: '.$ENV{'form.probTitle'}.' '."\n";
$title.='Section: '.$ENV{'form.section'}.' '."\n";
+
my $result= ''."\n";
- $result.= ''.
- 'Username Domain Fullname '."\n";
+ $result.= ' No. '.
+ ' Fullname (username) '."\n";
my %scoreptr = (
'correct' =>'correct_by_override',
@@ -2114,8 +2251,9 @@ sub editgrades {
if ($type eq 'awarded' || $type eq 'solved') { next; }
my $display=&Apache::lonnet::metadata($url,$stores.'.display');
$display =~ s/\[Part: (\w)+\]//;
- $header .= ' Old '.$display.' '.
- ' New '.$display.' ';
+ $display =~ s/Number of Attempts/Tries/;
+ $header .= ' Old '.$display.' '.
+ ' New '.$display.' ';
$columns{$partid}+=2;
}
}
@@ -2129,6 +2267,7 @@ sub editgrades {
$result .= $header;
$result .= ' '."\n";
my $noupdate;
+ my ($updateCtr,$noupdateCtr) = (1,1);
for ($i=0; $i<$ENV{'form.total'}; $i++) {
my $line;
my $user = $ENV{'form.ctr'.$i};
@@ -2137,12 +2276,11 @@ sub editgrades {
my ($uname,$udom)=split(/_/,$user);
my %newrecord;
my $updateflag = 0;
- $line .= ''.$uname.' '.
- $udom.' '.
- $$fullname{$usercolon}.' ';
+ $line .= ' '.$$fullname{$usercolon}.
+ ' ('.$uname.($udom eq $ENV{'user.domain'} ? '' : '$udom').') ';
my $usec=$classlist->{"$uname:$udom"}[5];
if (!&canmodify($usec)) {
- my $numcols=scalar(@partid)*(scalar(@parts)-1)*2;
+ my $numcols=scalar(@partid)*4+2;
$noupdate.=$line."Not allowed to modify student ";
next;
}
@@ -2163,8 +2301,19 @@ sub editgrades {
} elsif ($partial == 0) {
$score = 'incorrect_by_override';
}
- $score = 'excused' if (($ENV{'form.GD_'.$user.'_'.$_.'_solved'} eq 'excused') &&
- ($score ne 'excused'));
+ my $dropMenu = $ENV{'form.GD_'.$user.'_'.$_.'_solved'};
+ $score = 'excused' if (($dropMenu eq 'excused') && ($score ne 'excused'));
+
+ if ($dropMenu eq 'reset status' &&
+ $old_score ne '') { # ignore if no previous attempts => nothing to reset
+ $newrecord{'resource.'.$_.'.tries'} = 0;
+ $newrecord{'resource.'.$_.'.solved'} = '';
+ $newrecord{'resource.'.$_.'.award'} = '';
+ $newrecord{'resource.'.$_.'.awarded'} = 0;
+ $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ $updateflag = 1;
+ }
+
$line .= ''.$old_aw.' '.
''.$awarded.
($score eq 'excused' ? $score : '').' ';
@@ -2185,7 +2334,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 .= ''.$old_aw.' '.
@@ -2197,18 +2346,21 @@ sub editgrades {
$count++;
&Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
$udom,$uname);
- $result.=$line;
+ $result.=' '.$updateCtr.' '.$line;
+ $updateCtr++;
} else {
- $noupdate.=$line;
+ $noupdate.=' '.$noupdateCtr.' '.$line;
+ $noupdateCtr++;
}
}
if ($noupdate) {
- my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3;
- $result .= 'No Changes Occured For the Students Below '.$noupdate;
+# my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3;
+ my $numcols=scalar(@partid)*4+2;
+ $result .= 'No Changes Occurred For the Students Below '.$noupdate;
}
$result .= '
'."\n".
&show_grading_menu_form ($symb,$url);
- my $msg = 'Number of records updated = '.$rec_update.
+ my $msg = 'Number of records updated = '.$rec_update.
' for '.$count.' student'.($count <= 1 ? '' : 's').'. '.
'Total number of students = '.$ENV{'form.total'}.' ';
return $title.$msg.$result;
@@ -2314,19 +2466,8 @@ sub csvuploadmap_header {
$javascript=&csvupload_javascript_forward_associate();
}
- my $result='';
- $result.='Problem: '.$ENV{'form.probTitle'}.' ';
- my ($partlist,$handgrade) = &response_type($url);
- my ($resptype,$hdgrade)=('','no');
- for (sort keys(%$handgrade)) {
- my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
- $resptype = $responsetype;
- $hdgrade = $handgrade if ($handgrade eq 'yes');
- $result.='Part '.(split(/_/))[0].' '.
- 'Type: '.$responsetype.' '.
- 'Handgrade: '.$handgrade.' ';
- }
- $result.='
';
+ my ($result) = &showResourceInfo($url,$ENV{'form.probTitle'});
+
$request->print(<
Uploading Class Grades
@@ -2354,7 +2495,8 @@ to this page if the data selected is ins
$javascript
ENDPICK
-return '';
+ $request->print(&show_grading_menu_form($symb,$url));
+ return '';
}
@@ -2400,9 +2542,11 @@ sub upcsvScores_form {
CSVFORMJS
$ENV{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
+ my ($table) = &showResourceInfo($url,$ENV{'form.probTitle'});
+ $result.=$table;
$result.=''."\n";
$result.=''."\n";
- $result.=' Specify a file containing the class scores for problem - '.$ENV{'form.probTitle'}.
+ $result.=' Specify a file containing the class scores for current resource'.
'. '."\n";
$result.=''."\n";
my $upfile_select=&Apache::loncommon::upfile_select_html();
@@ -2421,7 +2565,6 @@ ENDUPFORM
$result.='
'."\n";
$result.='
'."\n";
$result.=&show_grading_menu_form($symb,$url);
-
return $result;
}
@@ -2535,7 +2678,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 {
@@ -2549,41 +2692,15 @@ function checkPickOne(formname) {
alert("Please select the student you wish to grade.");
return;
}
- var ptr = pullDownSelection(formname.selectpage);
- formname.page.value = eval("formname.page"+ptr+".value");
- formname.title.value = eval("formname.title"+ptr+".value");
+ ptr = pullDownSelection(formname.selectpage);
+ formname.page.value = formname["page"+ptr].value;
+ formname.title.value = formname["title"+ptr].value;
formname.submit();
}
-function radioSelection(radioButton) {
- var selection=null;
- if (radioButton.length > 1) {
- for (var i=0; i 1) {
- for (var i=0; i
LISTJAVASCRIPT
-
+ &commonJSfunctions($request);
my ($symb,$url) = &get_symb_and_url($request);
my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"};
my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"};
@@ -2620,45 +2737,44 @@ LISTJAVASCRIPT
$result.=' Submission Details: '.
' none'."\n".
- ' dates and submissions'."\n".
+ ' by dates and submissions'."\n".
' all details'."\n";
$result.=' '."\n".
- ' '."\n".
+ ' '."\n".
' '."\n".
' '."\n".
' '."\n".
' '." \n";
$result.=' '."\n";
+ 'onClick="javascript:checkPickOne(this.form);"value="Next->" /> '."\n";
$request->print($result);
- my $studentTable.=' Select a student you wish to grade '.
+ my $studentTable.=' Select a student you wish to grade and then click on the Next button. '.
''."\n";
- $studentTable.=' '."\n";
+ $studentTable.=' " />'."\n";
$studentTable.=&show_grading_menu_form($symb,$url);
$request->print($studentTable);
@@ -2726,22 +2842,24 @@ sub displayPage {
my $studentTable=''."\n";
$studentTable.=&show_grading_menu_form($symb,$url);
@@ -2845,24 +2933,45 @@ sub displayPage {
return '';
}
-sub cleanRecord {
- my ($answer,$response) = @_;
- if ($response eq 'option') {
- my (@IDs,@ans);
- foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
- my ($optionID,$ans) = split(/=/);
- push @IDs,$optionID.'';
- push @ans,$ans;
- }
- my $grayFont = '';
- return ''.
- 'Answer '.
- (join ' ',@ans).' '.
- ''.$grayFont.'Option ID '.$grayFont.
- (join ' '.$grayFont,@IDs).' '.
- '
';
+sub displaySubByDates {
+ my ($symbx,$record,$parts,$responseType,$checkIcon) = @_;
+ my $studentTable=''.
+ ''.
+ 'Date/Time '.
+ 'Submission '.
+ 'Status ';
+ 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.=''.$timestamp.' ';
+ my @versionKeys = split(/\:/,$$record{$version.':keys'});
+ my @displaySub = ();
+ foreach my $partid (@{$parts}) {
+ my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;
+# 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},$$symbx).' ' : '';
+ $displaySub[1].=(exists $$record{"$version:resource.$partid.award"}) ?
+ 'Part '.$partid.' '.
+ lc($$record{"$version:resource.$partid.award"}).' '.
+ $mark{$$record{"$version:resource.$partid.solved"}}.' ' : '';
+ $displaySub[2].=(exists $$record{"$version:resource.$partid.regrader"}) ?
+ $$record{"$version:resource.$partid.regrader"}.' (Part: '.$partid.')' : '';
+ }
+ $displaySub[2].=(exists $$record{"$version:resource.regrader"}) ?
+ $$record{"$version:resource.regrader"} : ''; # needed because old essay regrader has not parts info
+ $studentTable.=''.$displaySub[0].' '.$displaySub[1].
+ ($displaySub[2] eq '' ? '' : 'Manually graded by '.$displaySub[2]).' ';
}
- return $answer;
+ $studentTable.='
';
+ return $studentTable;
}
sub updateGradeByPage {
@@ -2881,7 +2990,7 @@ sub updateGradeByPage {
return;
}
my $result=' '.$ENV{'form.title'}.' ';
- $result.=' Student: '.$$fullname{$ENV{'form.student'}}.
+ $result.=' Student: '.$ENV{'form.fullname'}.
' ('.$uname.($udom eq $cdom ? '':':'.$udom).') '."\n";
$request->print($result);
@@ -2896,7 +3005,7 @@ sub updateGradeByPage {
my $studentTable=' '.
''.
- ' No '.
+ ' Prob. '.
' Title '.
' Previous Score '.
' New Score ';
@@ -2928,31 +3037,39 @@ sub updateGradeByPage {
my $score;
if ($partial > 0) {
$score = 'correct_by_override';
- } elsif ($partial == 0) {
+ } elsif ($newpts ne '') { #empty is taken as 0
$score = 'incorrect_by_override';
}
- if ($ENV{'form.GD_SEL'.$question.'_'.$partid} eq 'excused') {
+ my $dropMenu = $ENV{'form.GD_SEL'.$question.'_'.$partid};
+ if ($dropMenu eq 'excused') {
$partial = '';
$score = 'excused';
+ } elsif ($dropMenu eq 'reset status'
+ && $ENV{'form.solved'.$question.'_'.$partid} ne '') { #update only if previous record exists
+ $newrecord{'resource.'.$partid.'.tries'} = 0;
+ $newrecord{'resource.'.$partid.'.solved'} = '';
+ $newrecord{'resource.'.$partid.'.award'} = '';
+ $newrecord{'resource.'.$partid.'.awarded'} = 0;
+ $newrecord{'resource.'.$partid.'.regrader'} = "$ENV{'user.name'}:$ENV{'user.domain'}";
+ $changeflag++;
+ $newpts = '';
}
+
my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid};
$displayPts[0].=' Part '.$partid.' = '.
(($oldstatus eq 'excused') ? 'excused' : $oldpts).
' ';
$displayPts[1].=' Part '.$partid.' = '.
- ($oldstatus eq 'correct_by_student' ? $oldpts :
- (($score eq 'excused') ? 'excused' : $newpts)).
+ (($score eq 'excused') ? 'excused' : $newpts).
' ';
$question++;
- if (($oldstatus eq 'correct_by_student') ||
- ($newpts eq $oldpts && $score eq $oldstatus))
- {
- next;
- }
+ next if ($dropMenu eq 'reset status' || ($newpts == $oldpts && $score ne 'excused'));
+
$newrecord{'resource.'.$partid.'.awarded'} = $partial if $partial ne '';
- $newrecord{'resource.'.$partid.'.solved'} = $score;
- $newrecord{'resource.'.$partid.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ $newrecord{'resource.'.$partid.'.solved'} = $score if $score ne '';
+ $newrecord{'resource.'.$partid.'.regrader'} = "$ENV{'user.name'}:$ENV{'user.domain'}"
+ if (scalar(keys(%newrecord)) > 0);
$changeflag++;
}
@@ -2960,6 +3077,7 @@ sub updateGradeByPage {
&Apache::lonnet::cstore(\%newrecord,$symbx,$ENV{'request.course.id'},
$udom,$uname);
}
+
$studentTable.=''.$displayPts[0].' '.
''.$displayPts[1].' '.
'';
@@ -3301,7 +3419,7 @@ SCANTRONFORM
#--- Show a Grading Menu button - Calls the next routine ---
sub show_grading_menu_form {
my ($symb,$url)=@_;
- my $result.='