--- loncom/homework/structuretags.pm 2024/03/01 17:05:45 1.512.2.24.2.14 +++ 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.512.2.24.2.14 2024/03/01 17:05:45 raeburn Exp $ +# $Id: structuretags.pm,v 1.585 2024/02/27 22:09:40 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,7 +69,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','startpartmarker','startouttext','endpartmarker','endouttext','simpleeditbutton','definetag')); + &Apache::lonxml::register('Apache::structuretags',('block','languageblock','translated','instructorcomment','while','randomlist','problem','library','web','print','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startpartmarker','startouttext','endpartmarker','endouttext','simpleeditbutton','definetag')); } @@ -194,6 +194,28 @@ sub end_web { return ''; } +sub start_print { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; + if ($target ne 'edit' && $target ne 'modified') { + if ($target ne 'tex') { + my $skip = &Apache::lonxml::get_all_text("/print",$parser,$style); + &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]"); + } + } elsif ($target eq "edit") { + my $bodytext = &Apache::lonxml::get_all_text_unbalanced("/print",$parser); + my $result = &Apache::edit::tag_start($target,$token); + $result .= &Apache::edit::editfield($token->[1],$bodytext,'',80,1); + return $result; + } elsif ($target eq "modified") { + return $token->[4].&Apache::edit::modifiedfield("/print",$parser); + } + return ''; +} + +sub end_print { + return ''; +} + sub start_tex { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result=''; @@ -228,9 +250,11 @@ sub end_tex { sub homework_js { my ($postsubmit,$timeout); if (($env{'request.course.id'}) && ($env{'request.state'} ne 'construct')) { - my $crstype; - if (&Apache::loncommon::course_type() eq 'Community') { + my $crstype = &Apache::loncommon::course_type(); + if ($crstype eq 'Community') { $crstype = 'community'; + } elsif ($crstype eq 'Placement') { + $crstype = 'placement'; } else { if ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) { $crstype = 'official'; @@ -272,7 +296,7 @@ sub homework_js { $jstimeout = 1000 * $timeout; } return &Apache::loncommon::resize_textarea_js(). - &Apache::loncommon::colorfuleditor_js(). + &Apache::loncommon::colorfuleditor_js(). &Apache::lonxml::setmode_javascript(). <<"JS"; '; + $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js() + .''; } } @@ -515,11 +539,20 @@ sub page_start { && $env{'request.state'} eq 'construct') { if ($target eq 'web' || $target eq 'edit') { unless ($env{'form.inhibitmenu'} eq 'yes') { + my $text = 'Authoring Space'; + my $href = &Apache::loncommon::authorspace($env{'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 = &mt('Course Authoring Space'); + } + } # Breadcrumbs for Authoring Space &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Authoring Space', - 'href' => &Apache::loncommon::authorspace($env{'request.uri'}), + 'text' => $text, + 'href' => $href, }); # breadcrumbs (and tools) will be created # in start_page->bodytag->innerregister @@ -632,7 +665,7 @@ sub get_resource_name { } sub setup_rndseed { - my ($safeeval,$target,$probpartlist)=@_; + my ($safeeval,$target,$probpartlist,$prevparttype)=@_; my ($symb)=&Apache::lonnet::whichuser(); my ($questiontype,$set_safespace,$rndseed,$numtries,$reqtries); if ($target eq 'analyze') { @@ -749,11 +782,20 @@ sub setup_rndseed { if ($target eq 'grade') { $Apache::lonhomework::rawrndseed = $rndseed; } + } elsif ($prevparttype eq 'randomizetry') { + if ($env{'form.0.rndseed'} ne '') { + $set_safespace = 1; + $rndseed = $env{'form.0.rndseed'}; + } } if ($set_safespace) { if ($safeeval) { &Apache::lonxml::debug("Setting rndseed to $rndseed"); &Apache::run::run('$external::randomseed="'.$rndseed.'";',$safeeval); + if (($Apache::lonhomework::type eq 'randomizetry') || ($prevparttype eq 'randomizetry')) { + &Apache::lonxml::debug("Setting randomizetrypart to $Apache::inputtags::part"); + &Apache::run::run('$external::randomizetrypart="'.$Apache::inputtags::part.'";',$safeeval); + } } } unless (($env{'request.state'} eq "construct") || ($symb eq '')) { @@ -857,7 +899,6 @@ sub problem_edit_header { return $return; } - sub problem_edit_footer { my $resource = $env{'request.ambiguous'}; return '
@@ -934,7 +975,7 @@ sub problem_web_to_edit_header { ".&mt("Problem Type:")."