[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework structuretags.pm

raeburn raeburn at source.lon-capa.org
Tue Nov 5 13:14:39 EST 2019


raeburn		Tue Nov  5 18:14:39 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/homework	structuretags.pm 
  Log:
  - For 2.11
    Backport 1.568
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.512.2.21 loncom/homework/structuretags.pm:1.512.2.22
--- loncom/homework/structuretags.pm:1.512.2.21	Mon Nov  4 20:50:57 2019
+++ loncom/homework/structuretags.pm	Tue Nov  5 18:14:39 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.512.2.21 2019/11/04 20:50:57 raeburn Exp $
+# $Id: structuretags.pm,v 1.512.2.22 2019/11/05 18:14:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -652,10 +652,18 @@
     }
     if ($Apache::lonhomework::type eq 'randomizetry') {
         my $partfortries = $Apache::inputtags::part;
+#
+# Where question type is "randomizetry" for a problem containing
+# a single part (and unless type is explicitly set to not be
+# "randomizetry" for that part), the number of tries used to
+# determine randomization will be for that part, and randomization
+# from calls to &random() in a perl script block before the part tag,
+# will change based on the number of tries, and value of the
+# "randomizeontries" parameter in effect for the single part.
+#
         if (ref($probpartlist) eq 'ARRAY') {
-            if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $Apache::inputtags::part)) {
-                $partfortries = $probpartlist->[0];
-                if (&Apache::lonnet::EXT("resource.$partfortries.questiontype") eq 'randomizetry') {
+            if ((@{$probpartlist} == 1) && ($probpartlist->[0] ne $partfortries)) {
+                if (&Apache::lonnet::EXT('resource.'.$probpartlist->[0].'.type') eq 'randomizetry') {
                     $partfortries = $probpartlist->[0];
                 } else {
                     $partfortries = '';
@@ -1566,11 +1574,13 @@
 			$name);
     } elsif (($target eq 'grade') && ($Apache::lonhomework::type eq 'randomizetry')) {
         my ($symb)= &Apache::lonnet::whichuser();
-        my $navmap = Apache::lonnavmaps::navmap->new();
-        if (ref($navmap)) {
-            my $res = $navmap->getBySymb($symb);
-            if (ref($res)) {
-                $probpartlist = $res->parts();
+        if ($symb ne '') {
+            my $navmap = Apache::lonnavmaps::navmap->new();
+            if (ref($navmap)) {
+                my $res = $navmap->getBySymb($symb);
+                if (ref($res)) {
+                    $probpartlist = $res->parts();
+                }
             }
         }
     }
@@ -1581,7 +1591,14 @@
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
 	$target eq 'tex') {
 
+        my ($symb) = &Apache::lonnet::whichuser();
 	#handle rand seed in construction space
+        if (($env{'request.state'} eq 'construct') || ($symb eq '')) {
+            my $partorder=&Apache::lonnet::metadata($env{'request.uri'},'partorder');
+            if ($partorder ne '') {
+                @{$probpartlist} = split(/,/,$partorder);
+            }
+        }
 	my $rndseed=&setup_rndseed($safeeval,$target,$probpartlist);
         if (($target eq 'grade') && &Apache::response::submitted()) {
             if ($Apache::lonhomework::type eq 'randomizetry') {
@@ -1596,7 +1613,6 @@
                 }
             }
         }
-	my ($symb)=&Apache::lonnet::whichuser();
 
 	if ($env{'request.state'} ne "construct" && 
 	    ($symb eq '' || $Apache::lonhomework::type eq 'practice')) {




More information about the LON-CAPA-cvs mailing list