--- loncom/homework/lonhomework.pm 2023/06/04 05:27:28 1.377 +++ loncom/homework/lonhomework.pm 2023/11/17 17:02:21 1.380 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.377 2023/06/04 05:27:28 raeburn Exp $ +# $Id: lonhomework.pm,v 1.380 2023/11/17 17:02:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -163,9 +163,19 @@ sub get_target { return ('web','answer'); } elsif (($env{'form.problemmode'} eq 'saveedit') || ($env{'form.problemmode'} eq 'undo')) { - return ('modified','no_output_web','edit'); + my %editors = &Apache::loncommon::permitted_editors(); + if ($editors{'edit'}) { + return ('modified','no_output_web','edit'); + } else { + return ('web'); + } } elsif ($env{'form.problemmode'} eq 'edit') { - return ('no_output_web','edit'); + my %editors = &Apache::loncommon::permitted_editors(); + if ($editors{'edit'}) { + return ('no_output_web','edit'); + } else { + return ('web'); + } } else { return ('web'); } @@ -942,8 +952,17 @@ sub analyze_header { my $js = &Apache::structuretags::setmode_javascript(); # Breadcrumbs - my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), - 'text' => 'Authoring Space'}, + my $text = 'Authoring Space'; + my $href = &Apache::loncommon::authorspace($request->uri); + if ($env{'request.course.id'}) { + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + if ($href eq "/priv/$cdom/$cnum/") { + $text = 'Course Authoring Space'; + } + } + my $brcrum = [{'href' => $href, + 'text' => $text}, {'href' => '', 'text' => 'Problem Testing'}, {'href' => '', @@ -955,18 +974,26 @@ sub analyze_header { {'bread_crumbs' => $brcrum,}) .&Apache::loncommon::head_subbox( &Apache::loncommon::CSTR_pageheader()); + my %lt = &Apache::lonlocal::texthash( + edit => 'Edit', + editxml => 'EditXML', + ); $result .= '
'. ''. &Apache::structuretags::remember_problem_state().' -
- - -
+
'; + my %editors = &Apache::loncommon::permitted_editors(); + foreach my $item ('editxml','edit') { + next unless ($editors{$item}); + $result .= ''. + "\n"; + } + $result .= + '

@@ -1175,8 +1202,17 @@ sub editxmlmode { &Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); # Breadcrumbs - my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), - 'text' => 'Authoring Space'}, + my $text = 'Authoring Space'; + my $href = &Apache::loncommon::authorspace($request->uri); + if ($env{'request.course.id'}) { + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + if ($href eq "/priv/$cdom/$cnum/") { + $text = 'Course Authoring Space'; + } + } + my $brcrum = [{'href' => $href, + 'text' => $text}, {'href' => '', 'text' => 'Problem Editing'}]; @@ -1209,7 +1245,8 @@ sub editxmlmode { $result .= '
    '; - unless ($env{'environment.nocodemirror'}) { + my $nocodemirror = &Apache::loncommon::nocodemirror(); + unless ($nocodemirror) { # dropdown menus $result .= Apache::lonmenu::create_submenu("#", "", &mt("Problem Templates"), template_dropdown_datastructure()); @@ -1241,7 +1278,7 @@ sub editxmlmode { '
    '; my $resource = $env{'request.ambiguous'}; - unless($env{'environment.nocodemirror'}){ + unless ($nocodemirror) { $result .= '