--- loncom/homework/grades.pm 2006/11/03 20:04:08 1.383 +++ loncom/homework/grades.pm 2007/01/04 21:24:39 1.388 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.383 2006/11/03 20:04:08 albertel Exp $ +# $Id: grades.pm,v 1.388 2007/01/04 21:24:39 raeburn 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; @@ -1513,10 +1514,10 @@ sub gradeBox { $result.=''."\n"; @@ -1758,7 +1759,7 @@ KEYWORDS # Load the other essays for similarity check # my (undef,undef,$essayurl) = &Apache::lonnet::decode_symb($symb); - my ($adom,$aname,$apath)=($essayurl=~/^(\w+)\/(\w+)\/(.*)$/); + my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/); $apath=&escape($apath); $apath=~s/\W/\_/gs; %oldessays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname); @@ -2116,10 +2117,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 ''); @@ -2127,14 +2140,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}) { @@ -2150,7 +2165,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); } } } @@ -2506,10 +2537,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; @@ -3930,7 +3973,7 @@ sub displayPage { if($curRes == $iterator->BEGIN_MAP) { $depth++; } if($curRes == $iterator->END_MAP) { $depth--; } - if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) { + if (ref($curRes) && $curRes->is_problem()) { my $parts = $curRes->parts(); my $title = $curRes->compTitle(); my $symbx = $curRes->symb(); @@ -4155,7 +4198,7 @@ sub updateGradeByPage { if($curRes == $iterator->BEGIN_MAP) { $depth++; } if($curRes == $iterator->END_MAP) { $depth--; } - if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) { + if (ref($curRes) && $curRes->is_problem()) { my $parts = $curRes->parts(); my $title = $curRes->compTitle(); my $symbx = $curRes->symb();