--- loncom/homework/structuretags.pm 2011/07/25 12:02:45 1.492 +++ loncom/homework/structuretags.pm 2011/07/26 17:14:51 1.493 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.492 2011/07/25 12:02:45 christianto Exp $ +# $Id: structuretags.pm,v 1.493 2011/07/26 17:14:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -170,37 +170,154 @@ sub file_delchk_js { return <<"ENDSCRIPT"; +ENDSCRIPT +} + +sub file_overwritechk_js { + my $overwritewarn = &mt('File(s) you uploaded for your submission will overwrite existing file(s) submitted for this item').'\\n'. + &mt('Continue submission and overwrite the file(s)?'); + return <<"ENDSCRIPT"; + @@ -232,8 +349,43 @@ sub page_start { $extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); } my $is_task = ($env{'request.uri'} =~ /\.task$/); + my $needs_upload; if ($is_task) { $extra_head .= &file_delchk_js(); + } else { + if (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.uploadedfiletypes") ne '') { + $needs_upload = 1; + } else { + unless ($env{'request.state'} eq 'construct') { + my ($symb)= &Apache::lonnet::whichuser(); + my $navmap = Apache::lonnavmaps::navmap->new(); + if (ref($navmap)) { + my $res = $navmap->getBySymb($symb); + if (ref($res)) { + my $partlist = $res->parts(); + if (ref($partlist) eq 'ARRAY') { + foreach my $part (@{$partlist}) { + my @types = $res->responseType($part); + my @ids = $res->responseIds($part); + for (my $i=0; $i < scalar(@ids); $i++) { + if ($types[$i] eq 'essay') { + my $partid = $part.'_'.$ids[$i]; + if (&Apache::lonnet::EXT("resource.$partid.uploadedfiletypes") ne '') { + $needs_upload = 1; + last; + } + } + } + } + } + } + } + } + } + } + if ($needs_upload) { + $extra_head .= &file_overwritechk_js()."\n". + &file_delchk_js(); } my %body_args; @@ -316,7 +468,6 @@ sub page_start { if (!defined($found{'body'}) && $env{'request.state'} ne 'construct') { $page_start .= &Apache::lonxml::message_location(); } - my $form_tag_start; if (!defined($found{'form'})) { $form_tag_start='