--- loncom/interface/londocs.pm 2005/07/26 13:30:34 1.197 +++ loncom/interface/londocs.pm 2005/07/26 22:30:20 1.199 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.197 2005/07/26 13:30:34 raeburn Exp $ +# $Id: londocs.pm,v 1.199 2005/07/26 22:30:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -490,10 +490,21 @@ sub create_ims_store { ' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'. ' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'. ' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n". +' + + + + '.$env{'request.course.id'}.' + + '.$env{'course.'.$env{'request.course.id'}.'.description'}.' + + + + '."\n". ' '."\n". ' '."\n". -' '.$env{'request.'.$env{'request.course.id'}.'.description'}.'' +' '.$env{'course.'.$env{'request.course.id'}.'.description'}.'' } else { $$outcome .= 'An error occurred opening the IMS manifest file.
' ; @@ -541,7 +552,6 @@ sub build_package { $count = 0; my $imsresources; my $pkgdepth; - my $included = 0; while ($curRes = $it->next()) { if ($curRes == $it->BEGIN_MAP()) { $prevdepth = $depth; @@ -564,10 +574,13 @@ sub build_package { unless ($curRes->is_sequence()) { $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"'; } - if (($depth <= $prevdepth) && ($count > 1) && ($included)) { - print $ims_manifest "\n".' '."\n"; + my $step = $prevdepth - $depth; + if (($step >= 0) && ($count > 1)) { + while ($step >= 0) { + print $ims_manifest "\n".' '."\n"; + $step --; + } } - $included = 1; $prevdepth = $depth; my $itementry = @@ -609,8 +622,6 @@ sub build_package { } } $pkgdepth = $depth; - } else { - $included = 0; } } } @@ -782,16 +793,23 @@ sub replicate_content { $$message = 'Could not determine name of file for '.$symb."
\n"; } if ($repstatus eq 'ok') { - $content_name = $count.'/'.$filename; + $content_name = 'resources/'.$count.'/'.$filename; } return $content_name; } sub extract_media { my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_; + my ($dirpath,$container); my %allfiles = (); my %codebase = (); - $url =~ s#([^/]+)$##; + if ($url =~ m-(.*/)([^/]+)$-) { + $dirpath = $1; + $container = $2; + } else { + $dirpath = $url; + $container = ''; + } &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content); foreach my $embed_file (keys(%allfiles)) { my $filename; @@ -809,7 +827,7 @@ sub extract_media { if ($embed_file =~ m-https?://-) { next; # points to url } else { - $embed_url = $url.$embed_file; # points to relative path + $embed_url = $dirpath.$embed_file; # points to relative path } } if ($caller eq 'resource') { @@ -832,7 +850,7 @@ sub extract_media { my $copiedfile; if ($copiedfile = Apache::File->new('>'.$destination)) { print $copiedfile $embed_content; - push @{$href}, .'resources/'.$count.'/res/'.$filename; + push @{$href}, 'resources/'.$count.'/res/'.$filename; my $attrib_regexp = ''; if (@{$allfiles{$embed_file}} > 1) { $attrib_regexp = join('|',@{$allfiles{$embed_file}}); @@ -840,7 +858,7 @@ sub extract_media { $attrib_regexp = $allfiles{$embed_file}[0]; } $$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi; - if ($caller eq 'resource' && $url =~ /\.(problem|library)$/) { + if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) { $$content =~ s#\Q$embed_file\E#$newname#gi; } } @@ -868,9 +886,9 @@ sub store_template { close($storetemplate); } if ($content_type eq 'external') { - return $count.'/'.$content_type.'.html'; + return 'resources/'.$count.'/'.$content_type.'.html'; } else { - return $count.'/'.$content_type.'.xml'; + return 'resources/'.$count.'/'.$content_type.'.xml'; } } }