version 1.5, 2004/03/21 20:44:58
|
version 1.10, 2005/02/16 20:24:15
|
Line 1
|
Line 1
|
|
# 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; |
package Apache::imsimportdocs; |
|
|
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
Line 135 sub handler {
|
Line 158 sub handler {
|
my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'}); |
my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'}); |
unless ($allowed) { |
unless ($allowed) { |
$r->print("<html><head><title>The LearningOnline Network with CAPA</title></head>"); |
$r->print("<html><head><title>The LearningOnline Network with CAPA</title></head>"); |
$r->print(&Apache::loncommon::bodytag('Import IMS package')); |
$r->print(&Apache::loncommon::bodytag('Import IMS package',undef,'',1)); |
$r->print('<h3>'.&mt('Modification of Course Contents Disallowed').'</h3>'.&mt('Your current role does not grant you the right to modify course content in this course.').'</body></html>'); |
$r->print('<h3>'.&mt('Modification of Course Contents Disallowed').'</h3>'.&mt('Your current role does not grant you the right to modify course content in this course.').'</body></html>'); |
return OK; |
return OK; |
} |
} |
Line 164 $javascript
|
Line 187 $javascript
|
</head> |
</head> |
ENDHEAD |
ENDHEAD |
# -------------------------------------------------------------------- Body tag |
# -------------------------------------------------------------------- Body tag |
$r->print(&Apache::loncommon::bodytag('Import IMS package')); |
$r->print(&Apache::loncommon::bodytag('Import IMS package',undef,'',1)); |
if ($ENV{'form.phase'} eq 'one') { |
if ($ENV{'form.phase'} eq 'one') { |
&display_one($r); |
&display_one($r); |
} elsif ($ENV{'form.phase'} eq 'two') { |
} elsif ($ENV{'form.phase'} eq 'two') { |
Line 210 Please choose the CMS used to create you
|
Line 233 Please choose the CMS used to create you
|
<select name="source"> |
<select name="source"> |
<option value='-1' selected="true">Please select |
<option value='-1' selected="true">Please select |
<option value='bb5'>Blackboard 5 |
<option value='bb5'>Blackboard 5 |
|
<option value='bb6'>Blackboard 6 |
<option value='angel'>ANGEL |
<option value='angel'>ANGEL |
</select> |
</select> |
</font> |
</font> |
Line 285 sub display_two {
|
Line 309 sub display_two {
|
$unzip_result = &Apache::imsprocessor::expand_zip($tempdir,$fname); |
$unzip_result = &Apache::imsprocessor::expand_zip($tempdir,$fname); |
} |
} |
my %resources = (); |
my %resources = (); |
|
my %includedres = (); |
|
my %includeditems = (); |
my %items = (); |
my %items = (); |
my %hrefs = (); |
my %hrefs = (); |
my %resinfo = (); |
my %resinfo = (); |
Line 307 sub display_two {
|
Line 333 sub display_two {
|
); |
); |
|
|
if ($unzip_result eq 'ok') { |
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') { |
if ($manifest_result eq 'ok') { |
foreach my $res (sort keys %resources) { |
foreach my $res (sort keys %resources) { |
if ($cms eq 'bb5') { |
if ($cms eq 'bb5' || $cms eq 'bb6') { |
foreach my $area (keys %{$cmsmap{$cms}}) { |
foreach my $area (keys %{$cmsmap{$cms}}) { |
if ($resources{$res}{type} eq $cmsmap{$cms}{$area}) { |
if ($resources{$res}{type} eq $cmsmap{$cms}{$area}) { |
$count{$area} ++; |
$count{$area} ++; |
Line 483 sub display_three {
|
Line 509 sub display_three {
|
if ($crs =~ m/^(\d)(\d)(\d)/) { |
if ($crs =~ m/^(\d)(\d)(\d)/) { |
$longcrs = $1.'/'.$2.'/'.$3.'/'.$crs; |
$longcrs = $1.'/'.$2.'/'.$3.'/'.$crs; |
} |
} |
my %imports = (); |
my %importareas = (); |
|
my %includedres = (); |
|
my %includeditems = (); |
my @targets = (); |
my @targets = (); |
my %resources = (); |
my %resources = (); |
my %items = (); |
my %items = (); |
Line 505 sub display_three {
|
Line 533 sub display_three {
|
my $timenow = time; |
my $timenow = time; |
|
|
my $destdir = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$cdom.'/'.$crs.'/'.$timenow; |
my $destdir = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$cdom.'/'.$crs.'/'.$timenow; |
my $dirname = $cdom.'/'.$crs.'/'.$timenow; |
|
my $seqstem = "/uploaded/$cdom/$crs/$timenow"; |
my $seqstem = "/uploaded/$cdom/$crs/$timenow"; |
my $db_handling = ''; |
my $db_handling = ''; |
my $user_handling = ''; |
my $user_handling = ''; |
Line 519 sub display_three {
|
Line 546 sub display_three {
|
if (defined($ENV{'form.foldername'}) ) { |
if (defined($ENV{'form.foldername'}) ) { |
$foldername = $ENV{'form.foldername'}; |
$foldername = $ENV{'form.foldername'}; |
} |
} |
|
|
foreach my $area (@{$areas}) { |
foreach my $area (@{$areas}) { |
if (defined($ENV{"form.$area"}) ) { |
if (defined($ENV{"form.$area"}) && ($ENV{'form.'.$area} ne '')) { |
if ($cms eq 'angel' && $area eq 'doc') { |
if ($cms eq 'angel' && $area eq 'doc') { |
foreach (@{$cmsmap{$cms}{$area}}) { |
foreach (@{$cmsmap{$cms}{$area}}) { |
$imports{$_} = 1; |
$importareas{$_} = 1; |
} |
} |
} else { |
} else { |
$imports{$cmsmap{$cms}{$area}} = 1; |
$importareas{$cmsmap{$cms}{$area}} = 1; |
} |
} |
if ($area eq 'board') { |
if ($area eq 'board') { |
$db_handling = $ENV{'form.db_handling'}; |
$db_handling = $ENV{'form.db_handling'}; |
Line 536 sub display_three {
|
Line 563 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,\%includeditems); |
if ($manifest_result eq 'ok') { |
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') { |
|
|
my @path = ($cdom,$crs,$timenow); |
my @path = ($cdom,$crs,$timenow); |
my $fullpath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles'; |
my $fullpath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles'; |
foreach my $item (@path) { |
foreach my $item (@path) { |
Line 553 sub display_three {
|
Line 596 sub display_three {
|
mkdir("$fullpath/$name",0770); |
mkdir("$fullpath/$name",0770); |
} |
} |
} |
} |
&Apache::imsprocessor::target_resources(\%resources,\%imports,\@targets); |
&Apache::imsprocessor::target_resources(\%resources,\%importareas,\@targets); |
my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow); |
|
|
|
my @boards = (); |
my @boards = (); |
my @announcements = (); |
my @announcements = (); |
my @quizzes = (); |
my @quizzes = (); |
my @surveys = (); |
my @surveys = (); |
|
my @pools = (); |
my @groups = (); |
my @groups = (); |
my %messages = (); |
my %messages = (); |
my @timestamp = (); |
my @timestamp = (); |
my %boardnum = (); |
my %boardnum = (); |
my @topurls = (); |
my @topurls = (); |
my @topnames = (); |
my @topnames = (); |
|
my @packages = (); |
|
|
|
&Apache::imsprocessor::process_resinfo($cms,'DOCS',$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); |
|
|
&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,$dirname,$seqstem,\@resrcfiles); |
my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow,\%importareas); |
|
|
&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,\@targets,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems); |
|
|
foreach my $item (@pages) { |
foreach my $item (@pages) { |
my $filename = $timenow.'/pages/'.$item; |
my $filename = $timenow.'/pages/'.$item; |
Line 605 sub display_three {
|
Line 651 sub display_three {
|
$Apache::lonratedt::order[0]=1; |
$Apache::lonratedt::order[0]=1; |
$Apache::lonratedt::resources[1]=''; |
$Apache::lonratedt::resources[1]=''; |
} |
} |
my ($errtext,$fatal)=&Apache::londocs::group_import($crs, $cdom, $folder,@imports); |
my ($errtext,$fatal)=&Apache::londocs::group_import($crs,$cdom,$folder,'sequence','imsimport',@imports); |
if ($fatal) { |
if ($fatal) { |
print STDERR "Fatal error during group_import\n"; |
print STDERR "Fatal error during group_import\n"; |
} |
} |
Line 645 ENDBLOCK
|
Line 691 ENDBLOCK
|
<input type="button" value="|; |
<input type="button" value="|; |
$initblock .= &mt('re-initializing course'); |
$initblock .= &mt('re-initializing course'); |
$initblock .= qq|" onClick="javascript:init(this.form)"/>|; |
$initblock .= qq|" onClick="javascript:init(this.form)"/>|; |
$initblock .= &mt('or the next time you log in.'); |
$initblock .= ', '.&mt('or the next time you log in.'); |
$initblock .= qq|</font></h3></form>|; |
$initblock .= qq|</font></h3></form>|; |
$r->print($initblock); |
$r->print($initblock); |
$r->print(<<ENDBLOCKTWO); |
$r->print(<<ENDBLOCKTWO); |