[LON-CAPA-cvs] cvs: loncom /homework grades.pm /interface loncommon.pm
raeburn
raeburn at source.lon-capa.org
Sat Nov 8 13:26:07 EST 2014
raeburn Sat Nov 8 18:26:07 2014 EDT
Modified files:
/loncom/homework grades.pm
/loncom/interface loncommon.pm
Log:
- Bug 6740.
-------------- next part --------------
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.725 loncom/homework/grades.pm:1.726
--- loncom/homework/grades.pm:1.725 Mon Aug 25 22:12:58 2014
+++ loncom/homework/grades.pm Sat Nov 8 18:26:01 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.725 2014/08/25 22:12:58 raeburn Exp $
+# $Id: grades.pm,v 1.726 2014/11/08 18:26:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1295,10 +1295,8 @@
}
}
}
-
}
}
-
}
formname.submit();
}
@@ -2321,10 +2319,12 @@
}
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('<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'
.$udom.'" />'."\n");
@@ -2774,7 +2774,8 @@
my $ctr = 0;
while ($ctr < $ngrade) {
my ($uname,$udom) = split(/:/,$env{'form.unamedom'.$ctr});
- my ($errorflag,$pts,$wgt) = &saveHandGrade($request,$symb,$uname,$udom,$ctr);
+ my ($errorflag,$pts,$wgt,$numhidden) =
+ &saveHandGrade($request,$symb,$uname,$udom,$ctr);
if ($errorflag eq 'no_score') {
$ctr++;
next;
@@ -2787,6 +2788,12 @@
$ctr++;
next;
}
+ if ($numhidden) {
+ $request->print(
+ '<span class="LC_info">'
+ .&mt('For [_1]: [quant,_2,transaction] hidden',"$uname:$udom",$numhidden)
+ .'</span><br />');
+ }
my $includemsg = $env{'form.includemsg'.$ctr};
my ($subject,$message,$msgstatus) = ('','','');
my $restitle = &Apache::lonnet::gettitle($symb);
@@ -3008,9 +3015,13 @@
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 $numchgs = &makehidden($newflg,\%record,$symb,$domain,$stuname);
+ $totchg += $numchgs;
+ }
my @parts = split(/:/,$env{'form.partlist'.$newflg});
foreach my $new_part (@parts) {
#collaborator ($submi may vary for different parts
@@ -3113,7 +3124,38 @@
&Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,
$cdom,$cnum);
}
- return ('',$pts,$wgt);
+ return ('',$pts,$wgt,$totchg);
+}
+
+sub makehidden {
+ my ($newflg,$record,$symb,$domain,$stuname) = @_;
+ return unless (ref($record) eq 'HASH');
+ my %modified;
+ my $numchanged = 0;
+ my ($version,$parts) = split(/:/,$env{'form.HIDE'.$newflg},2);
+ 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) eq 'ok') {
+ $numchanged ++;
+ }
+ }
+ }
+ return $numchanged;
}
sub check_and_remove_from_queue {
@@ -4781,9 +4823,11 @@
}
} 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)) {
@@ -4996,7 +5040,7 @@
$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--; }
@@ -5017,6 +5061,11 @@
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 $numchgs = &makehidden($prob,\%record,$symbx,$udom,$uname);
+ $hideflag += $numchgs;
+ }
foreach my $partid (@{$parts}) {
my $newpts = $env{'form.GD_BOX'.$question.'_'.$partid};
my $oldpts = $env{'form.oldpts'.$question.'_'.$partid};
@@ -5107,8 +5156,11 @@
$studentTable.=&Apache::loncommon::end_data_table();
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).'<br />');
+ my $hidemsg=($hideflag == 0 ? '' :
+ &mt('Submissions were marked "hidden" for [quant,_1,transaction].',
+ $hideflag).'<br />');
+ $request->print($hidemsg.$grademsg.$studentTable);
return '';
}
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1198 loncom/interface/loncommon.pm:1.1199
--- loncom/interface/loncommon.pm:1.1198 Thu Jul 31 15:57:28 2014
+++ loncom/interface/loncommon.pm Sat Nov 8 18:26:06 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1198 2014/07/31 15:57:28 musolffc Exp $
+# $Id: loncommon.pm,v 1.1199 2014/11/08 18:26:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3761,7 +3761,7 @@
=over 4
=item * &get_previous_attempt($symb, $username, $domain, $course,
- $getattempt, $regexp, $gradesub)
+ $getattempt, $regexp, $gradesub, $usec, $identifier)
Return string with previous attempt on problem. Arguments:
@@ -3783,6 +3783,11 @@
=item * $gradesub: routine that processes the string if it matches $regexp
+=item * $usec: section of the desired student
+
+=item * $identifier: counter for student (multiple students one problem) or
+ problem (one student; whole sequence).
+
=back
The output string is a table containing all desired attempts, if any.
@@ -3790,7 +3795,7 @@
=cut
sub get_previous_attempt {
- my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub)=@_;
+ my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub,$usec,$identifier)=@_;
my $prevattempts='';
no strict 'refs';
if ($symb) {
@@ -3806,7 +3811,7 @@
}
$prevattempts=&start_data_table().&start_data_table_header_row();
$prevattempts.='<th>'.&mt('History').'</th>';
- my (%typeparts,%lasthidden);
+ my (%typeparts,%lasthidden,%regraded,%hidestatus);
my $showsurv=&Apache::lonnet::allowed('vas',$env{'request.course.id'});
foreach my $key (sort(keys(%lasthash))) {
my ($ign, at parts) = split(/\./,$key);
@@ -3823,6 +3828,17 @@
$lasthidden{$ign.'.'.$id} = 1;
}
}
+ if ($identifier ne '') {
+ my $id = join(',', at parts);
+ if (&Apache::lonnet::EXT("resource.$id.problemstatus",$symb,
+ $domain,$username,$usec,undef,$course) =~ /^no/) {
+ $hidestatus{$ign.'.'.$id} = 1;
+ }
+ }
+ } elsif ($data eq 'regrader') {
+ if (($identifier ne '') && (@parts)) {
+ $regraded{$parts[-1]} = 1;
+ }
}
} else {
if ($#parts == 0) {
@@ -3834,17 +3850,58 @@
}
$prevattempts.=&end_data_table_header_row();
if ($getattempt eq '') {
+ my (%solved,%resets,%probstatus);
for ($version=1;$version<=$returnhash{'version'};$version++) {
- my @hidden;
+ if ($identifier ne '') {
+ foreach my $part (keys(%regraded)) {
+ if (($returnhash{$version.':resource.'.$part.'.regrader'}) &&
+ ($returnhash{$version.':resource.'.$part.'.tries'} eq '') &&
+ ($returnhash{$version.':resource.'.$part.'.award'} eq '')) {
+ push(@{$resets{$part}},$version);
+ }
+ }
+ }
+ my (@hidden, at unsolved);
if (%typeparts) {
foreach my $id (keys(%typeparts)) {
- if (($returnhash{$version.':'.$id.'.type'} eq 'anonsurvey') || ($returnhash{$version.':'.$id.'.type'} eq 'anonsurveycred')) {
+ if (($returnhash{$version.':'.$id.'.type'} eq 'anonsurvey') ||
+ ($returnhash{$version.':'.$id.'.type'} eq 'anonsurveycred')) {
push(@hidden,$id);
+ } elsif ($identifier ne '') {
+ unless (($returnhash{$version.':'.$id.'.type'} eq 'survey') ||
+ ($returnhash{$version.':'.$id.'.type'} eq 'surveycred') ||
+ ($hidestatus{$id})) {
+ next if ((ref($resets{$id}) eq 'ARRAY') && grep(/^\Q$id\E$/,@{$resets{$id}}));
+ if ($returnhash{$version.':'.$id.'.solved'} eq 'correct_by_student') {
+ push(@{$solved{$id}},$version);
+ } elsif (($returnhash{$version.':'.$id.'.solved'} ne '') &&
+ (ref($solved{$id}) eq 'ARRAY')) {
+ my $skip;
+ if (ref($resets{$id}) eq 'ARRAY') {
+ foreach my $reset (@{$resets{$id}}) {
+ if ($reset > $solved{$id}[-1]) {
+ $skip=1;
+ last;
+ }
+ }
+ }
+ unless ($skip) {
+ my ($ign,$partslist) = split(/\./,$id,2);
+ push(@unsolved,$partslist);
+ }
+ }
+ }
}
}
}
$prevattempts.=&start_data_table_row().
- '<td>'.&mt('Transaction [_1]',$version).'</td>';
+ '<td>'.&mt('Transaction [_1]',$version);
+ if (@unsolved) {
+ $prevattempts .= '<span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="HIDE'.$identifier.'" value="'.$version.':'.join('_', at unsolved).'" />'.
+ &mt('Hide').'</label></span>';
+ }
+ $prevattempts .= '</td>';
if (@hidden) {
foreach my $key (sort(keys(%lasthash))) {
next if ($key =~ /\.foilorder$/);
More information about the LON-CAPA-cvs
mailing list