--- loncom/homework/structuretags.pm 2023/07/12 17:43:24 1.577 +++ loncom/homework/structuretags.pm 2023/11/28 04:48:15 1.582 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.577 2023/07/12 17:43:24 raeburn Exp $ +# $Id: structuretags.pm,v 1.582 2023/11/28 04:48:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -297,7 +297,7 @@ sub homework_js { } return &Apache::loncommon::resize_textarea_js(). &Apache::loncommon::colorfuleditor_js(). - &setmode_javascript(). + &Apache::lonxml::setmode_javascript(). <<"JS"; -ENDSCRIPT -} - sub page_start { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name, $extra_head)=@_; @@ -445,7 +430,7 @@ sub page_start { if (&Apache::lonhtmlcommon::htmlareabrowser()) { my %textarea_args; if (($env{'request.state'} ne 'construct') || - ($env{'environment.nocodemirror'})) { + (&Apache::loncommon::nocodemirror())) { %textarea_args = ( dragmath => 'math', ); @@ -835,13 +820,18 @@ sub problem_edit_action_button { sub problem_edit_buttons { my ($mode)=@_; + my %editors = &Apache::loncommon::permitted_editors(); # Buttons that save my $result = '
'; if ($mode eq 'editxml') { - $result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML'); + if ($editors{'xml'}) { + $result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML'); + } $result.=&problem_edit_action_button('subsaveview','saveviewxml','v','Save and View'); } else { - $result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit'); + if ($editors{'edit'}) { + $result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit'); + } $result.=&problem_edit_action_button('subsaveview','saveview','v','Save and View'); } $result.="\n
\n"; @@ -849,13 +839,23 @@ sub problem_edit_buttons { $result .= '
'. &problem_edit_action_button('subdiscview','discard','d','Discard Edits and View',1); if ($mode eq 'editxml') { - $result.=&problem_edit_action_button('subedit','edit','e','Edit',1); + if ($editors{'edit'}) { + $result.=&problem_edit_action_button('subedit','edit','e','Edit',1); + } + if ($editors{'daxe'}) { + $result.=&problem_edit_action_button('subdaxe','daxe','w','Edit with Daxe',1); + } $result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1); - if ($env{'environment.nocodemirror'}) { + if (&Apache::loncommon::nocodemirror()) { $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1); } } else { - $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1); + if ($editors{'xml'}) { + $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1); + } + if ($editors{'daxe'}) { + $result.=&problem_edit_action_button('subdaxe','daxe','w','Edit with Daxe',1); + } $result.=&problem_edit_action_button('subundo','undo','u','Undo',1); } $result.="\n
"; @@ -927,6 +927,7 @@ sub option { sub problem_web_to_edit_header { my ($rndseed)=@_; + my %editors = &Apache::loncommon::permitted_editors(); my $result .= '
'; if (!$Apache::lonhomework::parsing_a_task) { @@ -1056,15 +1057,20 @@ $show_all
'; $result.=''; - $result .= ''; - $result .= ''; - if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) { + if ($editors{'edit'}) { + $result .= ''; + } + if ($editors{'xml'}) { + $result .= ''; + } + if (($editors{'daxe'}) && + ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9)) { my $uri = $env{'request.uri'}; my $daxeurl = '/daxepage'.$uri; - $result .= ''; + $result .= ''; } $result.='
@@ -2373,7 +2379,8 @@ ENDJS # computation: # if ($target eq 'web') { - $result .= &Apache::lonhtmlcommon::set_compute_end_time(); + $result .= &Apache::lonhtmlcommon::dash_to_minus_js(). + &Apache::lonhtmlcommon::set_compute_end_time(); # # Closing tags delayed so any tags # not in head can appear inside body, for valid xhtml. @@ -3374,7 +3381,7 @@ sub end_startouttext { .&Apache::edit::deletelist($target,$token) .'' .''; - if ($env{'environment.nocodemirror'}) { + if (&Apache::loncommon::nocodemirror()) { $result.=&Apache::lonhtmlcommon::dragmath_button($areaid,1); } else { $result.=' ';