--- loncom/homework/grades.pm 2006/05/30 00:15:04 1.358
+++ loncom/homework/grades.pm 2006/06/12 22:14:29 1.363
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.358 2006/05/30 00:15:04 banghart Exp $
+# $Id: grades.pm,v 1.363 2006/06/12 22:14:29 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,10 +36,13 @@ use Apache::lonhtmlcommon;
use Apache::lonnavmaps;
use Apache::lonhomework;
use Apache::loncoursedata;
-use Apache::lonmsg qw(:user_normal_msg);
+use Apache::lonmsg();
use Apache::Constants qw(:common);
use Apache::lonlocal;
use String::Similarity;
+use lib '/home/httpd/lib/perl';
+use LONCAPA;
+
use POSIX qw(floor);
my %oldessays=();
@@ -1553,7 +1556,7 @@ sub handback_box {
$file_disp = "$name.$ext";
$file = $file_path.$file_disp;
$result.=&mt('Return commented version of [_1] to student.',
- ''.$file_disp.'');
+ ''.$file_disp.'');
$result.=''."\n";
$result.='
';
$file_counter++;
@@ -1747,7 +1750,7 @@ KEYWORDS
#
my (undef,undef,$essayurl) = &Apache::lonnet::decode_symb($symb);
my ($adom,$aname,$apath)=($essayurl=~/^(\w+)\/(\w+)\/(.*)$/);
- $apath=&Apache::lonnet::escape($apath);
+ $apath=&escape($apath);
$apath=~s/\W/\_/gs;
%oldessays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
}
@@ -2104,6 +2107,7 @@ sub processHandGrade {
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).']';
my (@msgnum) = split(/,/,$includemsg);
foreach (@msgnum) {
$message.=$env{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
@@ -2116,8 +2120,8 @@ sub processHandGrade {
"?symb=$symb\">$env{'form.probTitle'}";
}
$msgstatus = &Apache::lonmsg::user_normal_msg($uname,$udom,
- $subject.' ['.
- &Apache::lonnet::declutter($url).']',$message);
+ $subject,
+ $message);
$request->print('
'.&mt('Sending message to [_1]@[_2]',$uname,$udom).': '.
$msgstatus);
}
@@ -2130,11 +2134,11 @@ sub processHandGrade {
&saveHandGrade($request,$symb,$collaborator,$udom,$ctr,
$env{'form.unamedom'.$ctr},$part);
if ($errorflag eq 'not_allowed') {
- $request->print("Not allowed to modify grades for $collaborator:$udom");
+ $request->print("".&mt('Not allowed to modify grades for [_1]',"$collaborator:$udom")."");
next;
} else {
if ($message ne '') {
- $msgstatus = &Apache::lonmsg::user_normal_msg($collaborator,$udom,$env{'form.msgsub'},$message);
+ $msgstatus = &Apache::lonmsg::user_normal_msg($collaborator,$udom,$subject,$message);
}
}
}
@@ -2427,10 +2431,8 @@ sub saveHandGrade {
sub handback_files {
my ($request,$symb,$stuname,$domain,$newflg,$new_part,$newrecord) = @_;
- my $portfolio_root = &Apache::loncommon::propath($domain,
- $stuname).
- '/userfiles/portfolio';
- my ($partlist,$handgrade,$responseType) = &response_type($symb);
+ my $portfolio_root = &propath($domain,$stuname).'/userfiles/portfolio';
+ my ($partlist,$handgrade,$responseType) = &response_type($symb);
foreach my $part_resp (sort(keys(%$handgrade))) {
my ($part_id, $resp_id) = split(/_/,$part_resp);
if (($env{'form.'.$newflg.'_'.$part_resp.'_returndoc1'}) && ($new_part == $part_id)) {
@@ -2457,14 +2459,20 @@ sub handback_files {
$request->print(' An errror occured ('.$result.
') while trying to upload '.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'
');
} else {
+ # mark the file as read only
+ my @files = ($save_file_name);
+ my @what = ($symb,'handback');
+ &Apache::lonnet::mark_as_readonly($domain,$stuname,\@files,\@what);
my $subject = "File Handed Back by Instructor ";
my $message = "A file has been returned that was originally submitted in reponse to:
";
$message .= "".&Apache::lonnet::gettitle($symb)."
";
$message .= " The returned file is named:
".$save_file_name."
";
$message .= " and can be found in your portfolio space.";
&Apache::lonnet::logthis($message);
+ 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]',$message);
+ $subject.' (File Returned) ['.$url.']',$message);
}
$request->print("
".$fname." will be the uploaded file name");
$request->print(" ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});
@@ -2555,9 +2563,8 @@ sub version_portfiles {
my $version_parts = join('|',@$v_flag);
my @returned_keys;
my $parts = join('|', @$parts_graded);
- my $portfolio_root = &Apache::loncommon::propath($domain,
- $stu_name).
- '/userfiles/portfolio';
+ my $portfolio_root = &propath($domain,$stu_name).
+ '/userfiles/portfolio';
foreach my $key (keys(%$record)) {
my $new_portfiles;
if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
@@ -4228,7 +4235,7 @@ sub scantron_filenames {
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname,
- &Apache::loncommon::propath($cdom,$cname));
+ &propath($cdom,$cname));
my @possiblenames;
foreach my $filename (sort(@files)) {
($filename)=split(/&/,$filename);
@@ -5256,11 +5263,11 @@ function change_radio(field) {
ENDSCRIPT
my $href="/adm/pickcode?".
- "form=".&Apache::lonnet::escape("scantronupload").
- "&scantron_format=".&Apache::lonnet::escape($env{'form.scantron_format'}).
- "&scantron_CODElist=".&Apache::lonnet::escape($env{'form.scantron_CODElist'}).
- "&curCODE=".&Apache::lonnet::escape($$scan_record{'scantron.CODE'}).
- "&scantron_selectfile=".&Apache::lonnet::escape($env{'form.scantron_selectfile'});
+ "form=".&escape("scantronupload").
+ "&scantron_format=".&escape($env{'form.scantron_format'}).
+ "&scantron_CODElist=".&escape($env{'form.scantron_CODElist'}).
+ "&curCODE=".&escape($$scan_record{'scantron.CODE'}).
+ "&scantron_selectfile=".&escape($env{'form.scantron_selectfile'});
if ($env{'form.scantron_CODElist'} =~ /\S/) {
$r->print(" Selected CODE is ");
$r->print("\n
");