--- loncom/imspackages/imsimportdocs.pm 2009/08/17 03:52:09 1.23 +++ loncom/imspackages/imsimportdocs.pm 2009/11/20 16:20:17 1.27 @@ -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.27 2009/11/20 16:20:17 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( + '
' + .'

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

' + ); } @@ -319,10 +269,7 @@ sub display_two { my %hrefs = (); my %resinfo = (); my %count = (); - my @bgcolors = ("#eeeeee","#dddddd"); - my $counter = 0; - my $iter = 0; my %count = ( announce => 0, board => 0, @@ -336,171 +283,170 @@ 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} ++; } } - $r->print(< - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  -
3 -    - Choose which content types you wish to import -
 
  - - - - -
- - - - -
- - - - - - -ENDBLOCK - foreach my $area (@{$areasref}) { - if ($count{$area} > 0) { - my $count_tag = 'flag_'.$counter; - $r->print(" - - "); - if ($area eq 'board') { - $r->print(" "); - } elsif ($area eq 'users') { - $r->print(" "); - } else { - $r->print(" "); + } elsif ($cms eq 'angel5') { + foreach my $area (keys %{$cmsmap{$cms}}) { + if ($area eq 'doc') { + if (grep/^$resources{$res}{type}$/,@{$cmsmap{$cms}{doc}}) { + $count{$area} ++; } - $counter ++; - $iter = $counter%2; + } elsif ($resources{$res}{type} eq $cmsmap{$cms}{$area}) { + $count{$area} ++; } } - $r->print(< -
Import?Content typeAdditional options
print(qq|onClick='javascript:setOptions("$area","$counter")'|); - } - $r->print("/>  $$areaname{$area}   - $count{$area} item(s)   - -    - - -   None
-
-
-
 

4 -    - Choose display options for listing of contents of top level of package. -
 
  - - - - - - - -
   
-
 
 Once you have checked the checkboxes for all areas you wish to import from the IMS package, selected options (if available), and selected a display option for the package contents you should click the 'Complete Import' button.
  - - - - -
- - - - - -
- - - -
-
-
-ENDDOCUMENT + } else { # Unknown cms format + $r->print( + '' + .&mt('Unsupported IMS format: [_1]',$cms) + .'
' + ); + # return(); + } + } + + + # Start output: Step 3 and step 4 + + $r->print( + '' + .&Apache::lonhtmlcommon::topic_bar( + 3,&mt('Choose which content types you wish to import')) + .'

' + .&mt('Check the checkboxes for all areas you wish to import from the IMS package:') + .'

' + ); + + $r->print( + &Apache::loncommon::start_data_table() + .&Apache::loncommon::start_data_table_header_row() + .''.&mt('Import?').'' + .''.&mt('Content type').'' + .''.&mt('Additional options').'' + .&Apache::loncommon::end_data_table_header_row() + ); + + # Display import row for each area/content type + foreach my $area (@{$areasref}) { + unless ($count{$area} > 0) { next }; + + my $count_tag = 'flag_'.$counter; + + # Checkbox: Import? + $r->print( + &Apache::loncommon::start_data_table_row() + .'print(qq| onclick='javascript:setOptions("$area","$counter")'|); + } + + $r->print(' />'); + + # Content Type + $r->print( + '' + .$$areaname{$area}.'   - ' + .&mt('[quant,_1,item]',$count{$area}) + .'' + ); + + # Additional Options + $r->print(''); + if ($area eq 'board') { + $r->print( + '' + ); + } elsif ($area eq 'users') { + $r->print( + '' + ); } else { - $r->print("Unpacking of your IMS package failed because an IMS manifest file was not located in the package\n"); + $r->print( + &mt('None') + .'' + ); } - } else { - $r->print("Processing of your IMS package failed because the file you uploaded could not be unzipped\n"); + $r->print(''); + + $r->print(&Apache::loncommon::end_data_table_row()); + $counter ++; } + + $r->print(&Apache::loncommon::end_data_table()); + + $r->print( + &Apache::lonhtmlcommon::topic_bar( + 4,&mt('Choose display options for listing of contents of top level of package')) + .'

' + .&mt('Select a display option for the package content:') + .'

' + ); + $r->print( + '' + .' ' + .'
' + .'' + ); + + # Buttons + $r->print( + '' + .'' + .'' + .'' + ); + $r->print( + '
' + .'

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

' + ); + + $r->print(''); }