--- loncom/homework/essayresponse.pm 2004/11/13 21:07:20 1.47
+++ loncom/homework/essayresponse.pm 2004/12/14 18:44:56 1.53
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# essay (ungraded) style responses
#
-# $Id: essayresponse.pm,v 1.47 2004/11/13 21:07:20 albertel Exp $
+# $Id: essayresponse.pm,v 1.53 2004/12/14 18:44:56 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -67,16 +67,16 @@ sub start_essayresponse {
if ($uploadedfiletypes) {
$result.='
'.&mt('Submit a file:').
'
'.
+# $part.'_'.$id.'" onFocus="this.form.enctype='.
+# "'multipart/form-data'".';" /> '.
+ $part.'_'.$id.'" '.
&mt('Allowed filetypes: [_1]',$uploadedfiletypes).' '.
- 'OR: Select Portfolio Files'.
+ 'OR: Select Portfolio Files'.
' '.
''.
' ';
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){
- $result.="Portfolio files previously selected: ".$Apache::lonhomework::history{"resource.$part.$id.portfiles"}." ";
+ $result.="Portfolio files previously selected: ".&Apache::lonnet::unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"})." ";
}
if ($uploadedfile) {
@@ -117,6 +117,7 @@ sub end_essayresponse {
my $response = $ENV{'form.HWVAL_'.$id};
my $filename= $ENV{'form.HWFILE'.$part.'_'.$id.'.filename'};
my $portfiles = $ENV{'form.HWPORT'.$part.'_'.$id};
+ &Apache::lonnet::logthis("portfiles now $portfiles");
if (( $response =~ /[^\s]/) || ($filename =~ /[^\s]/) || ($portfiles =~ /[^\s]/)) {
my $award;
if ($ENV{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') {
@@ -126,6 +127,7 @@ sub end_essayresponse {
}
my $uploadedflag=0;
if ($filename =~ /[^\s]/) {
+ &Apache::lonnet::logthis("the file to upload is $filename");
my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes");
$uploadedfiletypes=~s/[^\w\,]//g;
$uploadedfiletypes=','.$uploadedfiletypes.',';
@@ -138,19 +140,21 @@ sub end_essayresponse {
} else {
$award='INVALID_FILETYPE';
}
+ } else {
+ $Apache::lonhomework::results{"resource.$part.$id.uploadedfile"}="";
+ $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"}="";
}
if ($portfiles =~ /[^\s]/) {
+ $portfiles =~s/,$//;
$Apache::lonhomework::results{"resource.$part.$id.portfiles"}=$portfiles;
- $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"}=$portfiles;
my @submitted_files = split /,/,$portfiles;
- my ($dsymb,$crsid,$domain,$name)=
- &Apache::lonxml::whichuser();
- foreach (@submitted_files) {
- my $file = $_;
- &Apache::lonnet::put('file_permissions',
- { $dsymb.$crsid => $file },$domain,$name);
- }
+ my ($dsymb,$crsid,$domain,$name)=&Apache::lonxml::whichuser();
+ &Apache::lonnet::unmark_as_readonly($domain,$name,$dsymb.$crsid);
+ &Apache::lonnet::mark_as_readonly($domain,$name,\@submitted_files,$dsymb.$crsid);
+ &Apache::lonnet::clear_selected_files($name);
$uploadedflag=1;
+ } else {
+ $Apache::lonhomework::results{"resource.$part.$id.portfiles"}="";
}
$Apache::lonhomework::results{"resource.$part.$id.submission"}=$response;
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$award;
|