--- loncom/homework/grades.pm 2014/08/25 22:17:54 1.596.2.12.2.30
+++ loncom/homework/grades.pm 2015/01/23 23:34:17 1.596.2.12.2.31
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.596.2.12.2.30 2014/08/25 22:17:54 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.31 2015/01/23 23:34:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1372,10 +1372,8 @@ sub sub_page_js {
}
}
}
-
}
}
-
}
if (val == "Grade Student") {
formname.showgrading.value = "yes";
@@ -2401,10 +2399,12 @@ sub submission {
$request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom));
}
if ($env{'form.lastSub'} =~ /^(last|all)$/) {
+ my $identifier = (&canmodify($usec)? $counter : '');
$request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
$env{'request.course.id'},
$last,'.submission',
- 'Apache::grades::keywords_highlight'));
+ 'Apache::grades::keywords_highlight',
+ $usec,$identifier));
}
$request->print(''
+ .&mt('For [_1]: [quant,_2,transaction] hidden',"$uname:$udom",$numhidden)
+ .'
');
+ }
my $includemsg = $env{'form.includemsg'.$ctr};
my ($subject,$message,$msgstatus) = ('','','');
my $restitle = &Apache::lonnet::gettitle($symb);
@@ -3107,9 +3114,14 @@ sub saveHandGrade {
my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$domain,$stuname);
my @parts_graded;
my %newrecord = ();
- my ($pts,$wgt) = ('','');
+ my ($pts,$wgt,$totchg) = ('','',0);
my %aggregate = ();
my $aggregateflag = 0;
+ if ($env{'form.HIDE'.$newflg}) {
+ my ($version,$parts) = split(/:/,$env{'form.HIDE'.$newflg},2);
+ my $numchgs = &makehidden($version,$parts,\%record,$symb,$domain,$stuname,1);
+ $totchg += $numchgs;
+ }
my @parts = split(/:/,$env{'form.partlist'.$newflg});
foreach my $new_part (@parts) {
#collaborator ($submi may vary for different parts
@@ -3212,7 +3224,37 @@ sub saveHandGrade {
&Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,
$cdom,$cnum);
}
- return ('',$pts,$wgt);
+ return ('',$pts,$wgt,$totchg);
+}
+
+sub makehidden {
+ my ($version,$parts,$record,$symb,$domain,$stuname,$tolog) = @_;
+ return unless (ref($record) eq 'HASH');
+ my %modified;
+ my $numchanged = 0;
+ if (exists($record->{$version.':keys'})) {
+ my $partsregexp = $parts;
+ $partsregexp =~ s/,/|/g;
+ foreach my $key (split(/\:/,$record->{$version.':keys'})) {
+ if ($key =~ /^resource\.(?:$partsregexp)\.([^\.]+)$/) {
+ my $item = $1;
+ unless (($item eq 'solved') || ($item =~ /^award(|msg|ed)$/)) {
+ $modified{$key} = $record->{$version.':'.$key};
+ }
+ } elsif ($key =~ m{^(resource\.(?:$partsregexp)\.[^\.]+\.)(.+)$}) {
+ $modified{$1.'hidden'.$2} = $record->{$version.':'.$key};
+ } elsif ($key =~ /^(ip|timestamp|host)$/) {
+ $modified{$key} = $record->{$version.':'.$key};
+ }
+ }
+ if (keys(%modified)) {
+ if (&Apache::lonnet::putstore($env{'request.course.id'},$symb,$version,\%modified,
+ $domain,$stuname,$tolog) eq 'ok') {
+ $numchanged ++;
+ }
+ }
+ }
+ return $numchanged;
}
sub check_and_remove_from_queue {
@@ -4914,9 +4956,11 @@ sub displayPage {
}
} elsif ($env{'form.lastSub'} eq 'all') {
my $last = ($env{'form.lastSub'} eq 'last' ? 'last' : '');
+ my $identifier = (&canmodify($usec)? $prob : '');
$studentTable.=&Apache::loncommon::get_previous_attempt($symbx,$uname,$udom,
$env{'request.course.id'},
- '','.submission');
+ '','.submission',undef,
+ $usec,$identifier);
}
if (&canmodify($usec)) {
@@ -5132,7 +5176,7 @@ sub updateGradeByPage {
$iterator->next(); # skip the first BEGIN_MAP
my $curRes = $iterator->next(); # for "current resource"
- my ($depth,$question,$prob,$changeflag)= (1,1,1,0);
+ my ($depth,$question,$prob,$changeflag,$hideflag)= (1,1,1,0,0);
while ($depth > 0) {
if($curRes == $iterator->BEGIN_MAP) { $depth++; }
if($curRes == $iterator->END_MAP) { $depth--; }
@@ -5153,6 +5197,12 @@ sub updateGradeByPage {
my @displayPts=();
my %aggregate = ();
my $aggregateflag = 0;
+ if ($env{'form.HIDE'.$prob}) {
+ my %record = &Apache::lonnet::restore($symbx,$env{'request.course.id'},$udom,$uname);
+ my ($version,$parts) = split(/:/,$env{'form.HIDE'.$prob},2);
+ my $numchgs = &makehidden($version,$parts,\%record,$symbx,$udom,$uname,1);
+ $hideflag += $numchgs;
+ }
foreach my $partid (@{$parts}) {
my $newpts = $env{'form.GD_BOX'.$question.'_'.$partid};
my $oldpts = $env{'form.oldpts'.$question.'_'.$partid};
@@ -5244,8 +5294,11 @@ sub updateGradeByPage {
$studentTable.=&show_grading_menu_form($env{'form.symb'});
my $grademsg=($changeflag == 0 ? &mt('No score was changed or updated.') :
&mt('The scores were changed for [quant,_1,problem].',
- $changeflag));
- $request->print($grademsg.$studentTable);
+ $changeflag).'
');
+ my $hidemsg=($hideflag == 0 ? '' :
+ &mt('Submissions were marked "hidden" for [quant,_1,transaction].',
+ $hideflag).'
');
+ $request->print($hidemsg.$grademsg.$studentTable);
return '';
}