[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Wed, 18 Sep 2002 18:47:05 -0000


sakharuk		Wed Sep 18 14:47:05 2002 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Problem with printing primary sequence containing the same resources as another sequence is resolved. I added symb to ssi and changed the main subrutine
  coming_from_hash which determine the set of file names. Now it determines the symb of any resource too. Tested on apcalc - everything is OK.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.67 loncom/interface/lonprintout.pm:1.68
--- loncom/interface/lonprintout.pm:1.67	Mon Sep 16 16:38:46 2002
+++ loncom/interface/lonprintout.pm	Wed Sep 18 14:47:04 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.67 2002/09/16 20:38:46 www Exp $
+# $Id: lonprintout.pm,v 1.68 2002/09/18 18:47:04 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -48,6 +48,7 @@
 use Apache::grades;
 use Apache::edit;
 use Apache::File();
+use Apache::lonnavmaps;
 use POSIX qw(strftime);
 use GDBM_File;
 
@@ -371,18 +372,18 @@
         #-- where is the primary sequence containing file?
 	my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});
 	$symbolic =~ m/([^_]+)_/;
-	my $primary_sequence = '/res/'.$1;
-	my @master_seq = &coming_from_hash($primary_sequence); 
+	my $primary_sequence = '/res/'.$1;    
+	my @master_seq = &coming_from_hash($primary_sequence);
         #-- produce an output string
 	for (my $i=0;$i<=$#master_seq;$i++) {
-            my $urlp = $master_seq[$i];		
+            my ($urlp,$symb) = split /&&/, $master_seq[$i];		
 	    if ($choice eq 'Standard LaTeX output for the primary sequence') {
 		$selectionmade = 2;
  		if ($urlp =~ m/\.(problem|exam|quiz|assess|survey|form|library)/) {
 		    my %moreenv;
 		    $moreenv{'form.grade_target'}='tex';
 		    &Apache::lonnet::appenv(%moreenv);
-		    my $texversion=&Apache::lonnet::ssi($urlp);
+		    my $texversion=&Apache::lonnet::ssi($urlp,('symb'=>$symb));
 		    &Apache::lonnet::delenv('form.grade_target');
 		    $result .= $texversion;        
 		}
@@ -556,25 +557,83 @@
 
     my $mainsequence = shift;
     my @resourcelist = ();
+    my $mapid = $hash{'map_pc_'.$mainsequence};
     my $mapstart = $hash{'map_start_'.$mainsequence};
     my $mapfinish = $hash{'map_finish_'.$mainsequence};
+    my $symb = &Apache::lonnet::symbread($hash{'src_'.$mapstart});
+    $symb = m/^([^___]*)___/;
+    my $presymb = $1.'___'; 
     my $current_resource = $mapstart;
     while ($current_resource ne $mapfinish) {
 	if (not $hash{'src_'.$current_resource}=~/\.sequence$/) {
-	    push @resourcelist,$hash{'src_'.$current_resource};
+	    my $rid = $hash{'ids_'.$hash{'src_'.$current_resource}};
+            if ($rid=~/,/) {
+		my @rid = split /,/, $rid;
+		foreach my $rid_element (@rid) {
+		    if ($rid_element =~ m/^$mapid\.(\d*)/) {
+			$rid = $1; 
+			last;
+		    }
+		}
+	    } else {
+		$rid =~ m/^$mapid\.(\d*)/;
+                $rid = $1;  
+	    }
+	    $hash{'src_'.$current_resource} =~ m/\/res\/(.*)$/;
+	    $symb = $presymb.$rid.'___'.$1;
+	    push @resourcelist,$hash{'src_'.$current_resource}.'&&'.$symb;
 	} else {
 	    push @resourcelist,&coming_from_hash($hash{'src_'.$current_resource});
 	}
 	$current_resource = $hash{'goesto_'.$hash{'to_'.$current_resource}};
     }
-    #needs if final resource in the map (type=finish) contains something
+    #needs if final resource in the map (type="finish") contains something
     if (not $hash{'src_'.$current_resource}=~/\.sequence$/) {
-	push @resourcelist,$hash{'src_'.$current_resource};
+		    my $rid = $hash{'ids_'.$hash{'src_'.$current_resource}};
+            if ($rid=~/,/) {
+		my @rid = split /,/, $rid;
+		foreach my $rid_element (@rid) {
+		    if ($rid_element =~ m/^$mapid\.(\d*)/) {
+			$rid = $1; 
+			last;
+		    }
+		}
+	    } else {
+		$rid =~ m/^$mapid\.(\d*)/;
+                $rid = $1;  
+	    }
+	    $hash{'src_'.$current_resource} =~ m/\/res\/(.*)$/;
+	    $symb = $presymb.$rid.'___'.$1;
+	push @resourcelist,$hash{'src_'.$current_resource}.'&&'.$symb;
     } else {
 	push @resourcelist,&coming_from_hash($hash{'src_'.$current_resource});
     }
     return @resourcelist;
 }
+#sub coming_from_hash {
+#
+#    my $mainsequence = shift;
+#    my @resourcelist = ();
+#    my $mapid = $hash{'map_pc_'.$mainsequence};
+#    my $mapstart = $hash{'map_start_'.$mainsequence};
+#    my $mapfinish = $hash{'map_finish_'.$mainsequence};
+#    my $current_resource = $mapstart;
+#    while ($current_resource ne $mapfinish) {
+#	if (not $hash{'src_'.$current_resource}=~/\.sequence$/) {
+#	    push @resourcelist,$hash{'src_'.$current_resource};
+#	} else {
+#	    push @resourcelist,&coming_from_hash($hash{'src_'.$current_resource});
+#	}
+#	$current_resource = $hash{'goesto_'.$hash{'to_'.$current_resource}};
+#    }
+#    #needs if final resource in the map (type="finish") contains something
+#    if (not $hash{'src_'.$current_resource}=~/\.sequence$/) {
+#	push @resourcelist,$hash{'src_'.$current_resource};
+#    } else {
+#	push @resourcelist,&coming_from_hash($hash{'src_'.$current_resource});
+#    }
+#    return @resourcelist;
+#}
 
 
 sub character_chart {
@@ -916,6 +975,8 @@
     }
     return $result;
 }
+
+
 sub page_cleanup {
     my $result = shift;