[LON-CAPA-cvs] cvs: loncom /homework response.pm structuretags.pm /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Fri Mar 30 19:50:29 EDT 2018


raeburn		Fri Mar 30 23:50:29 2018 EDT

  Modified files:              
    /loncom/homework	structuretags.pm response.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - <partorder> tag for a library file will include ids of any part tags.
  - library file is only loaded and inspected to check for parts if <partorder>
    is absent.
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.558 loncom/homework/structuretags.pm:1.559
--- loncom/homework/structuretags.pm:1.558	Tue Mar 27 04:36:28 2018
+++ loncom/homework/structuretags.pm	Fri Mar 30 23:50:13 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.558 2018/03/27 04:36:28 raeburn Exp $
+# $Id: structuretags.pm,v 1.559 2018/03/30 23:50:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2057,7 +2057,7 @@
 	    @Apache::inputtags::response=();
 	    $result=&Apache::response::mandatory_part_meta;
 	}
-	$result.=&Apache::response::meta_part_order();
+	$result.=&Apache::response::meta_part_order('problem');
 	$result.=&Apache::response::meta_response_order();
     } elsif ($target eq 'edit') {
 	&Apache::lonxml::debug("in end_problem with $target, edit");
@@ -2135,6 +2135,7 @@
 	     && $env{'request.state'} eq "construct") {
 	$result.='</form>'.&Apache::loncommon::end_page({'discussion' => 1});
     } elsif ($target eq 'meta') {
+        $result.=&Apache::response::meta_part_order('library');
         $result.=&Apache::response::meta_response_order();
     }
     if ( $#$tagstack eq 0 && $$tagstack[0] eq 'library') {
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.244 loncom/homework/response.pm:1.245
--- loncom/homework/response.pm:1.244	Fri Oct 30 03:49:47 2015
+++ loncom/homework/response.pm	Fri Mar 30 23:50:13 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.244 2015/10/30 03:49:47 raeburn Exp $
+# $Id: response.pm,v 1.245 2018/03/30 23:50:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -265,10 +265,15 @@
 }
 
 sub meta_part_order {
+    my ($type) = @_; 
     if (@Apache::inputtags::partlist) {
 	my @parts=@Apache::inputtags::partlist;
-	shift(@parts);
+        unless ($type eq 'library') {
+	    shift(@parts);
+        }
 	return '<partorder>'.join(',', at parts).'</partorder>'."\n";
+    } elsif ($type eq 'library') {
+        return '<partorder></partorder>'."\n";
     } else {
 	return '<partorder>0</partorder>'."\n";
     }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1371 loncom/lonnet/perl/lonnet.pm:1.1372
--- loncom/lonnet/perl/lonnet.pm:1.1371	Fri Mar 30 21:30:00 2018
+++ loncom/lonnet/perl/lonnet.pm	Fri Mar 30 23:50:29 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1371 2018/03/30 21:30:00 raeburn Exp $
+# $Id: lonnet.pm,v 1.1372 2018/03/30 23:50:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -11928,23 +11928,28 @@
 # Check metadata for imported file to
 # see if it contained response items
 #
+                        my ($origfile, at libfilekeys);
                         my %currmetaentry = %metaentry;
-                        my $libresponseorder = &metadata($location,'responseorder');
-                        my $origfile;
-                        if ($libresponseorder ne '') {
-                            if ($#origfiletagids<0) {
-                                undef(%importedrespids);
-                                undef(%importedpartids);
-                            }
-                            @{$importedrespids{$importid}} = split(/\s*,\s*/,$libresponseorder);
-                            if (@{$importedrespids{$importid}} > 0) {
-                                $importedresponses = 1;
+                        @libfilekeys = split(/,/,&metadata($location,'keys',undef,undef,undef,
+                                                           $depthcount+1));
+                        if (grep(/^responseorder$/, at libfilekeys)) {
+                            my $libresponseorder = &metadata($location,'responseorder',undef,undef,
+                                                             undef,$depthcount+1);
+                            if ($libresponseorder ne '') {
+                                if ($#origfiletagids<0) {
+                                    undef(%importedrespids);
+                                    undef(%importedpartids);
+                                }
+                                @{$importedrespids{$importid}} = split(/\s*,\s*/,$libresponseorder);
+                                if (@{$importedrespids{$importid}} > 0) {
+                                    $importedresponses = 1;
 # We need to get the original file and the imported file to get the response order correct
 # Load and inspect original file
-                                if ($#origfiletagids<0) {
-                                    my $origfilelocation=$perlvar{'lonDocRoot'}.&clutter($uri);
-                                    $origfile=&getfile($origfilelocation);
-                                    @origfiletagids=($origfile=~/<((?:\w+)response|import|part)[^>]*id\s*=\s*[\"\']([^\"\']+)[\"\'][^>]*>/gs);
+                                    if ($#origfiletagids<0) {
+                                        my $origfilelocation=$perlvar{'lonDocRoot'}.&clutter($uri);
+                                        $origfile=&getfile($origfilelocation);
+                                        @origfiletagids=($origfile=~/<((?:\w+)response|import|part)[^>]*id\s*=\s*[\"\']([^\"\']+)[\"\'][^>]*>/gs);
+                                    }
                                 }
                             }
                         }
@@ -11970,10 +11975,23 @@
                                    @origfiletagids=($origfile=~/<(part|import)[^>]*id\s*=\s*[\"\']([^\"\']+)[\"\'][^>]*>/gs);
                                }
                            }
-
-# Load and inspect imported file
-                           my $impfile=&getfile($location);
-                           my @impfilepartids=($impfile=~/<part[^>]*id\s*=\s*[\"\']([^\"\']+)[\"\'][^>]*>/gs);
+                           my @impfilepartids;
+# If <partorder> tag is included in metadata for the imported file
+# get the parts in the imported file from that.
+                           if (grep(/^partorder$/, at libfilekeys)) {
+                               %currmetaentry = %metaentry;
+                               my $libpartorder = &metadata($location,'partorder',undef,undef,undef,
+                                                            $depthcount+1);
+                               %metaentry = %currmetaentry;
+                               undef(%currmetaentry);
+                               if ($libpartorder ne '') {
+                                   @impfilepartids=split(/\s*,\s*/,$libpartorder);
+                               }
+                           } else {
+# If no <partorder> tag available, load and inspect imported file
+                               my $impfile=&getfile($location);
+                               @impfilepartids=($impfile=~/<part[^>]*id\s*=\s*[\"\']([^\"\']+)[\"\'][^>]*>/gs);
+                           }
                            if ($#impfilepartids>=0) {
 # This problem had parts
                                $importedpartids{$token->[2]->{'id'}}=join(',', at impfilepartids);
@@ -12124,7 +12142,6 @@
                 $metaentry{':responseorder'}=~s/^\,//;
             }
         }
-
 	$metaentry{':keys'} = join(',',keys(%metathesekeys));
 	&metadata_generate_part0(\%metathesekeys,\%metaentry,$uri);
 	$metaentry{':allpossiblekeys'}=join(',',keys(%metathesekeys));




More information about the LON-CAPA-cvs mailing list