--- loncom/homework/structuretags.pm 2023/11/07 12:26:00 1.579 +++ loncom/homework/structuretags.pm 2024/02/27 22:09:40 1.585 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.579 2023/11/07 12:26:00 raeburn Exp $ +# $Id: structuretags.pm,v 1.585 2024/02/27 22:09:40 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)=@_; @@ -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 (&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.='
@@ -1433,20 +1439,30 @@ sub needs_linkprot_passback { $lti_in_use = $domlti{$itemnum}; } my ($state,$others,$listed,$scope,$protect,$display,$target,$exit) = split(/,/,$deeplink); - my $passback; - if ($scope eq 'resource') { + my ($passback,$pbscope); + if ($scope eq 'res') { if ($deeplink_symb eq $symb) { $passback = 1; + $pbscope = 'resource'; } } elsif ($scope eq 'map') { if (&Apache::lonnet::clutter($deeplink_map) eq $map) { $passback = 1; + $pbscope = 'nonrec'; + } + } elsif ($scope eq 'rec') { + if (&Apache::lonnet::clutter($deeplink_map) eq $map) { + $passback = 1; + $pbscope = 'map'; + } else { + my @recurseup = &Apache::lonnet::get_map_hierarchy($map,$env{'request.course.id'}); + if (grep(/^\Q$deeplink_map\E$/,@recurseup)) { + $passback = 1; + $pbscope = 'map'; + } } - } elsif ($scope eq 'recurse') { -#FIXME check if $deeplink_map contains $map - $passback = 1; } - return ($passback,$scope,$deeplink_map,$deeplink_symb,$crsdef,$itemnum,$lti_in_use); + return ($passback,$pbscope,$deeplink_map,$deeplink_symb,$crsdef,$itemnum,$lti_in_use); } } } @@ -1636,10 +1652,13 @@ sub access_status_msg { $msg ='\noindent \vskip 1 mm '. $startminipage.'\vskip 0 mm'; if ($status eq 'UNAVAILABLE') { - $msg.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm '; + $msg.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.'); + } elsif ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') { + $msg.=&mt('Problem is not open to be viewed. It')." $accessmsg"; } else { - $msg.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm "; + $msg.=&mt('Problem is not open to be viewed.'); } + $msg .= " \\vskip 0 mm "; } return $msg; }