--- loncom/imspackages/imsimportdocs.pm 2009/11/06 17:16:53 1.24 +++ loncom/imspackages/imsimportdocs.pm 2009/11/20 11:16:59 1.25 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: imsimportdocs.pm,v 1.24 2009/11/06 17:16:53 bisitz Exp $ +# $Id: imsimportdocs.pm,v 1.25 2009/11/20 11:16:59 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -165,9 +165,15 @@ sub handler { my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); unless ($allowed) { $r->print(&Apache::loncommon::start_page('Import IMS package',undef, - {'only_body' => 1,})); - $r->print('

'.&mt('Modification of Course Contents Disallowed').'

'.&mt('Your current role does not grant you the right to modify course content in this course.'). - &Apache::loncommon::end_page()); + {'only_body' => 1,})); + $r->print( + '

' + .&mt('Modification of Course Contents Disallowed') + .'

' + .&mt('Your current role does not grant you the right to modify course content in this course.') + .'

' + .&Apache::loncommon::end_page() + ); return OK; } @@ -183,11 +189,13 @@ sub handler { } $javascript = - "\n"; - my $start_page = &Apache::loncommon::start_page('Import IMS package', - $javascript, - {'only_body' => 1,}); + "\n"; + my $headline = 'Import IMS package'; + my $start_page = &Apache::loncommon::start_page($headline, + $javascript, + {'only_body' => 1,}) + .'

'.&mt($headline).'

'; # print screen $r->print($start_page); @@ -278,28 +286,57 @@ sub display_two { users => 0, ); - if ($unzip_result eq 'ok') { - $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' || $cms eq 'bb6' || $cms eq 'webctce4') { - foreach my $area (keys %{$cmsmap{$cms}}) { - if ($resources{$res}{type} eq $cmsmap{$cms}{$area}) { - $count{$area} ++; - } - } - } elsif ($cms eq 'angel5') { - foreach my $area (keys %{$cmsmap{$cms}}) { - if ($area eq 'doc') { - if (grep/^$resources{$res}{type}$/,@{$cmsmap{$cms}{doc}}) { - $count{$area} ++; - } - } elsif ($resources{$res}{type} eq $cmsmap{$cms}{$area}) { - $count{$area} ++; - } + if ($unzip_result ne 'ok') { + $r->print( + '

' + .&mt('Processing of your IMS package failed because the file you' + .' uploaded could not be unzipped.') + .'

' + ); + return(); + } + + # Get manifest file from package + $manifest_result = &Apache::imsprocessor::process_manifest( + $cms,$tempdir,\%resources,\%items,\%hrefs, + \%resinfo,'choose',\%includedres,\%includeditems); + if ($manifest_result ne 'ok') { + $r->print( + '

' + .&mt('Unpacking of your IMS package failed because an IMS manifest file was not located in the package.') + .'

' + ); + return(); + } + + # Count areas depending on cms version + foreach my $res (sort keys %resources) { + if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webctce4') { + foreach my $area (keys %{$cmsmap{$cms}}) { + if ($resources{$res}{type} eq $cmsmap{$cms}{$area}) { + $count{$area} ++; + } + } + } elsif ($cms eq 'angel5') { + foreach my $area (keys %{$cmsmap{$cms}}) { + if ($area eq 'doc') { + if (grep/^$resources{$res}{type}$/,@{$cmsmap{$cms}{doc}}) { + $count{$area} ++; } + } elsif ($resources{$res}{type} eq $cmsmap{$cms}{$area}) { + $count{$area} ++; } } + } else { # Unknown cms format + $r->print( + '' + .&mt('Unsupported IMS format: [_1]',$cms) + .'
' + ); + # return(); + } + } + $r->print(< @@ -437,21 +474,6 @@ ENDBLOCK
ENDDOCUMENT - } else { - $r->print( - '

' - .&mt('Unpacking of your IMS package failed because an IMS manifest file was not located in the package.') - .'

' - ); - } - } else { - $r->print( - '

' - .&mt('Processing of your IMS package failed because the file you' - .' uploaded could not be unzipped.') - .'

' - ); - } }