[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm structuretags.pm
raeburn
raeburn at source.lon-capa.org
Wed Nov 6 11:20:07 EST 2019
raeburn Wed Nov 6 16:20:07 2019 EDT
Modified files:
/loncom/homework default_homework.lcpm structuretags.pm
Log:
- Bug 6919. For multi-part problems containing perl script blocks inside
part(s), if question type = randomizetry, the first call to &random()
for each part needs to set the new seed.
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.176 loncom/homework/default_homework.lcpm:1.177
--- loncom/homework/default_homework.lcpm:1.176 Wed Apr 3 21:37:11 2019
+++ loncom/homework/default_homework.lcpm Wed Nov 6 16:20:06 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
#
-# $Id: default_homework.lcpm,v 1.176 2019/04/03 21:37:11 raeburn Exp $
+# $Id: default_homework.lcpm,v 1.177 2019/11/06 16:20:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -29,6 +29,7 @@
#init some globals
$hidden::RANDOMINIT=0;
+$hidden::RANDOMINITTRYPART='';
$pi=atan2(1,1)*4;
$rad2deg=180.0/$pi;
$deg2rad=$pi/180.0;
@@ -655,7 +656,9 @@
sub random {
my ($start,$end,$step)=@_;
- if ( ! $hidden::RANDOMINIT ) {
+ if (( ! $hidden::RANDOMINIT ) ||
+ (($external::randomizetrypart ne '') &&
+ ($hidden::RANDOMINITTRYPART ne $external::randomizetrypart))) {
if ($external::randomseed == 0) { $external::randomseed=1; }
if ($external::randomseed =~/,/) {
my ($num1,$num2) = map { abs($_); } split(/,/,$external::randomseed);
@@ -681,6 +684,7 @@
}
&math_random_uniform();
$hidden::RANDOMINIT=1;
+ $hidden::RANDOMINITTRYPART=$external::randomizetrypart;
}
if (!defined($step)) { $step=1; }
my $num=1+int(($end-$start)/$step);
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.568 loncom/homework/structuretags.pm:1.569
--- loncom/homework/structuretags.pm:1.568 Tue Nov 5 18:08:09 2019
+++ loncom/homework/structuretags.pm Wed Nov 6 16:20:06 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.568 2019/11/05 18:08:09 raeburn Exp $
+# $Id: structuretags.pm,v 1.569 2019/11/06 16:20:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -789,6 +789,14 @@
if ($safeeval) {
&Apache::lonxml::debug("Setting rndseed to $rndseed");
&Apache::run::run('$external::randomseed="'.$rndseed.'";',$safeeval);
+ my $prevparttype;
+ if (@Apache::inputtags::partlist > 1) {
+ $prevparttype = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[-2].type");
+ }
+ 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 '')) {
More information about the LON-CAPA-cvs
mailing list