--- loncom/interface/londocs.pm 2004/12/15 15:21:43 1.157 +++ loncom/interface/londocs.pm 2004/12/23 14:00:58 1.158 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.157 2004/12/15 15:21:43 raeburn Exp $ +# $Id: londocs.pm,v 1.158 2004/12/23 14:00:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,6 +30,7 @@ package Apache::londocs; use strict; use Apache::Constants qw(:common :http); +use Apache::imsexport; use Apache::lonnet; use Apache::loncommon; use Apache::lonratedt; @@ -319,7 +320,7 @@ sub exportcourse { } $r->print('Export Course'. - &Apache::loncommon::bodytag('Export course to IMS or SCORM content package')); + &Apache::loncommon::bodytag('Export course to IMS content package')); $r->print($outcome); $r->print(''); } else { @@ -368,6 +369,12 @@ sub exportcourse { } if (ref($curRes)) { my $symb = $curRes->symb(); + my $ressymb = $symb; + if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { + unless ($ressymb =~ m|adm/wrapper/adm|) { + $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; + } + } my $color = $count%2; $display .=''."\n". 'title().''; - if ($discussiontime{$symb} > 0) { + if ($discussiontime{$ressymb} > 0) { $boards ++; $currelem = $count+$boards+$startcount; $display .= '  '."\n"; @@ -402,13 +409,23 @@ sub exportcourse { |; $r->print('Export Course'.$scripttag.''. - &Apache::loncommon::bodytag('Export course to IMS or SCORM content package' + &Apache::loncommon::bodytag('Export course to IMS content package' )); $r->print($display.''. @@ -482,7 +499,7 @@ 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". -' '."\n". +' '."\n". ' '."\n". ' '.$ENV{'request.'.$ENV{'request.course.id'}.'.description'}.'' @@ -581,6 +598,22 @@ sub build_package { $imsresources .= ' '."\n"; } + if (grep/^$count$/,@$discussions) { + my $ressymb = $symb; + my $mode; + if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { + unless ($ressymb =~ m|adm/wrapper/adm|) { + $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; + } + $mode = 'board'; + } + my %extras = ( + caller => 'imsexport', + tempexport => $tempexport, + count => $count + ); + my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras); + } $imsresources .= ' '."\n"; } } @@ -623,24 +656,52 @@ sub process_content { my $message; # find where user is author or co-author my %roleshash = &Apache::lonnet::get_my_roles(); + my @uploads = (); if ($curRes->is_sequence()) { $content_type = 'sequence'; } elsif ($curRes->is_page()) { $content_type = 'page'; # need to handle individual items in pages. } elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) { $content_type = 'syllabus'; + my $contents = &Apache::imsexport::templatedpage($content_type); + if ($contents) { + $$content_file = &store_template($contents,$tempexport,$count,$content_type); + } } elsif ($symb =~ m-\.sequence___\d+___ext-) { $content_type = 'external'; + my $title = $curRes->title; + my $contents = &Apache::imsexport::external($symb,$title); + if ($contents) { + $$content_file = &store_template($contents,$tempexport,$count,$content_type); + } } elsif ($symb =~ m-adm/navmaps$-) { $content_type = 'navmap'; - } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/smppg$-) { + } elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) { $content_type = 'simplepage'; - } elsif ($symb =~ m-/lib/templates/simpleproblem\.problem$-) { + my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads); + if ($contents) { + $$content_file = &store_template($contents,$tempexport,$count,$content_type); + } + } elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) { $content_type = 'simpleproblem'; - } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/bulletinboard$-) { + my $contents = &Apache::imsexport::simpleproblem($symb); + if ($contents) { + $$content_file = &store_template($contents,$tempexport,$count,$content_type); + } + } elsif ($symb =~ m-lib/templates/examupload\.problem-m) { + $content_type = 'examupload'; + } elsif ($symb =~ m-adm/(\w+)/(\w+)/(\d+)/bulletinboard$-) { $content_type = 'bulletinboard'; - } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/aboutme$-) { + my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2); + if ($contents) { + $$content_file = &store_template($contents,$tempexport,$count,$content_type); + } + } elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) { $content_type = 'aboutme'; + my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2); + if ($contents) { + $$content_file = &store_template($contents,$tempexport,$count,$content_type); + } } elsif ($symb =~ m-uploaded/$cdom/$cnum-) { $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded'); } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) { @@ -665,6 +726,15 @@ sub process_content { $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit'); } } + if (@uploads > 0) { + foreach my $item (@uploads) { + my $uploadmsg = ''; + &replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'uploaded'); + if ($uploadmsg) { + $$copyresult .= $uploadmsg."\n"; + } + } + } if ($message) { $$copyresult .= $message."\n"; } @@ -735,6 +805,19 @@ sub extract_media { return; } +sub store_template { + my ($contents,$tempexport,$count,$content_type) = @_; + if ($contents) { + my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml'; + my $storetemplate; + if ($storetemplate = Apache::File->new('>'.$destination)) { + print $storetemplate $contents; + close($storetemplate); + } + return $count.'/'.$content_type.'.xml'; + } +} + # Imports the given (name, url) resources into the course # coursenum, coursedom, and folder must precede the list sub group_import {