--- loncom/homework/structuretags.pm 2010/10/28 00:27:56 1.477 +++ 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.477 2010/10/28 00:27:56 www Exp $ +# $Id: structuretags.pm,v 1.493 2011/07/26 17:14:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -128,6 +128,7 @@ sub homework_js { &setmode_javascript(). <<'JS'; JS } @@ -153,10 +154,172 @@ JS sub setmode_javascript { return <<"ENDSCRIPT"; +ENDSCRIPT +} + +sub file_delchk_js { + my $delfilewarn = &mt('You have indicated you wish to remove some files previously included in your submission.').'\\n'. + &mt('Continue submission with these files removed?'); + 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"; + ENDSCRIPT } @@ -185,6 +348,45 @@ 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; if (defined($found{'html'})) { @@ -266,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='