--- loncom/homework/essayresponse.pm 2010/08/22 19:00:15 1.109
+++ loncom/homework/essayresponse.pm 2011/01/29 19:41:41 1.114
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# essay (ungraded) style responses
#
-# $Id: essayresponse.pm,v 1.109 2010/08/22 19:00:15 raeburn Exp $
+# $Id: essayresponse.pm,v 1.114 2011/01/29 19:41:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -58,22 +58,18 @@ sub start_essayresponse {
if (!defined($maxfilesize)) {
$maxfilesize = 10.0; #FIXME This should become a domain configuration
}
+ my $hiddendraft;
if (($Apache::lonhomework::type eq 'survey') ||
($Apache::lonhomework::type eq 'surveycred') ||
($Apache::lonhomework::type eq 'anonsurvey') ||
($Apache::lonhomework::type eq 'anonsurveycred')) {
- $result.= '';
- }
- my $status_text = &mt('Submission type');
- if ($Apache::lonhomework::history{"resource.$part.award"} eq 'DRAFT') {
- $status_text .= '
'.&mt('(Currently -- draft)');
- }
- $result.= '
'.&Apache::lonhtmlcommon::start_pick_box().
- &Apache::lonhtmlcommon::row_title($status_text);
- if (($Apache::lonhomework::type ne 'survey') &&
- ($Apache::lonhomework::type ne 'surveycred') &&
- ($Apache::lonhomework::type ne 'anonsurvey') &&
- ($Apache::lonhomework::type ne 'anonsurveycred')) {
+ $hiddendraft = '';
+ } else {
+ my $status_text = &mt('Submission type');
+ if ($Apache::lonhomework::history{"resource.$part.award"} eq 'DRAFT') {
+ $status_text .= '
'.&mt('(Currently -- draft)');
+ }
+ $result = &Apache::lonhtmlcommon::row_title($status_text);
my $closure;
unless ($ncol || $uploadedfiletypes) {
$closure = 1;
@@ -111,7 +107,15 @@ sub start_essayresponse {
}
$result.=&Apache::inputtags::file_selector($part,$id,$uploadedfiletypes,
$filesfrom,undef,$maxfilesize);
- $result.=&Apache::lonhtmlcommon::end_pick_box().'
';
+ if ($result) {
+ $result =
+ ''.$hiddendraft.
+ &Apache::lonhtmlcommon::start_pick_box().
+ $result.
+ &Apache::lonhtmlcommon::end_pick_box().'
';
+ } else {
+ $result = $hiddendraft;
+ }
} elsif ($target eq 'web' &&
$Apache::inputtags::status[-1] ne 'CAN_ANSWER') {
my $part= $Apache::inputtags::part;
@@ -155,10 +159,12 @@ sub end_essayresponse {
$increment=&Apache::response::scored_response($part,$id);
} elsif ( &Apache::response::submitted() ) {
my $response = $env{'form.HWVAL_'.$id};
- my $filename = $env{'form.HWFILE'.$part.'_'.$id.'.filename'} ||
+ my $jspart=$part;
+ $jspart=~s/\./_/g;
+ my $filename = $env{'form.HWFILE'.$jspart.'_'.$id.'.filename'} ||
$env{'form.HWFILETOOBIG'.$part.'_'.$id};
- my $portfiles = $env{'form.HWPORT'.$part.'_'.$id};
- my @deletions = &Apache::loncommon::get_env_multiple('form.HWFILE'.$part.'_'.$id.'_delete');
+ my $portfiles = $env{'form.HWPORT'.$jspart.'_'.$id};
+ my @deletions = &Apache::loncommon::get_env_multiple('form.HWFILE'.$jspart.'_'.$id.'_delete');
my ($is_submit,$was_draft);
if ($env{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') {
$is_submit = 1;
@@ -306,6 +312,8 @@ sub file_submission {
$port_delete{$file} = 1;
} elsif ($file =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/essayresponse/\Q$cdom\E/\Q$cnum\E/}) {
$uploaded_delete = $file;
+ } elsif ($file =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/essayresponse/[^/]+$}) {
+ $uploaded_delete = $file;
}
}
}
@@ -316,8 +324,12 @@ sub file_submission {
}
}
if ($uploaded_delete) {
- $Apache::lonhomework::results{"resource.$part.$id.uploadedfile"} = "";
- $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"} = "";
+ if ($uploaded_delete eq $uploadedurl) {
+ $Apache::lonhomework::results{"resource.$part.$id.uploadedfile"} = "";
+ $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"} = "";
+ } else {
+ undef($uploaded_delete);
+ }
}
}
if ($env{'form.HWPORT'.$jspart.'_'.$id} ne '') {
@@ -331,7 +343,7 @@ sub file_submission {
}
}
}
- if ($env{'form.HWFILETOOBIG'.$jspart.'_'.$id} ne '') {
+ if ($env{'form.HWFILETOOBIG'.$part.'_'.$id} ne '') {
$$award = 'EXCESS_FILESIZE';
} elsif ($env{'form.HWFILE'.$jspart.'_'.$id.'.filename'} ne '') {
my $newfile = $env{'form.HWFILE'.$jspart.'_'.$id.'.filename'};
@@ -483,8 +495,7 @@ sub file_submission {
push(@pathitems,$restitle);
$path .= join('/',@pathitems);
my $formelement = 'HWFILE'.$jspart.'_'.$id;
- my $fname = $env{'form.'.$formelement.'.filename'};
- &Apache::lonnet::clean_filename($fname);
+ my $fname = &Apache::lonnet::clean_filename($env{'form.'.$formelement.'.filename'});
my $url = '/uploaded/'.$udom.'/'.$uname.'/'.$prefix.$path.'/'.$fname;
my @stat = &Apache::lonnet::stat_file($url);
if (@stat && $stat[0] ne 'no_such_dir') {
@@ -515,7 +526,9 @@ sub file_submission {
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} = "";
}
}
- if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"} ne $Apache::lonhomework::results{"resource.$part.$id.portfiles"}) {
+ if (($Apache::lonhomework::history{"resource.$part.$id.portfiles"} ne
+ $Apache::lonhomework::results{"resource.$part.$id.portfiles"}) ||
+ ($uploaded_delete)) {
if (ref($uploadedflag)) {
$$uploadedflag=1;
}