[LON-CAPA-cvs] cvs: loncom /imspackages imsimport.pm imsimportdocs.pm imsprocessor.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 05 Aug 2004 23:21:49 -0000


This is a MIME encoded message

--raeburn1091748109
Content-Type: text/plain

raeburn		Thu Aug  5 19:21:49 2004 EDT

  Modified files:              
    /loncom/imspackages	imsimport.pm imsimportdocs.pm imsprocessor.pm 
  Log:
  Support for import of Blackboard 6 IMS exports (e.g. Concord RTT), and 'packages' within course content (Blackboard 5).
  
  
--raeburn1091748109
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040805192149.txt"

Index: loncom/imspackages/imsimport.pm
diff -u loncom/imspackages/imsimport.pm:1.6 loncom/imspackages/imsimport.pm:1.7
--- loncom/imspackages/imsimport.pm:1.6	Thu Apr  8 05:19:39 2004
+++ loncom/imspackages/imsimport.pm	Thu Aug  5 19:21:49 2004
@@ -1,3 +1,26 @@
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+
 package Apache::imsimport;
 
 use strict;
@@ -270,6 +293,7 @@
 Please choose the CMS used to create your IMS content package.  
         <select name="source">
          <option value='-1' selected="true">Please select
+         <option value='bb6'>Blackboard 6
          <option value='bb5'>Blackboard 5
          <option value='angel'>ANGEL
         </select>
@@ -376,7 +400,7 @@
         $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo);
         if ($manifest_result eq 'ok') {
             foreach my $res (sort keys %resources) {
-                if ($cms eq 'bb5') {
+                if ($cms eq 'bb5' || $cms eq 'bb6') {
                     foreach my $area (keys %{$$cmsmap{$cms}}) {
                         if ($resources{$res}{type} eq $$cmsmap{$cms}{$area}) {
                             $count{$area} ++;
@@ -642,7 +666,6 @@
     my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo);
     if ($manifest_result eq 'ok') {
         &Apache::imsprocessor::target_resources(\%resources,\%imports,\@targets);
-        my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow);
 
         my @boards = ();
         my @announcements = ();
@@ -654,10 +677,13 @@
         my %boardnum = ();
         my @topurls = ();
         my @topnames = ();
+        my @packages = ();
 
-        &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$newdir,$seqstem,\@resrcfiles);
+        &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$newdir,$seqstem,\@resrcfiles,\@packages,\%hrefs);
+
+        my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow);
    
-        &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames);
+        &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages);
 
         $r->print("<h3>Step 3: Publish your new LON-CAPA materials</h3>");
 
Index: loncom/imspackages/imsimportdocs.pm
diff -u loncom/imspackages/imsimportdocs.pm:1.6 loncom/imspackages/imsimportdocs.pm:1.7
--- loncom/imspackages/imsimportdocs.pm:1.6	Thu Apr  8 05:19:39 2004
+++ loncom/imspackages/imsimportdocs.pm	Thu Aug  5 19:21:49 2004
@@ -1,3 +1,26 @@
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+
 package Apache::imsimportdocs;
 
 use Apache::Constants qw(:common :http :methods);
@@ -210,6 +233,7 @@
         <select name="source">
          <option value='-1' selected="true">Please select
          <option value='bb5'>Blackboard 5
+         <option value='bb6'>Blackboard 6
          <option value='angel'>ANGEL
         </select>
         </font>
@@ -310,7 +334,7 @@
         $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo);
         if ($manifest_result eq 'ok') {
             foreach my $res (sort keys %resources) {
-                if ($cms eq 'bb5') {
+                if ($cms eq 'bb5' || $cms eq 'bb6') {
                     foreach my $area (keys %{$cmsmap{$cms}}) {
                         if ($resources{$res}{type} eq $cmsmap{$cms}{$area}) {
                             $count{$area} ++;
@@ -553,7 +577,6 @@
             }
         }
         &Apache::imsprocessor::target_resources(\%resources,\%imports,\@targets);
-        my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow);
 
         my @boards = ();
         my @announcements = ();
@@ -565,10 +588,13 @@
         my %boardnum = ();
         my @topurls = ();
         my @topnames = ();
+        my @packages = ();
 
-        &Apache::imsprocessor::process_resinfo($cms,'DOCS',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles);
+        &Apache::imsprocessor::process_resinfo($cms,'DOCS',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles,\@packages,\%hrefs);
+
+        my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow);
 
-        &Apache::imsprocessor::build_structure($cms,'DOCS',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames);
+        &Apache::imsprocessor::build_structure($cms,'DOCS',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages);
  
         foreach my $item (@pages) {
             my $filename = $timenow.'/pages/'.$item;
Index: loncom/imspackages/imsprocessor.pm
diff -u loncom/imspackages/imsprocessor.pm:1.9 loncom/imspackages/imsprocessor.pm:1.10
--- loncom/imspackages/imsprocessor.pm:1.9	Wed Aug  4 13:34:29 2004
+++ loncom/imspackages/imsprocessor.pm	Thu Aug  5 19:21:49 2004
@@ -1,3 +1,26 @@
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+
 package Apache::imsprocessor;
 
 use Apache::lonnet;
@@ -18,6 +41,9 @@
                 survey => 'assessment/x-bb-survey',
                 users => 'course/x-bb-user',
                 );
+
+    %{$$cmsmap{bb6}} =  %{$$cmsmap{bb5}};
+    $$cmsmap{bb6}{conference} = 'resource/x-bb-conference';
  
     %{$$cmsmap{angel}} =  (
                 board => 'BOARD',
@@ -99,6 +125,9 @@
 sub expand_zip {
     my ($tempdir,$filename) = @_;
     my $zipfile = "$tempdir/$filename";
+    if (!-e "$zipfile") {
+        return 'no zip';
+    }
     if ($filename =~ m|\.zip$|i) {
     # unzip can cause an sh launch which can pass along all of %ENV
     # which can be too large for /bin/sh to handle
@@ -120,6 +149,7 @@
 sub process_manifest {
     my ($cms,$tempdir,$resources,$items,$hrefs,$resinfo) = @_;
     my %toc = (
+              bb6 => 'organization',
               bb5 => 'tableofcontents',
               angel => 'organization',
               );
@@ -139,7 +169,7 @@
  
     if ($cms eq 'angel') {
         $$resources{'toplevel'}{type} = "FOLDER";
-    } elsif ($cms eq 'bb5') {
+    } elsif ($cms eq 'bb5' || $cms eq 'bb6') {
         $$resources{'toplevel'}{type} = 'resource/x-bb-document';
     }
 
@@ -172,9 +202,11 @@
                         $itm = $attr->{identifier};              
                         %{$$items{$itm}} = ();
                         $$items{$itm}{contentscount} = 0;
-                        if ($cms eq 'bb5') {
+                        if ($cms eq 'bb5' || $cms eq 'bb6') {
                             $$items{$itm}{resnum} = $attr->{identifierref};
-                            $$items{$itm}{title} = $attr->{title};
+                            if ($cms eq 'bb5') {
+                                $$items{$itm}{title} = $attr->{title};
+                            }
                         } elsif ($cms eq 'angel') {
                             if ($attr->{identifierref} =~ m/^res(.+)$/) {
                                 $$items{$itm}{resnum} = $1;
@@ -214,7 +246,7 @@
                             $path = $seq[0];
                         }
                         $$items{$itm}{filepath} = $path;
-                        if ($cms eq 'bb5') {
+                        if ($cms eq 'bb5' || $cms eq 'bb6') {
                             if ($$items{$itm}{filepath} eq 'Top') {
                                 $$items{$itm}{resnum} = $itm;
                                 $$resources{$$items{$itm}{resnum}}{type} = 'resource/x-bb-document';
@@ -227,7 +259,7 @@
                     }
                 } elsif ("@state" eq "manifest resources resource" ) {
                     $identifier = $attr->{identifier};
-                    if ($cms eq 'bb5') {                 
+                    if ($cms eq 'bb5' || $cms eq 'bb6') {                 
                         $$resources{$identifier}{file} = $attr->{file};
                         $$resources{$identifier}{type} = $attr->{type};
                     } elsif ($cms eq 'angel') {
@@ -238,7 +270,7 @@
                     }
                     @{$$hrefs{$identifier}} = ();
                 } elsif ("@state" eq "manifest resources resource file") {
-                    if ($cms eq 'bb5') {
+                    if ($cms eq 'bb5' || $cms eq 'bb6') {
                         push @{$$hrefs{$identifier}},$attr->{href};
                     } elsif ($cms eq 'angel') {
                         if ($attr->{href} =~ m/^_assoc\\$identifier\\(.+)$/) {
@@ -252,8 +284,8 @@
         text_h =>
             [sub {
                 my ($text) = @_;
-                if ($state[0] eq "manifest" && $state[1] eq "organizations" && $state[2] eq "organization" && $state[-1] eq "title") {
-                    if ($cms eq 'angel') {
+                if ($state[0] eq "manifest" && $state[1] eq "organizations" && $state[2] eq $toc{$cms} && $state[-1] eq "title") {
+                    if ($cms eq 'angel' || $cms eq 'bb6') {
                         $$items{$itm}{title} = $text;
                     }
                 }
@@ -311,7 +343,7 @@
         foreach my $key (sort keys %{$hrefs}) {
             foreach my $file (@{$$hrefs{$key}}) {
                 $file =~ s-\\-/-g;
-                if ( ($cms eq 'angel' && $file ne 'pg'.$key.'.htm') || ($cms eq 'bb5') ) {
+                if ( ($cms eq 'angel' && $file ne 'pg'.$key.'.htm') || ($cms eq 'bb5') || ($cms eq 'bb6') ) {
                     if (!-e "$destdir/resfiles/$key") {
                         mkdir("$destdir/resfiles/$key",0770);
                     }
@@ -329,7 +361,7 @@
                     }
                     if ($cms eq 'angel') {
                         rename("$tempdir/_assoc/$key/$file","$destdir/resfiles/$key/$file");
-                    } elsif ($cms eq 'bb5') {
+                    } elsif ($cms eq 'bb5' || $cms eq 'bb6') {
                         rename("$tempdir/$key/$file","$destdir/resfiles/$key/$file");
                     }
                 }
@@ -369,7 +401,7 @@
 }
 
 sub process_resinfo {
-    my ($cms,$context,$docroot,$destdir,$items,$resources,$boards,$announcements,$quizzes,$surveys,$groups,$messages,$timestamp,$boardnum,$resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,$total,$dirname,$seqstem,$resrcfiles) = @_;
+    my ($cms,$context,$docroot,$destdir,$items,$resources,$boards,$announcements,$quizzes,$surveys,$groups,$messages,$timestamp,$boardnum,$resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,$total,$dirname,$seqstem,$resrcfiles,$packages,$hrefs) = @_;
     my $board_id = time;
     my $board_count = 0;
     my $announce_handling = 'include';
@@ -405,12 +437,12 @@
                 %{$$resinfo{$key}} = ();
             }
         }
-    } elsif ($cms eq 'bb5') {
+    } elsif ($cms eq 'bb5' || $cms eq 'bb6') {
         foreach my $key (sort keys %{$resources}) {
             if ($$resources{$key}{type} eq "resource/x-bb-document") {
                 unless ($$items{$$resources{$key}{revitm}}{filepath} eq 'Top') {
                     %{$$resinfo{$key}} = ();
-                    &process_content($key,$context,$docroot,$destdir,\%{$$resinfo{$key}},$udom,$uname,$resrcfiles);
+                    &process_content($cms,$key,$context,$docroot,$destdir,\%{$$resinfo{$key}},$udom,$uname,$resrcfiles,$packages,$hrefs);
                 }
             } elsif ($$resources{$key}{type} eq "resource/x-bb-staffinfo") {
                 %{$$resinfo{$key}} = ();
@@ -476,7 +508,7 @@
 }
 
 sub build_structure {
-    my ($cms,$context,$destdir,$items,$resinfo,$resources,$hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,$timestamp,$total,$boards,$announcements,$quizzes,$surveys,$boardnum,$pagesfiles,$seqfiles,$topurls,$topnames) = @_;
+    my ($cms,$context,$destdir,$items,$resinfo,$resources,$hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,$timestamp,$total,$boards,$announcements,$quizzes,$surveys,$boardnum,$pagesfiles,$seqfiles,$topurls,$topnames,$packages) = @_;
     my %flag = ();
     my %count = ();
     my %pagecontents = ();
@@ -533,8 +565,8 @@
         my $curr_id = 1;
         my $resnum = $$items{$key}{resnum};
         my $type = $$resources{$resnum}{type};
-        if (($cms eq 'angel' && $type eq "FOLDER") || ($cms eq 'bb5' && $$resinfo{$resnum}{'isfolder'} eq "true") && (($type eq "resource/x-bb-document") || ($type eq "resource/x-bb-staffinfo") || ($type eq "resource/x-bb-externallink")) ) {
-            unless ($cms eq 'bb5' && $key eq 'Top') {
+        if (($cms eq 'angel' && $type eq "FOLDER") || (($cms eq 'bb5' || $cms eq 'bb6') && $$resinfo{$resnum}{'isfolder'} eq "true") && (($type eq "resource/x-bb-document") || ($type eq "resource/x-bb-staffinfo") || ($type eq "resource/x-bb-externallink")) ) {
+            unless (($cms eq 'bb5') && $key eq 'Top') {
                 $seqtext{$key} = "<map>\n";
             }
             if ($$items{$key}{contentscount} == 0) {
@@ -547,7 +579,11 @@
                 my $res = $$items{$contitem}{resnum};
                 my $type = $$resources{$res}{type};
                 my $title = $$items{$contitem}{title};
-                $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom);
+                my $packageflag = 0;
+                if (grep/^$res$/,@{$packages}) {
+                    $packageflag = 1;
+                }
+                $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag);
                 unless ($flag{$key}{page} == 1) {
                     $seqtext{$key} .= qq|<resource id="$curr_id" src="$src" title="$title" type="start"|;
                     unless ($flag{$key}{seq} || $flag{$key}{board} || $flag{$key}{file}) {
@@ -568,8 +604,12 @@
                             my $contitem = $$items{$key}{contents}[$i];
                             my $res = $$items{$contitem}{resnum};
                             my $type = $$resources{$res}{type};
-                            my $title = $$items{$contitem}{title};  
-                            $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom);
+                            my $title = $$items{$contitem}{title};
+                            my $packageflag = 0;
+                            if (grep/^$res$/,@{$packages}) {
+                                $packageflag = 1;
+                            }
+                            $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag);
                             unless ($flag{$key}{page} == 1) {
                                 $seqtext{$key} .= qq|></resource>
 <link from="$curr_id" to="$next_id" index="$curr_id"></link>
@@ -590,8 +630,11 @@
                     my $res = $$items{$contitem}{resnum};
                     my $type = $$resources{$res}{type};
                     my $title = $$items{$contitem}{title};
-
-                    $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom);
+                    my $packageflag = 0;
+                    if (grep/^$res$/,@{$packages}) {
+                        $packageflag = 1;
+                    }
+                    $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag);
                     if ($flag{$key}{page}) {
                         if ($count{$key}{seq} + $count{$key}{page} + $count{$key}{board} + $count{$key}{file} +1 == 1) {
                             $seqtext{$key} .= qq|></resource>
@@ -617,7 +660,7 @@
                     } 
                 }
             }
-            unless ($cms eq 'bb5' && $key eq 'Top') {
+            unless (($cms eq 'bb5') && $key eq 'Top') {
                 $seqtext{$key} .= "</map>\n";
                 open(LOCFILE,">$destdir/sequences/$key.sequence");
                 print LOCFILE $seqtext{$key};
@@ -631,7 +674,7 @@
     }
     $topnum += ($count{'Top'}{page} + $count{'Top'}{seq});
 
-    if ($cms eq 'bb5') {
+    if ($cms eq 'bb5' || $cms eq 'bb6') {
         if (@{$announcements} > 0) {
             &process_specials($context,'announcements',$announcements,\$topnum,$$items{'Top'}{contentscount},$destdir,$udom,$uname,$cdom,$crs,$timenow,$newdir,$timestamp,$resinfo,\$seqtext{'Top'},$pagesfiles,$seqfiles,$topurls,$topnames);
         }
@@ -662,24 +705,44 @@
     foreach my $key (sort keys %pagecontents) {
         for (my $i=0; $i<@{$pagecontents{$key}}; $i++) {
             my $filename = $destdir.'/pages/'.$key.'_'.$i.'.page';
+            my $resource = "$filestem/resfiles/$$items{$pagecontents{$key}[$i][0]}{resnum}.html";
+            my $res = $$items{$pagecontents{$key}[$i][0]}{resnum};
+            my $resource = $filestem.'/resfiles/'.$res.'.html';
+            if (grep/^$res$/,@{$packages}) {
+                $resource =  $filestem.'/resfiles/'.$res.'./index.html'; # should be entry_point
+            }
             open(PAGEFILE,">$filename");
             print PAGEFILE qq|<map>
-<resource src="$filestem/resfiles/$$items{$pagecontents{$key}[$i][0]}{resnum}.html" id="1" type="start" title="$$items{$pagecontents{$key}[$i][0]}{title}"></resource>
+<resource src="$resource" id="1" type="start" title="$$items{$pagecontents{$key}[$i][0]}{title}"></resource>
 <link to="2" index="1" from="1">\n|;
             if (@{$pagecontents{$key}[$i]} == 1) {
                 print PAGEFILE qq|<resource src="" id="2" type="finish"></resource>\n|;
             } elsif (@{$pagecontents{$key}[$i]} == 2)  {
-                print PAGEFILE qq|<resource src="$filestem/resfiles/$$items{$pagecontents{$key}[$i][1]}{resnum}.html" id="2" type="finish" title="$$items{$pagecontents{$key}[$i][1]}{title}"></resource>\n|;
+                my $res = $$items{$pagecontents{$key}[$i][1]}{resnum};
+                my $resource = $filestem.'/resfiles/'.$res.'.html';
+                if (grep/^$res$/,@{$packages}) {
+                    $resource =  $filestem.'/resfiles/'.$res.'./index.html'; # should be entry_point
+                }
+                print PAGEFILE qq|<resource src="$resource" id="2" type="finish" title="$$items{$pagecontents{$key}[$i][1]}{title}"></resource>\n|;
             } else {
                 for (my $j=1; $j<@{$pagecontents{$key}[$i]}-1; $j++) {
                     my $curr_id = $j+1;
                     my $next_id = $j+2;
-                    my $resource = $filestem.'/resfiles/'.$$items{$pagecontents{$key}[$i][$j]}{resnum}.'.html';
+                    my $res = $$items{$pagecontents{$key}[$i][$j]}{resnum};
+                    my $resource = $filestem.'/resfiles/'.$res.'.html';
+                    if (grep/^$res$/,@{$packages}) {
+                        $resource =  $filestem.'/resfiles/'.$res.'./index.html'; # entry_point
+                    }
                     print PAGEFILE qq|<resource src="$resource" id="$curr_id" title="$$items{$pagecontents{$key}[$i][$j]}{title}"></resource>
 <link to="$next_id" index="$curr_id" from="$curr_id">\n|;
                 }
                 my $final_id = @{$pagecontents{$key}[$i]};
-                print PAGEFILE qq|<resource src="$filestem/resfiles/$$items{$pagecontents{$key}[$i][-1]}{resnum}.html" id="$final_id" type="finish" title="$$items{$pagecontents{$key}[$i][-1]}{title}"></resource>\n|;
+                my $res = $$items{$pagecontents{$key}[$i][-1]}{resnum};
+                my $resource = $filestem.'/resfiles/'.$res.'.html';
+                if (grep/^$res$/,@{$packages}) {
+                    $resource =  $filestem.'/resfiles/'.$res.'./index.html'; # entry_point
+                }
+                print PAGEFILE qq|<resource src="$resource" id="$final_id" type="finish" title="$$items{$pagecontents{$key}[$i][-1]}{title}"></resource>\n|;
             }
             print PAGEFILE "</map>";
             close(PAGEFILE);
@@ -689,9 +752,9 @@
 }
 
 sub make_structure {
-    my ($cms,$key,$srcstem,$flag,$count,$timestamp,$boardnum,$hrefs,$pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom) = @_;
+    my ($cms,$key,$srcstem,$flag,$count,$timestamp,$boardnum,$hrefs,$pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag) = @_;
     my $src ='';
-    if (($cms eq 'angel' && $type eq 'FOLDER') || ($cms eq 'bb5' && ($$resinfo{$res}{'isfolder'} eq 'true')  || ($key eq 'Top')) ) {
+    if (($cms eq 'angel' && $type eq 'FOLDER') || (($cms eq 'bb5' || $cms eq 'bb6') && ($$resinfo{$res}{'isfolder'} eq 'true')  || ($key eq 'Top')) ) {
         $src = $srcstem.'/sequences/'.$contitem.'.sequence';
         $$flag{$key}{page} = 0;
         $$flag{$key}{seq} = 1;
@@ -722,13 +785,21 @@
             @{$$pagecontents{$key}[$$count{$key}{page}]} = ("$contitem");
             $$flag{$key}{seq} = 0;
         }
-    } elsif ($cms eq 'bb5') {
+    } elsif ($cms eq 'bb5' || $cms eq 'bb6') {
         if ($$flag{$key}{page}) {
             push @{$$pagecontents{$key}[$$count{$key}{page}]},$contitem;
         } else {
-            $$count{$key}{page} ++;
-            $src = $srcstem.'/pages/'.$key.'_'.$$count{$key}{page}.'.page';
-            @{$$pagecontents{$key}[$$count{$key}{page}]} = ("$contitem");
+            if ($contcount == 1) {
+                if ($packageflag) {
+                    $src = $srcstem.'/resfiles/'.$res.'/index.html'; # Needs to be entry point
+                } else {
+                    $src = $srcstem.'/resfiles/'.$res.'.html';
+                }
+            } else {
+                $$count{$key}{page} ++;
+                $src = $srcstem.'/pages/'.$key.'_'.$$count{$key}{page}.'.page';
+                @{$$pagecontents{$key}[$$count{$key}{page}]} = ("$contitem");
+            }
             $$flag{$key}{seq} = 0;
         }
     }
@@ -1932,7 +2003,7 @@
 
 # ---------------------------------------------------------------- Process Blackboard Content
 sub process_content {
-    my ($res,$context,$docroot,$destdir,$settings,$dom,$user,$resrcfiles) = @_;
+    my ($cms,$res,$context,$docroot,$destdir,$settings,$dom,$user,$resrcfiles,$packages,$hrefs) = @_;
     my $xmlfile = $docroot.'/'.$res.".dat";
     my $destresdir = $destdir;
     if ($context eq 'CSTR') {
@@ -1940,6 +2011,12 @@
     } elsif ($context eq 'DOCS') {
         $destresdir =~ s|^/home/httpd/html/userfiles|/uploaded|;
     }
+    my $filetag = '';
+    if ($cms eq 'bb5') {
+        $filetag = 'FILEREF';
+    } elsif ($cms eq 'bb6') {
+        $filetag = 'FILE';
+    }
     my $filecount = 0;
     my @allrelfiles = ();
     my @state;
@@ -1951,37 +2028,41 @@
       [sub {
         my ($tagname, $attr) = @_;
         push @state, $tagname;
-        if ("@state" eq "CONTENT MAINDATA") {
+        if ("@state" eq "CONTENT ") {
             %{$$settings{maindata}} = ();
+        } elsif ("@state" eq "CONTENT TITLECOLOR") {
+            $$settings{titlecolor} =  $attr->{value};
         } elsif ("@state" eq "CONTENT MAINDATA TEXTCOLOR") {
             $$settings{maindata}{color} = $attr->{value};
         } elsif ("@state" eq "CONTENT MAINDATA FLAGS ISHTML") {  
             $$settings{maindata}{ishtml} = $attr->{value}; 
         } elsif ("@state" eq "CONTENT MAINDATA FLAGS ISNEWLINELITERAL") {  
             $$settings{maindata}{isnewline} = $attr->{value};
+        } elsif ("@state" eq "CONTENT BODY TYPE") {
+            $$settings{maindata}{bodytype} =  $attr->{value};
         } elsif ("@state" eq "CONTENT FLAGS ISAVAILABLE" ) {
             $$settings{isavailable} = $attr->{value};
         } elsif ("@state" eq "CONTENT FLAGS ISFOLDER" ) {
             $$settings{isfolder} = $attr->{value};
         } elsif ("@state" eq "CONTENT FLAGS LAUNCHINNEWWINDOW" ) {
             $$settings{newwindow} = $attr->{value};
-        } elsif ("@state" eq "CONTENT FILES FILEREF") {
+        } elsif ("@state" eq "CONTENT FILES $filetag") {
             %{$$settings{files}[$filecount]} = ();
             %{$$settings{files}[$filecount]{registry}} = (); 
         } elsif ("@state" eq "CONTENT FILES FILEREF RELFILE" ) {
             $$settings{files}[$filecount]{'relfile'} = $attr->{value};
             push @allrelfiles, $attr->{value};
-        } elsif ("@state" eq "CONTENT FILES FILEREF MIMETYPE") {
+        } elsif ("@state" eq "CONTENT FILES $filetag MIMETYPE") {
             $$settings{files}[$filecount]{mimetype} = $attr->{value};
-        } elsif ("@state" eq "CONTENT FILES FILEREF CONTENTTYPE") {
+        } elsif ("@state" eq "CONTENT FILES $filetag CONTENTTYPE") {
             $$settings{files}[$filecount]{contenttype} = $attr->{value};
-        } elsif ("@state" eq "CONTENT FILES FILEREF FILEACTION") {
+        } elsif ("@state" eq "CONTENT FILES $filetag FILEACTION") {
             $$settings{files}[$filecount]{fileaction} = $attr->{value};
-        } elsif ("@state" eq "CONTENT FILES FILEREF PACKAGEPARENT") {
+        } elsif ("@state" eq "CONTENT FILES $filetag PACKAGEPARENT") {
             $$settings{files}[$filecount]{packageparent} = $attr->{value};
-        } elsif ("@state" eq "CONTENT FILES FILEREF LINKNAME") {
+        } elsif ("@state" eq "CONTENT FILES $filetag LINKNAME") {
             $$settings{files}[$filecount]{linkname} = $attr->{value};
-        } elsif ("@state" eq "CONTENT FILES FILEREF REGISTRY REGISTRYENTRY") {
+        } elsif ("@state" eq "CONTENT FILES $filetag REGISTRY REGISTRYENTRY") {
             my $key = $attr->{key};
             $$settings{files}[$filecount]{registry}{$key} = $attr->{value};
         }
@@ -1991,16 +2072,19 @@
         my ($text) = @_;
         if ("@state" eq "CONTENT TITLE") {
             $$settings{title} = $text;
-        } elsif ("@state" eq "CONTENT MAINDATA TEXT") {
+        } elsif ( ("@state" eq "CONTENT MAINDATA TEXT") || ("@state" eq "CONTENT BODY TEXT") ) {
             $$settings{maindata}{text} = $text;
-        }  elsif ("@state" eq "CONTENT FILES FILEREF REFTEXT") {
+        }  elsif ("@state" eq "CONTENT FILES $filetag REFTEXT") {
             $$settings{files}[$filecount]{reftext} = $text;
+        } elsif ("@state" eq "CONTENT FILES FILE NAME" ) {
+            $$settings{files}[$filecount]{'relfile'} = $text;
+            push @allrelfiles, $text;
         }
        }, "dtext"],
       end_h =>
       [sub {
         my ($tagname) = @_;
-        if ("@state" eq "CONTENT FILES FILEREF") {
+        if ("@state" eq "CONTENT FILES $filetag") {
             $filecount ++;
         }
         pop @state;
@@ -2046,10 +2130,8 @@
                     }
                 } else {
                     my $filename=$$settings{files}[$filecount]{'relfile'};
-#                  print "File is $filename\n";
                     my $newfilename="$destresdir/resfiles/$res/$$settings{files}[$filecount]{relfile}";
-#                  print "New filename is $newfilename\n";
-                    $$settings{maindata}{text} =~ s#(src|SRC|value)="$filename"#$1="$newfilename"#g;
+                    $$settings{maindata}{text} =~ s#(src|SRC|value)=("|&quot;)$filename("|&quot;)#$1="$newfilename"#g;
                 }
             } elsif ($$settings{files}[$filecount]{fileaction} eq 'link') {
                 unless (($$settings{files}[$filecount]{packageparent} ne '') && (grep/^$$settings{files}[$filecount]{packageparent}$/,@{$$settings{files}}) ) {
@@ -2062,8 +2144,28 @@
                     }
                       $linktag .= qq|>$$settings{files}[$filecount]{linkname}</a><br/>\n|;
                 }
-            } elsif ($$settings{files}[$filecount]{fileaction} eq 'package') {
-#              print "Found a package\n";
+            } elsif ( ($$settings{files}[$filecount]{fileaction} eq 'PACKAGE') || ($$settings{files}[$filecount]{fileaction} eq 'package') ) {
+               my $open_package = '';
+               if ($$settings{files}[$filecount]{'relfile'} =~ m|\.zip$|i) {
+                   $open_package = &expand_zip("$docroot/$res",$$settings{files}[$filecount]{'relfile'});
+               }
+               if ($open_package eq 'ok') {
+                   opendir(DIR,"$docroot/$res");
+                   my @dircontents = grep(!/^\./,readdir(DIR));
+                   closedir(DIR);
+                   push @{$resrcfiles}, @dircontents;
+                   @{$$hrefs{$res}} = @dircontents;
+                   push @{$packages}, $res;
+               }
+            } elsif ( ($$settings{files}[$filecount]{fileaction} eq 'BROKEN_IMAGE') && ($cms eq 'bb6') ) {
+                my $filename=$$settings{files}[$filecount]{'relfile'};
+                my $newfilename="$destresdir/resfiles/$res/$$settings{files}[$filecount]{relfile}";
+                $$settings{maindata}{text} =~ s#(src|SRC|value)=("|&quot;)$filename("|&quot;)#$1="$newfilename"#g;
+            } elsif ( ($$settings{files}[$filecount]{fileaction} eq 'LINK') && ($cms eq 'bb6') ) {
+                my $filename=$$settings{files}[$filecount]{'relfile'};
+                my $newfilename="$destresdir/resfiles/$res/$$settings{files}[$filecount]{relfile}";
+                my $filetitle = $$settings{files}[$filecount]{'linkname'};
+                $$settings{maindata}{text} = '<a href="'.$newfilename.'">'.$filetitle.'</a><br /><br />'. $$settings{maindata}{text};
             }
         }
     }
@@ -2071,36 +2173,48 @@
         $fontcol =  qq|<font color="$$settings{maindata}{textcolor}">|;
     }
     if (defined($$settings{maindata}{text})) {
+        if ($$settings{maindata}{bodytype} eq "S") {
+            $$settings{maindata}{text} =~ s#\n#<br/>#g;
+        }
         if ($$settings{maindata}{ishtml} eq "false") {
             if ($$settings{maindata}{isnewline} eq "true") {
                 $$settings{maindata}{text} =~ s#\n#<br/>#g;
             }
         } else {
-            $$settings{maindata}{text} = &HTML::Entities::decode($$settings{maindata}{text});
+#            $$settings{maindata}{text} = &HTML::Entities::decode($$settings{maindata}{text});
         }
     }
 
     open(FILE,">$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
-    print FILE qq|<html>
+    my $htmldoc = 0;
+#    if ($$settings{maindata}{text} =~ m-&lt;(html|HTML)>.+&lt;\\(html|HTML)-) {
+    if ($$settings{maindata}{text} =~ m-<(html|HTML)>-) {
+        $htmldoc = 1;
+    }
+    unless ($htmldoc) {
+        print FILE qq|<html>
 <head>
 <title>$$settings{title}</title>
 </head>
 <body bgcolor='#ffffff'>
 $fontcol
 |;
+    }
     unless ($$settings{title} eq '') { 
         print FILE qq|$$settings{title}<br/><br/>\n|;
     }
     print FILE qq|
 $$settings{maindata}{text}
 $linktag|;
-    if (defined($$settings{maindata}{textcolor})) {
-        print FILE qq|</font>|;
-    }
-    print FILE qq|
+    unless ($htmldoc) {
+        if (defined($$settings{maindata}{textcolor})) {
+            print FILE qq|</font>|;
+        }
+        print FILE qq|
   </body>
  </html>|;
+    }
     close(FILE);
 }
 
@@ -2146,7 +2260,6 @@
         my $msgcount = 0; 
                                                                                                      
         my $putresult = &Apache::lonnet::put($boardname,\%boardinfo,$cdom,$crs);
-#        print STDERR "putresult is $putresult for $boardname $cdom $crs\n";
         if ($db_handling eq 'importall') {
             foreach my $msg_id (@{$$messages{$$boards[$i]}}) {
                 $msgcount ++;

--raeburn1091748109--