--- loncom/homework/grades.pm 2003/07/17 22:08:25 1.118
+++ loncom/homework/grades.pm 2003/07/18 20:14:35 1.119
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.118 2003/07/17 22:08:25 ng Exp $
+# $Id: grades.pm,v 1.119 2003/07/18 20:14:35 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -140,7 +140,6 @@ sub showResourceInfo {
#--- Currently filters option response type only.
sub cleanRecord {
my ($answer,$response) = @_;
- $answer =~ s|^ ||;
if ($response eq 'option') {
my (@IDs,@ans);
foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
@@ -471,8 +470,7 @@ LISTJAVASCRIPT
$request->print($result);
my $checkhdgrade = ($ENV{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked' : '';
- my $checklastsub = ($ENV{'form.handgrade'} eq 'no') ? 'checked' : '';
- $checklastsub = 'checked' if ($checkhdgrade eq '' && $checklastsub eq '');
+ my $checklastsub = $checkhdgrade eq '' ? 'checked' : '';
my $gradeTable='
';
$endform.=&show_grading_menu_form($symb,$url);
$request->print($endform);
@@ -1525,15 +1509,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)) {
@@ -1557,13 +1541,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;
}
@@ -1609,7 +1588,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;
@@ -1626,48 +1606,50 @@ 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'},'0');
+ my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
if ($ENV{'form.refresh'} eq 'on') {
my ($ctr,$total) = (0,0);
while ($ctr < $ngrade) {
@@ -1689,7 +1671,7 @@ sub processHandGrade {
# 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++;
@@ -1773,6 +1755,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';
@@ -2047,8 +2030,6 @@ sub viewgrades {
'';
$result.='';
-# $result.=' '."\n";
#table listing all the students in a section/class
#header of table
@@ -2824,45 +2805,11 @@ sub displayPage {
if ($record{'version'} eq '') {
$studentTable.=' No recorded submission for this problem ';
} else {
- $studentTable.='
'.
- '
'.
- '
Date/Time
'.
- '
Submission
'.
- '
Status
';
my %responseType = ();
foreach my $partid (@{$parts}) {
$responseType{$partid} = $curRes->responseType($partid);
}
- my ($version);
- my %mark;
- $mark{'correct_by_student'} = $checkIcon;
- for ($version=1;$version<=$record{'version'};$version++) {
- my $timestamp = scalar(localtime($record{$version.':timestamp'}));
- $studentTable.='