[LON-CAPA-cvs] cvs: loncom /homework outputtags.pm /xml lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 03 May 2003 21:09:03 -0000


albertel		Sat May  3 17:09:03 2003 EDT

  Modified files:              
    /loncom/homework	outputtags.pm 
    /loncom/xml	lonxml.pm 
  Log:
  - implements last of BUG#1276,
  - new script space function &multipart, returns a list of parts if it is a multipart problem or undef if it isn't
  
  
Index: loncom/homework/outputtags.pm
diff -u loncom/homework/outputtags.pm:1.28 loncom/homework/outputtags.pm:1.29
--- loncom/homework/outputtags.pm:1.28	Fri May  2 15:11:12 2003
+++ loncom/homework/outputtags.pm	Sat May  3 17:09:03 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # tags that create controlled output
 #
-# $Id: outputtags.pm,v 1.28 2003/05/02 19:11:12 albertel Exp $
+# $Id: outputtags.pm,v 1.29 2003/05/03 21:09:03 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -109,6 +109,20 @@
     return @result;
 }
 
+sub multipart {
+    my ($uri)=@_;
+    if (!defined($uri)) { $uri=$ENV{'request.uri'}; }
+    my @parts;
+    my $metadata = &Apache::lonnet::metadata($uri,'packages');
+    foreach (split(/\,/,$metadata)) {
+	if ($_ =~ /^part_(.*)$/) {
+	    my $part = $1;
+	    if ($part ne '0') { push(@parts,$part); }
+	}
+    }
+    return @parts;
+}
+
 sub start_displayweight {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result;
@@ -128,16 +142,12 @@
 	    if (!defined($weight) || ($weight eq '')) { $weight=1; }
 	    $result.=$weight;
 	} else {
-	    my $metadata = &Apache::lonnet::metadata($ENV{'request.uri'},
-						     'packages');
+	    my @parts=&multipart($ENV{'request.uri'});
 	    my $weight;
-	    foreach (split(/\,/,$metadata)) {
-		if ($_ =~ /^part_(.*)$/) {
-		    my $part = $1;
-		    my $pweight=&Apache::lonnet::EXT("resource.$part.weight");
-		    if (!defined($pweight) || ($pweight eq '')) { $pweight=1; }
-		    $weight+=$pweight;
-		}
+	    foreach my $part (@parts) {
+		my $pweight=&Apache::lonnet::EXT("resource.$part.weight");
+		if (!defined($pweight) || ($pweight eq '')) { $pweight=1; }
+		$weight+=$pweight;
 	    }
 	    $result=$weight;
 	}
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.250 loncom/xml/lonxml.pm:1.251
--- loncom/xml/lonxml.pm:1.250	Fri May  2 15:57:01 2003
+++ loncom/xml/lonxml.pm	Sat May  3 17:09:03 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.250 2003/05/02 19:57:01 albertel Exp $
+# $Id: lonxml.pm,v 1.251 2003/05/03 21:09:03 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -722,6 +722,7 @@
   $safeeval->permit("sort");
   $safeeval->deny(":base_io");
   $safehole->wrap(\&Apache::scripttag::xmlparse,$safeeval,'&xmlparse');
+  $safehole->wrap(\&Apache::outputtags::multipart,$safeeval,'&multipart');
   $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
   
   $safehole->wrap(\&Math::Cephes::asin,$safeeval,'&asin');