--- loncom/homework/grades.pm 2006/05/17 22:08:17 1.353
+++ loncom/homework/grades.pm 2006/06/12 00:34:45 1.360
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.353 2006/05/17 22:08:17 albertel Exp $
+# $Id: grades.pm,v 1.360 2006/06/12 00:34:45 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,6 +40,9 @@ use Apache::lonmsg qw(:user_normal_msg);
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=();
@@ -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);
}
@@ -2427,10 +2430,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 +2443,36 @@ 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);
+ $version++;
+ # 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);
+ 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);
}
$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 +2560,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 +4232,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);
@@ -5093,7 +5106,7 @@ sub scantron_validate_sequence {
my @resources=
$navmap->retrieveResources($map,\&scantron_filter_not_exam,1,0);
if (@resources) {
- $r->print("
".&mt('Some resource in the sequece currently are not set to exam mode. Grading these resources currently may not work correctly.')."
"); + $r->print("".&mt('Some resources in the sequence currently are not set to exam mode. Grading these resources currently may not work correctly.')."
"); return (1,$currentphase); } } @@ -5247,11 +5260,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