--- loncom/homework/grades.pm 2006/10/13 21:49:28 1.378 +++ loncom/homework/grades.pm 2007/04/26 22:29:50 1.397 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.378 2006/10/13 21:49:28 albertel Exp $ +# $Id: grades.pm,v 1.397 2007/04/26 22:29:50 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,6 +39,7 @@ use Apache::loncoursedata; use Apache::lonmsg(); use Apache::Constants qw(:common); use Apache::lonlocal; +use Apache::lonenc; use String::Similarity; use lib '/home/httpd/lib/perl'; use LONCAPA; @@ -116,8 +117,12 @@ sub response_type { my $navmap = Apache::lonnavmaps::navmap->new(); my $res = $navmap->getBySymb($symb); my $partlist = $res->parts(); + my %vPart = + map { $_ => 1 } (&Apache::loncommon::get_env_multiple('form.vPart')); my (%response_types,%handgrade); foreach my $part (@{ $partlist }) { + next if (%vPart && !exists($vPart{$part})); + my @types = $res->responseType($part); my @ids = $res->responseIds($part); for (my $i=0; $i < scalar(@ids); $i++) { @@ -598,7 +603,8 @@ sub verifyreceipt { my (undef,undef,$fullname) = &getclasslist('all','0'); my $receiptparts=0; - if ($env{"course.$courseid.receiptalg"} eq 'receipt2') { $receiptparts=1; } + if ($env{"course.$courseid.receiptalg"} eq 'receipt2' || + $env{"course.$courseid.receiptalg"} eq 'receipt3') { $receiptparts=1; } my $parts=['0']; if ($receiptparts) { ($parts)=&response_type($symb); } foreach (sort @@ -947,8 +953,8 @@ sub processGroup { my @stuchecked = &Apache::loncommon::get_env_multiple('form.stuinfo'); my $total = scalar(@stuchecked)-1; - foreach (@stuchecked) { - my ($uname,$udom,$fullname) = split(/:/); + foreach my $student (@stuchecked) { + my ($uname,$udom,$fullname) = split(/:/,$student); $env{'form.student'} = $uname; $env{'form.userdom'} = $udom; $env{'form.fullname'} = $fullname; @@ -1469,7 +1475,8 @@ sub get_increment { #--- displays the grading box, used in essay type problem and grading by page/sequence sub gradeBox { my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_; - my $checkIcon = ''; my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname); my $wgtmsg = ($wgt > 0 ? '(problem weight)' : @@ -1492,10 +1499,10 @@ sub gradeBox { my $increment = &get_increment(); $result.='
Part: '.
- $display_part.' ( ID '.$respid.
+ $lastsubonly.='Debug -'.'Part: '.
+ $display_part.' ( hhhh ID '.$respid.
' ) ';
my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
if (@$files) {
@@ -2000,7 +2054,8 @@ KEYWORDS
my $part_resp = join('_',@{ $part_response_id });
next if ($seen{$partid} > 0);
$seen{$partid}++;
- next if ($$handgrade{$part_resp} =~ /:no$/ && $env{'form.lastSub'} =~ /^(hdgrade)$/);
+ next if ($$handgrade{$part_resp} ne 'yes'
+ && $env{'form.lastSub'} eq 'hdgrade');
push @partlist,$partid;
push @gradePartRespid,$partid.'.'.$respid;
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
@@ -2052,22 +2107,27 @@ sub get_last_submission {
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'}));
+ foreach my $key (sort(split(/\:/,
+ $$returnhash{$version.':keys'}))) {
+ $lasthash{$key}=$$returnhash{$version.':'.$key};
+ $timestamp =
+ scalar(localtime($$returnhash{$version.':timestamp'}));
}
}
- foreach ((keys %lasthash)) {
- if ($_ =~ /\.submission$/) {
- my ($partid,$foo) = split(/submission$/,$_);
- my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
- 'Draft Copy ' : '';
- push @string, (join(':',$_,$draft.$lasthash{$_}));
- }
+ foreach my $key (keys(%lasthash)) {
+ next if ($key !~ /\.submission$/);
+
+ my ($partid,$foo) = split(/submission$/,$key);
+ my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
+ 'Draft Copy ' : '';
+ push(@string, join(':', $key, $draft.$lasthash{$key}));
}
}
- @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
- return \@string,\$timestamp;
+ if (!@string) {
+ $string[0] =
+ 'Nothing submitted - no attempts.';
+ }
+ return (\@string,\$timestamp);
}
#--- High light keywords, with style choosen by user.
@@ -2110,10 +2170,22 @@ sub processHandGrade {
}
my $includemsg = $env{'form.includemsg'.$ctr};
my ($subject,$message,$msgstatus) = ('','','');
+ my $restitle = &Apache::lonnet::gettitle($symb);
+ my $encrypturl=&Apache::lonnet::EXT('resource.0.encrypturl',
+ $symb,$udom,$uname);
+ my ($feedurl,$baseurl,$showsymb,$messagetail);
+ $feedurl = &Apache::lonnet::clutter($url);
+ if ($encrypturl =~ /^yes$/i) {
+ $baseurl = &Apache::lonenc::encrypted($feedurl,1);
+ $showsymb = &Apache::lonenc::encrypted($symb,1);
+ } else {
+ $baseurl = $feedurl;
+ $showsymb = $symb;
+ }
if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) {
$subject = $env{'form.msgsub'} if ($includemsg =~ /msgsub/);
unless ($subject=~/\w/) { $subject=&mt('Grading Feedback'); }
- $subject.=' ['.&Apache::lonnet::declutter($url).']';
+ $subject.=' ['.$restitle.']';
my (@msgnum) = split(/,/,$includemsg);
foreach (@msgnum) {
$message.=$env{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
@@ -2121,14 +2193,16 @@ sub processHandGrade {
$message =&Apache::lonfeedback::clear_out_html($message);
if ($env{'form.withgrades'.$ctr}) {
$message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt;
- $message.=" for $env{'form.probTitle'}";
- }
- $msgstatus = &Apache::lonmsg::user_normal_msg($uname,$udom,
- $subject,
- $message);
- $request->print(' | '.&mt('Sending message to [_1]@[_2]',$uname,$udom).': '. + $messagetail = " for $env{'form.probTitle'}"; + } + $msgstatus = + &Apache::lonmsg::user_normal_msg($uname,$udom,$subject, + $message.$messagetail, + undef,$baseurl,undef, + undef,undef,$showsymb, + $restitle); + $request->print(' '.&mt('Sending message to [_1]:[_2]',$uname,$udom).': '. $msgstatus); } if ($env{'form.collaborator'.$ctr}) { @@ -2144,7 +2218,23 @@ sub processHandGrade { next; } else { if ($message ne '') { - $msgstatus = &Apache::lonmsg::user_normal_msg($collaborator,$udom,$subject,$message); + $encrypturl= + &Apache::lonnet::EXT('resource.0.encrypturl', + $symb,$udom,$collaborator); + if ($encrypturl =~ /^yes$/i) { + $baseurl = &Apache::lonenc::encrypted($feedurl,1); + $showsymb = &Apache::lonenc::encrypted($symb,1); + } else { + $baseurl = $feedurl; + $showsymb = $symb; + } + if ($env{'form.withgrades'.$ctr}) { + $messagetail = " for $env{'form.probTitle'}"; + + } + $msgstatus = + &Apache::lonmsg::user_normal_msg($collaborator,$udom,$subject,$message.$messagetail,undef,$baseurl,undef,undef,undef,$showsymb,$restitle); } } } @@ -2420,17 +2510,8 @@ sub saveHandGrade { } &Apache::lonnet::cstore(\%newrecord,$symb, $env{'request.course.id'},$domain,$stuname); - my @ungraded_parts; - foreach my $part (@parts) { - if ( !defined($record{'resource.'.$part.'.awarded'}) - && !defined($newrecord{'resource.'.$part.'.awarded'}) ) { - push(@ungraded_parts, $part); - } - } - if ( !@ungraded_parts ) { - &Apache::bridgetask::remove_from_queue('gradingqueue',$symb,$cdom, - $cnum,$domain,$stuname); - } + &check_and_remove_from_queue(\@parts,\%record,\%newrecord,$symb, + $cdom,$cnum,$domain,$stuname); } if ($aggregateflag) { &Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate, @@ -2439,6 +2520,24 @@ sub saveHandGrade { return ('',$pts,$wgt); } +sub check_and_remove_from_queue { + my ($parts,$record,$newrecord,$symb,$cdom,$cnum,$domain,$stuname) = @_; + my @ungraded_parts; + foreach my $part (@{$parts}) { + if ( $record->{ 'resource.'.$part.'.awarded'} eq '' + && $record->{ 'resource.'.$part.'.solved' } ne 'excused' + && $newrecord->{'resource.'.$part.'.awarded'} eq '' + && $newrecord->{'resource.'.$part.'.solved' } ne 'excused' + ) { + push(@ungraded_parts, $part); + } + } + if ( !@ungraded_parts ) { + &Apache::bridgetask::remove_from_queue('gradingqueue',$symb,$cdom, + $cnum,$domain,$stuname); + } +} + sub handback_files { my ($request,$symb,$stuname,$domain,$newflg,$new_part,$newrecord) = @_; my $portfolio_root = &propath($domain,$stuname).'/userfiles/portfolio'; @@ -2491,10 +2590,22 @@ sub handback_files { $message .= ' The returned file(s) are named: '. $file_msg; $message .= " and can be found in your portfolio space."; my $url = (&Apache::lonnet::decode_symb($symb))[2]; - $url = &Apache::lonnet::declutter($url); - my $msgstatus = &Apache::lonmsg::user_normal_msg($stuname,$domain, - $subject.' (File Returned) ['.$url.']',$message); - + my $feedurl = &Apache::lonnet::clutter($url); + my $encrypturl=&Apache::lonnet::EXT('resource.0.encrypturl', + $symb,$domain,$stuname); + my ($baseurl,$showsymb); + if ($encrypturl =~ /^yes$/i) { + $baseurl = &Apache::lonenc::encrypted($feedurl,1); + $showsymb = &Apache::lonenc::encrypted($symb,1); + } else { + $baseurl = $feedurl; + $showsymb = $symb; + } + my $restitle = &Apache::lonnet::gettitle($symb); + my $msgstatus = + &Apache::lonmsg::user_normal_msg($stuname,$domain,$subject. + ' (File Returned) ['.$restitle.']',$message,undef, + $baseurl,undef,undef,undef,$showsymb,$restitle); } } return; @@ -2926,7 +3037,7 @@ sub viewgrades { } $result.=' |