version 1.158, 2004/12/23 14:00:58
|
version 1.161, 2004/12/23 17:50:42
|
Line 242 sub dumpcourse {
|
Line 242 sub dumpcourse {
|
# ------------------------------------------------------ Generate "export" button |
# ------------------------------------------------------ Generate "export" button |
|
|
sub exportbutton { |
sub exportbutton { |
|
return ''; |
return '</td><td bgcolor="#DDDDCC">'. |
return '</td><td bgcolor="#DDDDCC">'. |
'<input type="submit" name="exportcourse" value="'. |
'<input type="submit" name="exportcourse" value="'. |
&mt('Export Course to IMS').'" />'. |
&mt('Export Course to IMS').'" />'. |
Line 486 sub create_ims_store {
|
Line 487 sub create_ims_store {
|
if (!-e $$tempexport) { |
if (!-e $$tempexport) { |
mkdir($$tempexport,0700); |
mkdir($$tempexport,0700); |
} |
} |
|
if (!-e "$$tempexport/resources") { |
|
mkdir("$$tempexport/resources",0700); |
|
} |
# open manifest file |
# open manifest file |
my $manifest = '/imsmanifest.xml'; |
my $manifest = '/imsmanifest.xml'; |
my $manifestfilename = $$tempexport.$manifest; |
my $manifestfilename = $$tempexport.$manifest; |
Line 609 sub build_package {
|
Line 613 sub build_package {
|
} |
} |
my %extras = ( |
my %extras = ( |
caller => 'imsexport', |
caller => 'imsexport', |
tempexport => $tempexport, |
tempexport => $tempexport.'/resources', |
count => $count |
count => $count |
); |
); |
my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras); |
my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras); |
Line 655 sub process_content {
|
Line 659 sub process_content {
|
my $content_type; |
my $content_type; |
my $message; |
my $message; |
# find where user is author or co-author |
# find where user is author or co-author |
my %roleshash = &Apache::lonnet::get_my_roles(); |
|
my @uploads = (); |
my @uploads = (); |
if ($curRes->is_sequence()) { |
if ($curRes->is_sequence()) { |
$content_type = 'sequence'; |
$content_type = 'sequence'; |
Line 711 sub process_content {
|
Line 714 sub process_content {
|
my $canedit = 0; |
my $canedit = 0; |
if ($2 eq $ENV{'user.domain'} && $3 eq $ENV{'user.name'}) { |
if ($2 eq $ENV{'user.domain'} && $3 eq $ENV{'user.name'}) { |
$canedit= 1; |
$canedit= 1; |
} elsif (defined($roleshash{$coauth})) { |
|
if ($roleshash{$coauth} =~ /(\d+):(\d+)/) { |
|
if (($1 < time || $1 == 0) && ($2 == 0 || $2 >= time)) { |
|
$canedit = 1; |
|
} |
|
} elsif ($roleshash{$coauth} eq ':') { |
|
$canedit = 1; |
|
} |
|
} |
} |
if ($canedit) { |
if ($canedit) { |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource'); |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource'); |
Line 729 sub process_content {
|
Line 724 sub process_content {
|
if (@uploads > 0) { |
if (@uploads > 0) { |
foreach my $item (@uploads) { |
foreach my $item (@uploads) { |
my $uploadmsg = ''; |
my $uploadmsg = ''; |
&replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'uploaded'); |
&replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload'); |
if ($uploadmsg) { |
if ($uploadmsg) { |
$$copyresult .= $uploadmsg."\n"; |
$$copyresult .= $uploadmsg."\n"; |
} |
} |
Line 742 sub process_content {
|
Line 737 sub process_content {
|
|
|
sub replicate_content { |
sub replicate_content { |
my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_; |
my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_; |
my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); |
my ($map,$ind,$url); |
my $feedurl = &Apache::lonnet::clutter($url); |
if ($caller eq 'templateupload') { |
|
$url = $symb; |
|
$url =~ s#//#/#g; |
|
} else { |
|
($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); |
|
} |
my $content; |
my $content; |
my $filename; |
my $filename; |
my $repstatus; |
my $repstatus; |
Line 769 sub replicate_content {
|
Line 768 sub replicate_content {
|
&extract_media($content,$count,$tempexport,$href,'resource'); |
&extract_media($content,$count,$tempexport,$href,'resource'); |
$repstatus = 'ok'; |
$repstatus = 'ok'; |
} |
} |
} elsif ($caller eq 'noedit' || $caller eq 'uploaded') { |
} elsif ($caller eq 'noedit' || $caller eq 'uploaded' || $caller eq 'templateupload') { |
my $rtncode; |
my $rtncode; |
$repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode); |
$repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode); |
if ($repstatus eq 'ok') { |
if ($repstatus eq 'ok') { |
Line 788 sub replicate_content {
|
Line 787 sub replicate_content {
|
$$message = 'Could not open destination file for '.$filename."\n"; |
$$message = 'Could not open destination file for '.$filename."\n"; |
} |
} |
} else { |
} else { |
$$message = 'Could not determine name of file for '.$url."\n"; |
$$message = 'Could not determine name of file for '.$symb."\n"; |
} |
} |
if ($repstatus eq 'ok') { |
if ($repstatus eq 'ok') { |
$content_name = $count.'/'.$filename; |
$content_name = $count.'/'.$filename; |
Line 808 sub extract_media {
|
Line 807 sub extract_media {
|
sub store_template { |
sub store_template { |
my ($contents,$tempexport,$count,$content_type) = @_; |
my ($contents,$tempexport,$count,$content_type) = @_; |
if ($contents) { |
if ($contents) { |
my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml'; |
if ($tempexport) { |
my $storetemplate; |
if (!-e $tempexport.'/resources') { |
if ($storetemplate = Apache::File->new('>'.$destination)) { |
mkdir($tempexport.'/resources',0700); |
print $storetemplate $contents; |
} |
close($storetemplate); |
if (!-e $tempexport.'/resources/'.$count) { |
|
mkdir($tempexport.'/resources/'.$count,0700); |
|
} |
|
my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml'; |
|
my $storetemplate; |
|
if ($storetemplate = Apache::File->new('>'.$destination)) { |
|
print $storetemplate $contents; |
|
close($storetemplate); |
|
} |
|
if ($content_type eq 'external') { |
|
return $count.'/'.$content_type.'.html'; |
|
} else { |
|
return $count.'/'.$content_type.'.xml'; |
|
} |
} |
} |
return $count.'/'.$content_type.'.xml'; |
|
} |
} |
} |
} |
|
|