--- loncom/imspackages/imsimportdocs.pm 2009/08/17 03:52:09 1.23 +++ 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.23 2009/08/17 03:52:09 raeburn 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); @@ -207,96 +215,38 @@ sub display_one { my ($r) = @_; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder']); - $r->print(< - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  -
1  -    - Specify the Course Management system used to create the package.   - -
 
  - -Please choose the CMS used to create your IMS content package.   - - -
 
 
2  -    - Locate the IMS content package you wish to upload.   - -
 
  - - - -
 
 If you have selected the CMS, and located the IMS package, you should click the 'Upload IMS package' button to upload the file to the server.
 
- - - - -
- - - -
-
- - - - -ENDBLOCK + $r->print( + '
' + .&Apache::lonhtmlcommon::topic_bar( + 1,&mt('Specify the Course Management system used to create the package')) + .&mt('Please choose the CMS used to create your IMS content package:').' ' + .'' + ); + $r->print( + &Apache::lonhtmlcommon::topic_bar( + 2,&mt('Locate the IMS content package you wish to upload')) + .'' + .'' + .&mt('File:') + .' ' + ); + $r->print( + '
' + .'

' + .'' + .' ' + .'' + .'

' + ); } @@ -336,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(< @@ -442,7 +421,7 @@ ENDBLOCK @@ -481,7 +460,7 @@ ENDBLOCK
4    - Choose display options for listing of contents of top level of package. + Choose display options for listing of contents of top level of package
- + @@ -495,12 +474,6 @@ ENDBLOCK
ENDDOCUMENT - } else { - $r->print("Unpacking of your IMS package failed because an IMS manifest file was not located in the package\n"); - } - } else { - $r->print("Processing of your IMS package failed because the file you uploaded could not be unzipped\n"); - } }