Diff for /loncom/imspackages/imsimportdocs.pm between versions 1.16 and 1.24

version 1.16, 2006/03/23 23:17:46 version 1.24, 2009/11/06 17:16:53
Line 1 Line 1
   # The LearningOnline Network with CAPA
   #
   # $Id$
   #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
Line 30  use Apache::loncommon; Line 34  use Apache::loncommon;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::imsprocessor;  use Apache::imsprocessor;
 use LONCAPA::Configuration;  use LONCAPA::Configuration;
   use LONCAPA::map();
   use lib '/home/httpd/lib/perl/';
   use LONCAPA;
    
 use strict;  use strict;
   
 sub jscript_one {  sub jscript_one {
Line 150  sub handler { Line 158  sub handler {
     
     my $uname=$env{'user.name'};      my $uname=$env{'user.name'};
     my $udom=$env{'user.domain'};      my $udom=$env{'user.domain'};
     my $plainname=&Apache::lonnet::escape(      my $plainname=&escape(
                      &Apache::loncommon::plainname($uname,$udom));                       &Apache::loncommon::plainname($uname,$udom));
   
 # does this user have privileges to post, etc?  # does this user have privileges to post, etc?
Line 199  sub display_one { Line 207  sub display_one {
     my ($r) = @_;      my ($r) = @_;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder']);
   
     $r->print(<<ENDBLOCK);      $r->print(
 <form action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" name="pickcms">          '<form action="/adm/imsimportdocs" method="post"'
   <table border='0' bgcolor='#F6F6F6' cellspacing='0' cellpadding ='0' width='100%'>         .' enctype="multipart/form-data" name="pickcms">'
    <tr>         .&Apache::lonhtmlcommon::topic_bar(
     <td colspan='2'>              1,&mt('Specify the Course Management system used to create the package'))
      <table border='0' cellspacing='0' cellpadding='0'>         .&mt('Please choose the CMS used to create your IMS content package:').' '
       <tr>         .'<select name="source">'
         <td colspan='2'  align='left'>&nbsp;         .'<option value="-1" selected="selected">'.&mt('Please select').'</option>'
         </td>         .'<option value="bb5">Blackboard 5</option>'
        </tr>         .'<option value="bb6">Blackboard 6</option>'
        <tr bgcolor='#CCCCFF'>         .'<option value="angel5">ANGEL 5.5</option>'
         <td valign='middle'><img src='/res/adm/pages/bl_step1.gif'>&nbsp;         .'<option value="webctce4">WebCT 4 Campus Edition</option>'
         </td>         .'</select>'
         <td width='100%' align='left'>&nbsp;&nbsp;      );
          <font face='arial,helvetica,sans-serif'><b>Specify the Course Management system used to create the package.</b>&nbsp;&nbsp;      $r->print(
          </font>         &Apache::lonhtmlcommon::topic_bar(
        </td>             2,&mt('Locate the IMS content package you wish to upload'))
       </tr>        .'<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'
       <tr>        .'<input type="hidden" name="phase" value="two" />'
        <td colspan='2'>&nbsp;</td>        .&mt('File:')
       </tr>        .' <input type="file" name="uploadname" size="40" />'
       <tr>      );
        <td>&nbsp;</td>      $r->print(
        <td>         '<hr />'
         <font face='Arial,Helvetica,sans-serif'>        .'<p>'
 Please choose the CMS used to create your IMS content package.&nbsp;&nbsp;        .'<input type="button" name="exitpage" value="'.&mt('Cancel').'"'
         <select name="source">        .' onclick="javascript:self.close()" />'
          <option value='-1' selected="true">Please select</option>        .' '
          <option value='bb5'>Blackboard 5</option>        .'<input type="button" name="nextpage" value="'.&mt('Upload IMS package').'"'
          <option value='bb6'>Blackboard 6</option>        .' onclick="javascript:nextPage()" />'
          <option value='angel'>ANGEL</option>        .'</p>'
          <option value='webct4'>WebCT 4</option>      );
         </select>  
         </font>  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
       <tr bgcolor='#CCCCFF'>  
         <td valign='middle'><img src='/res/adm/pages/bl_step2.gif'>&nbsp;  
         </td>  
         <td width='100%' align='left'>&nbsp;&nbsp;  
          <font face='arial,helvetica,sans-serif'><b>Locate the IMS content package you wish to upload.</b>&nbsp;&nbsp;  
          </font>  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;  
         <input type="hidden" name="folder" value="$env{'form.folder'}" />  
         <input type="hidden" name="phase" value="two" />  
         <input type="file" name="uploadname" size="40" />  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
       <tr>  
        <td>&nbsp;</td>  
        <td><font face='arial,helvetica,sans-serif'>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.</font></td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
       <tr  
        <td colspan='2'>  
         <table border='0' cellspacing='0' cellpadding='0' width="100%">  
          <tr>  
           <td align='left'>  
            <input type="button" name="exitpage" value="Exit now" onClick="javascript:self.close()" />  
           </td>  
           <td align='right'>  
            <input type="button" name="nextpage" value="Upload IMS package" onClick="javascript:nextPage()" />  
           </td>  
          </tr>  
         </table>  
        </td>  
       </tr>  
      </table>  
     </td>  
    </tr>  
   </table>  
 </form>  
 ENDBLOCK  
 }  }
   
   
Line 332  sub display_two { Line 282  sub display_two {
         $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'choose',\%includedres,\%includeditems);          $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' || $cms eq 'bb6' || $cms eq 'webct4') {                  if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webctce4') {
                     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} ++;
                         }                          }
                     }                      }
                 } elsif ($cms eq 'angel') {                  } elsif ($cms eq 'angel5') {
                     foreach my $area (keys %{$cmsmap{$cms}}) {                      foreach my $area (keys %{$cmsmap{$cms}}) {
                         if ($area eq 'doc') {                          if ($area eq 'doc') {
                             if (grep/^$resources{$res}{type}$/,@{$cmsmap{$cms}{doc}}) {                              if (grep/^$resources{$res}{type}$/,@{$cmsmap{$cms}{doc}}) {
Line 361  sub display_two { Line 311  sub display_two {
        </td>         </td>
       </tr>        </tr>
       <tr bgcolor='#CCCCFF'>        <tr bgcolor='#CCCCFF'>
        <td valign='middle'><img src='/res/adm/pages/bl_step3.gif'>         <td valign="middle"><img src="/res/adm/pages/bl_step3.gif" alt="3" />
        </td>         </td>
        <td width='100%' align='left'>&nbsp;&nbsp;         <td width='100%' align='left'>&nbsp;&nbsp;
         <font face='arial,helvetica,sans-serif'><b>Choose which content types you wish to import</b></font>          <font face='arial,helvetica,sans-serif'><b>Choose which content types you wish to import</b></font>
Line 431  ENDBLOCK Line 381  ENDBLOCK
        <td colspan='2'>&nbsp;<br /><br /></td>         <td colspan='2'>&nbsp;<br /><br /></td>
       </tr>        </tr>
       <tr bgcolor='#CCCCFF'>        <tr bgcolor='#CCCCFF'>
        <td valign='middle'><img src='/res/adm/pages/bl_step4.gif'>         <td valign="middle"><img src="/res/adm/pages/bl_step4.gif" alt="4" />
        </td>         </td>
        <td width='100%' align='left'>&nbsp;&nbsp;         <td width='100%' align='left'>&nbsp;&nbsp;
         <font face='arial,helvetica,sans-serif'><b>Choose display options for listing of contents of top level of package.</b></font>          <font face='arial,helvetica,sans-serif'><b>Choose display options for listing of contents of top level of package</b></font>
        </td>         </td>
       </tr>        </tr>
       <tr>        <tr>
Line 473  ENDBLOCK Line 423  ENDBLOCK
         <table border='0' cellspacing='0' cellpadding='0' width="100%">          <table border='0' cellspacing='0' cellpadding='0' width="100%">
          <tr>           <tr>
           <td align='left'>            <td align='left'>
            <input type='button' name='exitpage' value='Exit now' onClick="javascript:self.close()" />             <input type='button' name='exitpage' value='Cancel' onClick="javascript:self.close()" />
           </td>            </td>
           <td align='right'>            <td align='right'>
            <input type="button" name="nextpage" value="Complete Import" onClick="javascript:nextPage($counter)" />             <input type="button" name="nextpage" value="Complete Import" onClick="javascript:nextPage($counter)" />
Line 488  ENDBLOCK Line 438  ENDBLOCK
   </table>    </table>
 ENDDOCUMENT  ENDDOCUMENT
         } else {          } else {
             $r->print("Unpacking of your IMS package failed because an IMS manifest file was not located in the package\n");              $r->print(
                  '<p class="LC_warning">'
                  .&mt('Unpacking of your IMS package failed because an IMS manifest file was not located in the package.')
                  .'</p>'
               );
         }          }
     } else {      } else {
         $r->print("Processing of your IMS package failed because the file you uploaded could not be unzipped\n");          $r->print(
               '<p class="LC_warning">'
              .&mt('Processing of your IMS package failed because the file you'
                  .' uploaded could not be unzipped.')
              .'</p>'
           );
     }      }
 }  }
   
Line 545  sub display_three { Line 504  sub display_three {
   
     foreach my $area (@{$areas}) {      foreach my $area (@{$areas}) {
         if (defined($env{"form.$area"}) && ($env{'form.'.$area} ne '')) {          if (defined($env{"form.$area"}) && ($env{'form.'.$area} ne '')) {
             if ($cms eq 'angel' && $area eq 'doc') {              if ($cms eq 'angel5' && $area eq 'doc') {
                 foreach (@{$cmsmap{$cms}{$area}}) {                  foreach (@{$cmsmap{$cms}{$area}}) {
                     $importareas{$_} = 1;                      $importareas{$_} = 1;
                 }                  }
Line 631  sub display_three { Line 590  sub display_three {
         my @imports = ();          my @imports = ();
         if ($toplevel eq 'oldfolder') {          if ($toplevel eq 'oldfolder') {
             for (my $i=0; $i<@topurls; $i++) {              for (my $i=0; $i<@topurls; $i++) {
                 my $url = &Apache::lonnet::unescape($topurls[$i]);                  my $url = &unescape($topurls[$i]);
                 my $name = &Apache::lonnet::unescape($topnames[$i]);                  my $name = &unescape($topnames[$i]);
                 push @imports, $name, $url;                  push(@imports, [$name, $url]);
             }              }
         } elsif ($toplevel eq 'newfolder') {          } elsif ($toplevel eq 'newfolder') {
             my $url = &Apache::lonnet::unescape("/uploaded/$cdom/$crs/$timenow/sequences/Top.sequence");              my $url = &unescape("/uploaded/$cdom/$crs/$timenow/sequences/Top.sequence");
             my $name = &Apache::lonnet::unescape("$env{'form.foldername'}");              my $name = &unescape("$env{'form.foldername'}");
             push @imports, $name, $url;              push(@imports, [$name, $url]);
         }          }
         my $errtext='';          my $errtext='';
         my $fatal=0;          my $fatal=0;
         ($errtext,$fatal)=  &Apache::londocs::mapread($crs,$cdom,$folder.'.sequence');          ($errtext,$fatal)=  &Apache::londocs::mapread($crs,$cdom,$folder.'.sequence');
         if ($#Apache::lonratedt::order<1) {          if ($#LONCAPA::map::order<1) {
             $Apache::lonratedt::order[0]=1;              $LONCAPA::map::order[0]=1;
             $Apache::lonratedt::resources[1]='';              $LONCAPA::map::resources[1]='';
         }          }
         my ($errtext,$fatal)=&Apache::londocs::group_import($crs,$cdom,$folder,'sequence','imsimport',@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";              &Apache::lonnet::logthis("Fatal error during group_import.");
         }          }
     }      }
     if ($tempdir =~ m/^\/home\/httpd\/perl\/tmp\/$crs\/\d{10}/) {      if ($tempdir =~ m/^\/home\/httpd\/perl\/tmp\/$crs\/\d{10}/) {
Line 665  sub display_three { Line 624  sub display_three {
        </td>         </td>
       </tr>        </tr>
       <tr bgcolor='#CCCCFF'>        <tr bgcolor='#CCCCFF'>
        <td valign='middle'><img src='/res/adm/pages/bl_step5.gif'>         <td valign="middle"><img src="/res/adm/pages/bl_step5.gif" alt="5" />
        </td>         </td>
        <td width='100%' align='left'>&nbsp;&nbsp;         <td width='100%' align='left'>&nbsp;&nbsp;
         <font face='arial,helvetica,sans-serif'><b>Your import is complete</b></font>          <font face='arial,helvetica,sans-serif'><b>Your import is complete</b></font>

Removed from v.1.16  
changed lines
  Added in v.1.24


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>