--- loncom/imspackages/imsimport.pm 2004/03/16 19:20:58 1.5 +++ loncom/imspackages/imsimport.pm 2005/02/21 23:47:46 1.10 @@ -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; @@ -271,7 +294,9 @@ Please choose the CMS used to create you @@ -350,6 +375,8 @@ sub display_two { $unzip_result = &Apache::imsprocessor::expand_zip($tempdir,$fname); } my %resources = (); + my %includedres = (); + my %includeditems = (); my %items = (); my %hrefs = (); my %resinfo = (); @@ -373,10 +400,10 @@ sub display_two { my $conditions; if ($unzip_result eq 'ok') { - $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo); + $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'choose',\%includedres,\%includeditems); if ($manifest_result eq 'ok') { foreach my $res (sort keys %resources) { - if ($cms eq 'bb5') { + if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webct4') { foreach my $area (keys %{$$cmsmap{$cms}}) { if ($resources{$res}{type} eq $$cmsmap{$cms}{$area}) { $count{$area} ++; @@ -588,20 +615,17 @@ sub display_three { ($cdom,$crs) = split/\//,$ENV{'form.bb_crs'}; $chome = &Apache::lonnet::homeserver($crs,$cdom); } - if ( defined($ENV{'form.bb_handling'}) ) { - $db_handling = $ENV{'form.bb_handling'}; - } my $user_crs = ''; my $user_cdom = ''; my $user_handling = ''; if ( defined($ENV{'form.user_crs'}) ) { ($user_cdom,$user_crs) = split/\//,$ENV{'form.user_crs'}; } - if ( defined($ENV{'form.user_handling'}) ) { - $user_handling = $ENV{'form.user_handling'}; - } my $seqstem = "/res/$udom/$uname/$newdir"; - my %imports = (); + my %importareas = (); + my %includedres = (); + my %includeditems = (); + my %randompicks = (); my @targets = (); my %resources = (); my %items = (); @@ -624,13 +648,13 @@ sub display_three { my $tempdir = $ENV{'form.tempdir'}; foreach my $area (@{$areas}) { - if (defined($ENV{"form.$area"}) ) { + if (defined($ENV{"form.$area"}) ) { if ($cms eq 'angel' && $area eq 'doc') { foreach (@{$$cmsmap{$cms}{$area}}) { - $imports{$_} = 1; + $importareas{$_} = 1; } } else { - $imports{$$cmsmap{$cms}{$area}} = 1; + $importareas{$$cmsmap{$cms}{$area}} = 1; } if ($area eq 'board') { $db_handling = $ENV{'form.db_handling'}; @@ -639,36 +663,59 @@ sub display_three { } } } - my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo); + + my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'prepare',\%includedres); + if ($manifest_result eq 'ok') { + foreach my $res (sort keys %resources) { + if ($importareas{$resources{$res}{type}}) { + $includedres{$res} = 1; + } + } + foreach my $itm (sort keys %items) { + &Apache::imsprocessor::get_imports(\%includeditems,\%items,\%resources,\%importareas,$itm); + } + } + + foreach my $itm (sort keys %includeditems) { + &Apache::imsprocessor::get_parents(\%includeditems,\%items,$itm); + } + + $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'build',\%includedres,\%includeditems); 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); + &Apache::imsprocessor::target_resources(\%resources,\%importareas,\@targets); my @boards = (); my @announcements = (); my @quizzes = (); my @surveys = (); + my @pools = (); my @groups = (); my %messages = (); my @timestamp = (); my %boardnum = (); my @topurls = (); my @topnames = (); + my @packages = (); + + &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@targets,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles,\@packages,\%hrefs,\@pages,\@sequences,\%randompicks); - &Apache::imsprocessor::process_resinfo($cms,$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); + my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow,\%importareas); - &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,\@targets,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems,\%randompicks); - $r->print("