--- loncom/homework/grades.pm 2006/04/11 20:51:46 1.351
+++ loncom/homework/grades.pm 2006/06/27 20:37:42 1.366
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.351 2006/04/11 20:51:46 albertel Exp $
+# $Id: grades.pm,v 1.366 2006/06/27 20:37:42 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);
}
}
}
@@ -2326,7 +2330,7 @@ sub saveHandGrade {
if (exists($record{'resource.'.$new_part.'.awarded'})) {
$newrecord{'resource.'.$new_part.'.awarded'} = '';
}
- $newrecord{'resource.'.$new_part.'.regrader'}="$env{'user.name'}:$env{'user.domain'}";
+ $newrecord{'resource.'.$new_part.'.regrader'}="$env{'user.name'}:$env{'user.domain'}";
}
} elsif ($dropMenu eq 'reset status'
&& exists($record{'resource.'.$new_part.'.solved'})) { #don't bother if no old records -> no attempts
@@ -2401,7 +2405,8 @@ sub saveHandGrade {
if (%newrecord) {
if (@version_parts) {
- my @changed_keys = &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts);
+ my @changed_keys = &version_portfiles(\%record, \@parts_graded,
+ $env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts);
@newrecord{@changed_keys} = @record{@changed_keys};
}
&Apache::lonnet::cstore(\%newrecord,$symb,
@@ -2427,10 +2432,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)) {
@@ -2442,23 +2445,35 @@ sub handback_files {
($env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter} =~ /^(.*?)([^\/]*)$/);
my ($answer_name,$answer_ver,$answer_ext) =
&file_name_version_ext($answer_file);
- $directory =~ /^.+$stuname\/portfolio(.*)/;
- my $portfolio_path = $1;
+ my ($portfolio_path) = ($directory =~ /^.+$stuname\/portfolio(.*)/);
my @dir_list = &Apache::lonnet::dirlist($portfolio_path,$domain,$stuname,$portfolio_root);
my $version = &get_next_version($answer_name, $answer_ext, \@dir_list);
- my $new_answer = &version_selected_portfile($domain, $stuname, $portfolio_path, $answer_file, $version);
- $$newrecord{"resource.$new_part.$resp_id.handback"} = $new_answer;
- # set the filename to match the submitted file name
- $env{'form.'.$newflg.'_'.$part_resp.'_returndoc1.filename'} = $env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter};
- my $result=&Apache::lonnet::userfileupload($newflg.'_'.$part_resp.'_returndoc'.$file_counter,'',
- 'portfolio',undef,undef,undef,$stuname,$domain);
+ # fix file name
+ my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/);
+ my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain,
+ $newflg.'_'.$part_resp.'_returndoc'.$file_counter,
+ $save_file_name);
if ($result !~ m|^/uploaded/|) {
$request->print(' An errror occured ('.$result.
- ') while trying to upload '.&display_file().'
');
- # $request->print(&done('Back'));
+ ') 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);
+ $$newrecord{"resource.$new_part.$resp_id.handback"} = $save_file_name;
+ 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.";
+ 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);
}
$request->print("
".$fname." will be the uploaded file name");
- $request->print("Will upload document ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});
+ $request->print(" ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});
$file_counter++;
}
}
@@ -2546,9 +2561,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$/ ) {
@@ -4219,7 +4233,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);
@@ -4831,7 +4845,7 @@ $warning
STUFF
}
- $r->print("
".&show_grading_menu_form($symb)."