--- loncom/homework/structuretags.pm 2017/03/14 12:20:57 1.512.2.13 +++ loncom/homework/structuretags.pm 2018/03/28 10:29:54 1.512.2.13.4.3 @@ -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.13 2017/03/14 12:20:57 raeburn Exp $ +# $Id: structuretags.pm,v 1.512.2.13.4.3 2018/03/28 10:29:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -650,10 +650,11 @@ sub setup_rndseed { unless (defined($questiontype)) { $questiontype = $Apache::lonhomework::type; } - if ($env{'request.state'} eq "construct" - || $symb eq '' - || $Apache::lonhomework::type eq 'practice' - || $Apache::lonhomework::history{'resource.CODE'}) { + if (($env{'request.state'} eq "construct") + || ($symb eq '') + || ($Apache::lonhomework::type eq 'practice') + || ($Apache::lonhomework::history{'resource.CODE'}) + || (($env{'form.code_for_randomlist'}) && ($target eq 'analyze'))) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['rndseed']); $rndseed=$env{'form.rndseed'}; @@ -662,7 +663,9 @@ sub setup_rndseed { if (!$rndseed) { $rndseed=time; } - $env{'form.rndseed'}=$rndseed; + unless ($env{'form.code_for_randomlist'}) { + $env{'form.rndseed'}=$rndseed; + } } if (($env{'request.state'} eq "construct") && ($Apache::lonhomework::type eq 'randomizetry')) { @@ -690,7 +693,11 @@ sub setup_rndseed { $rndseed=join(':',&Apache::lonnet::digest($rndseed)); } } - if ($Apache::lonhomework::history{'resource.CODE'}) { + if (($env{'form.code_for_randomlist'}) && ($target eq 'analyze')) { + $env{'form.CODE'} = $env{'form.code_for_randomlist'}; + $rndseed=&Apache::lonnet::rndseed(); + undef($env{'form.CODE'}); + } elsif ($Apache::lonhomework::history{'resource.CODE'}) { $rndseed=&Apache::lonnet::rndseed(); } $set_safespace = 1; @@ -1525,7 +1532,8 @@ sub start_problem { $target eq 'tex') { if ($env{'form.markaccess'}) { my @interval=&Apache::lonnet::EXT("resource.0.interval"); - &Apache::lonnet::set_first_access($interval[1],$interval[0]); + my ($timelimit) = ($interval[0] =~ /^(\d+)/); + &Apache::lonnet::set_first_access($interval[1],$timelimit); } ($status,$accessmsg,$slot_name,$slot) = @@ -2009,6 +2017,8 @@ sub end_library { && ($#$tagstack eq 0 && $$tagstack[0] eq 'library') && $env{'request.state'} eq "construct") { $result.=''.&Apache::loncommon::end_page({'discussion' => 1}); + } elsif ($target eq 'meta') { + $result.=&Apache::response::meta_response_order(); } if ( $#$tagstack eq 0 && $$tagstack[0] eq 'library') { &reset_problem_globals('library'); @@ -2491,7 +2501,12 @@ sub start_randomlist { } if (@randomlist) { my @idx_arr = (0 .. $#randomlist); - &Apache::structuretags::shuffle(\@idx_arr); + if ($env{'form.code_for_randomlist'}) { + &Apache::structuretags::shuffle(\@idx_arr,$target); + undef($env{'form.code_for_randomlist'}); + } else { + &Apache::structuretags::shuffle(\@idx_arr); + } my $bodytext = ''; my $show=$#randomlist; my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval); @@ -2530,10 +2545,10 @@ sub start_randomlist { } sub shuffle { - my $a=shift; + my ($a,$target) = @_; my $i; if (ref($a) eq 'ARRAY' && @$a) { - &Apache::response::pushrandomnumber(); + &Apache::response::pushrandomnumber(undef,$target); for($i=@$a;--$i;) { my $j=int(&Math::Random::random_uniform() * ($i+1)); next if $i == $j;