--- loncom/interface/londocs.pm 2005/07/26 13:30:34 1.197
+++ loncom/interface/londocs.pm 2005/09/20 07:52:03 1.206
@@ -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.206 2005/09/20 07:52:03 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -166,7 +166,10 @@ sub dumpcourse {
$crs=~s/\_/\//g;
foreach (keys %replacehash) {
my $newfilename=$title.'/'.$replacehash{$_};
+ $newfilename=~s/\.(\w+)$//;
+ my $ext=$1;
$newfilename=&clean($newfilename);
+ $newfilename.='.'.$ext;
my @dirs=split(/\//,$newfilename);
my $path='/home/'.$ca.'/public_html';
my $makepath=$path;
@@ -252,7 +255,7 @@ sub exportbutton {
return '
'.
''.
- &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
+ &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
}
sub exportcourse {
@@ -490,10 +493,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 +555,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 +577,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 +625,6 @@ sub build_package {
}
}
$pkgdepth = $depth;
- } else {
- $included = 0;
}
}
}
@@ -645,7 +659,6 @@ sub process_content {
my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
my $content_type;
my $message;
-# find where user is author or co-author
my @uploads = ();
if ($curRes->is_sequence()) {
$content_type = 'sequence';
@@ -699,6 +712,7 @@ sub process_content {
if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) {
$canedit= 1;
}
+# only include problem code where current user is author
if ($canedit) {
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
} else {
@@ -782,16 +796,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 +830,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 +853,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 +861,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 +889,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';
}
}
}
@@ -1093,7 +1114,7 @@ sub editor {
if ($cmd eq 'del') {
my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
- ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library)$/)) {
+ ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
&Apache::lonnet::removeuploadedurl($url);
} else {
&Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]);
|