--- loncom/homework/grades.pm 2006/06/12 18:56:22 1.361
+++ loncom/homework/grades.pm 2006/07/02 01:03:04 1.369
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.361 2006/06/12 18:56:22 albertel Exp $
+# $Id: grades.pm,v 1.369 2006/07/02 01:03:04 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,7 @@ 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;
@@ -1551,15 +1551,18 @@ sub handback_box {
next if (!@$files);
my $file_counter = 1;
foreach my $file (@$files) {
- my ($file_path, $file_disp) = ($file =~ m|(.+/)(.+)$|);
- my ($name,$version,$ext) = &file_name_version_ext($file_disp);
- $file_disp = "$name.$ext";
- $file = $file_path.$file_disp;
- $result.=&mt('Return commented version of [_1] to student.',
- ''.$file_disp.'');
- $result.=''."\n";
- $result.=' ';
- $file_counter++;
+ if ($file =~ /\/portfolio\//) {
+ my ($file_path, $file_disp) = ($file =~ m|(.+/)(.+)$|);
+ my ($name,$version,$ext) = &file_name_version_ext($file_disp);
+ $file_disp = "$name.$ext";
+ $file = $file_path.$file_disp;
+ $result.=&mt('Return commented version of [_1] to student.',
+ ''.$file_disp.'');
+ $result.=''."\n";
+ $result.=' ';
+ $result.='(File will be uploaded when you click on Save & Next below.) ';
+ $file_counter++;
+ }
}
}
return $result;
@@ -2107,6 +2110,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 '');
@@ -2119,8 +2123,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);
}
@@ -2133,11 +2137,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);
}
}
}
@@ -2329,7 +2333,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
@@ -2389,7 +2393,6 @@ sub saveHandGrade {
}
$newrecord{'resource.'.$new_part.'.regrader'}=
"$env{'user.name'}:$env{'user.domain'}";
- &handback_files($request,$symb,$stuname,$domain,$newflg,$new_part,\%newrecord);
}
# unless problem has been graded, set flag to version the submitted files
unless ($record{'resource.'.$new_part.'.solved'} =~ /^correct_/ ||
@@ -2404,8 +2407,13 @@ 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};
+ foreach my $new_part (@version_parts) {
+ &handback_files($request,$symb,$stuname,$domain,$newflg,
+ $new_part,\%newrecord);
+ }
}
&Apache::lonnet::cstore(\%newrecord,$symb,
$env{'request.course.id'},$domain,$stuname);
@@ -2437,6 +2445,7 @@ sub handback_files {
if (($env{'form.'.$newflg.'_'.$part_resp.'_returndoc1'}) && ($new_part == $part_id)) {
# if multiple files are uploaded names will be 'returndoc2','returndoc3'
my $file_counter = 1;
+ my $file_msg;
while ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter}) {
my $fname=$env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'.filename'};
my ($directory,$answer_file) =
@@ -2446,9 +2455,6 @@ sub handback_files {
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;
- $version++;
# fix file name
my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/);
my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain,
@@ -2462,19 +2468,27 @@ sub handback_files {
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 $msgstatus = &Apache::lonmsg::user_normal_msg($stuname,$domain,
- $subject.' [File Returned]',$message);
+ if (exists($$newrecord{"resource.$new_part.$resp_id.handback"})) {
+ $$newrecord{"resource.$new_part.$resp_id.handback"}.=',';
+ }
+ $$newrecord{"resource.$new_part.$resp_id.handback"} .= $save_file_name;
+ $file_msg.= "\n".' '.$save_file_name." ";
+
}
$request->print(" ".$fname." will be the uploaded file name");
$request->print(" ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});
$file_counter++;
}
+ 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(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);
+
}
}
return;
@@ -2566,7 +2580,7 @@ sub version_portfiles {
my $new_portfiles;
if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
my @versioned_portfiles;
- my @portfiles = split(/,/,$$record{$key});
+ my @portfiles = split(/\s*,\s*/,$$record{$key});
foreach my $file (@portfiles) {
&Apache::lonnet::unmark_as_readonly($domain,$stu_name,[$symb,$env{'request.course.id'}],$file);
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/);
@@ -2578,7 +2592,7 @@ sub version_portfiles {
if ($new_answer ne 'problem getting file') {
push(@versioned_portfiles, $directory.$new_answer);
&Apache::lonnet::mark_as_readonly($domain,$stu_name,
- ['/portfolio'.$directory.$new_answer],
+ [$directory.$new_answer],
[$symb,$env{'request.course.id'},'graded']);
}
}