--- loncom/homework/structuretags.pm 2009/05/28 12:39:17 1.447
+++ 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.447 2009/05/28 12:39:17 bisitz Exp $
+# $Id: structuretags.pm,v 1.493 2011/07/26 17:14:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,7 +66,7 @@ use lib '/home/httpd/lib/perl/';
use LONCAPA;
BEGIN {
- &Apache::lonxml::register('Apache::structuretags',('block','languageblock','translated','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag'));
+ &Apache::lonxml::register('Apache::structuretags',('block','languageblock','translated','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startpartmarker','startouttext','endpartmarker','endouttext','simpleeditbutton','definetag'));
}
sub start_web {
@@ -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
}
@@ -177,12 +340,52 @@ sub page_start {
$parstack,$parser,$safeeval);
}
- $extra_head .= &homework_js();
-
- if ($env{'environment.wysiwygeditor'} eq 'on') {
- $extra_head .= &Apache::lonhtmlcommon::dragmath_js("FCKEditMathPopup");
+ $extra_head .= &homework_js().
+ &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
+ if (&Apache::lonhtmlcommon::htmlareabrowser()) {
+ my %textarea_args = (
+ dragmath => 'math',
+ );
+ $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 {
- $extra_head .= &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
+ 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;
@@ -209,11 +412,21 @@ sub page_start {
} elsif (!defined($found{'body'})
&& $env{'request.state'} eq 'construct') {
if ($target eq 'web' || $target eq 'edit') {
- if ($env{'environment.remote'} ne 'off') {
- $body_args{'only_body'} = 1;
- }
- $pageheader = &Apache::lonhtmlcommon::breadcrumbs() # FIXME add breadcrumbs
- .&Apache::loncommon::head_subbox(
+ # Breadcrumbs for Construction Space
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'Construction Space',
+ 'href' => &Apache::loncommon::authorspace(),
+ });
+ # breadcrumbs (and tools) will be created
+ # in start_page->bodytag->innerregister
+
+# FIXME Where are we?
+# &Apache::lonhtmlcommon::add_breadcrumb({
+# 'text' => 'Problem Editing', # 'Problem Testing'
+# 'href' => '',
+# });
+ $pageheader =&Apache::loncommon::head_subbox(
&Apache::loncommon::CSTR_pageheader());
}
} elsif (!defined($found{'body'})) {
@@ -232,8 +445,7 @@ sub page_start {
# $body_args{'no_title'} = 1;
$body_args{'force_register'} = 1;
$body_args{'add_entries'} = \%add_entries;
- if ($env{'environment.remote'} eq 'off'
- && $env{'request.state'} eq 'construct') {
+ if ( $env{'request.state'} eq 'construct') {
$body_args{'only_body'} = 1;
}
}
@@ -246,25 +458,34 @@ sub page_start {
&& ($target eq 'web' || $target eq 'webgrade')) {
my ($symb,undef,undef,undef,$publicuser)= &Apache::lonnet::whichuser();
- if ($symb eq '' && !$publicuser) {
- my $help = &Apache::loncommon::help_open_topic("Ambiguous_Reference");
- $help=&mt("Browsing resource, all submissions are temporary.")."
";
- $page_start .= $help;
- }
+ if ($symb eq '' && !$publicuser) {
+ $page_start .= '
' + .&mt('Browsing resource, all submissions are temporary.') + .'
'; + } } 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='