[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework structuretags.pm
raeburn
raeburn at source.lon-capa.org
Fri Sep 15 11:10:12 EDT 2017
raeburn Fri Sep 15 15:10:12 2017 EDT
Modified files: (Branch: version_2_11_X)
/loncom/homework structuretags.pm
Log:
- For 2.11
- Backport 1.555
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.512.2.13 loncom/homework/structuretags.pm:1.512.2.14
--- loncom/homework/structuretags.pm:1.512.2.13 Tue Mar 14 12:20:57 2017
+++ loncom/homework/structuretags.pm Fri Sep 15 15:10:11 2017
@@ -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.14 2017/09/15 15:10:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -650,10 +650,11 @@
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 @@
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 @@
$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;
@@ -2491,7 +2498,12 @@
}
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 +2542,10 @@
}
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;
More information about the LON-CAPA-cvs
mailing list