Diff for /loncom/imspackages/imsimport.pm between versions 1.6 and 1.21

version 1.6, 2004/04/08 09:19:39 version 1.21, 2006/11/27 16:37:36
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::imsimport;  package Apache::imsimport;
   
 use strict;  use strict;
 use Apache::Constants qw(:common :http :methods);  use Apache::Constants qw(:common :http :methods);
 use Apache::loncacc;  use Apache::loncacc;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::Log();  
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::imsprocessor;  use Apache::imsprocessor;
 use HTML::Parser;  use HTML::Parser;
Line 12  use HTML::Entities(); Line 34  use HTML::Entities();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonupload;  use Apache::lonupload;
 use File::Basename();  use File::Basename();
                                                                                               use LONCAPA;
   
 # ----------------------------------------------------------------  Jscript One  # ----------------------------------------------------------------  Jscript One
 sub jscript_one {  sub jscript_one {
     my ($fullpath,$jsref) = @_;      my ($fullpath,$jsref) = @_;
   
       my %body_layout = ('rightmargin'  => "0",
          'leftmargin'   => "0",
          'marginwidth'  => "0",
          'topmargin'    => "0",
          'marginheight' => "0");
       my $start_page = 
    &Apache::loncommon::start_page('Create IMS import directory',undef,
          {'only_body'   => 1,
    'add_entries' => \%body_layout,
    'js_ready'    => 1,});
       my $end_page = 
    &Apache::loncommon::end_page({'js_ready' => 1,});
   
     $$jsref = <<"END_OF_ONE";      $$jsref = <<"END_OF_ONE";
 function verify() {  function verify() {
  if ((document.forms.dataForm.newdir.value == '')  || (!document.forms.dataForm.newdir.value)) {   if ((document.forms.dataForm.newdir.value == '')  || (!document.forms.dataForm.newdir.value)) {
Line 39  function createWin() { Line 76  function createWin() {
   document.dataForm.newdir.value = "";    document.dataForm.newdir.value = "";
   newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes")    newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes")
   newWindow.document.open()    newWindow.document.open()
   newWindow.document.write("<html><head><title>Create IMS import directory</title><meta http-equiv='pragma' content='no-cache'>\\n")    newWindow.document.write('$start_page')
   newWindow.document.write("</head><body bgcolor='#CCFFDD' topmargin='0' leftmargin='0' marginheight='0'marginwidth='0' rightmargin='0'>\\n")    newWindow.document.write("\\n<img border='0' src='/adm/lonInterFace/author.jpg' alt='[Author Header]'>\\n")
   newWindow.document.write("<img border='0' src='/adm/lonInterFace/author.jpg' alt='[Author Header]'>\\n")  
   newWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='600' bgcolor='#CCFFDD'>\\n")    newWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='600' bgcolor='#CCFFDD'>\\n")
   newWindow.document.write("<tr><td width='2'>&nbsp;</td><td width='3'>&nbsp;</td>\\n")    newWindow.document.write("<tr><td width='2'>&nbsp;</td><td width='3'>&nbsp;</td>\\n")
   newWindow.document.write("<td><h3>Location: <tt>$fullpath</tt></h3><h3>New Directory</h3></td></tr>\\n")    newWindow.document.write("<td><h3>Location: <tt>$fullpath</tt></h3><h3>New Directory</h3></td></tr>\\n")
   newWindow.document.write("<tr><td width='2'>&nbsp;</td><td width='3'>&nbsp;</td>\\n")    newWindow.document.write("<tr><td width='2'>&nbsp;</td><td width='3'>&nbsp;</td>\\n")
   newWindow.document.write("<td><form name='fileaction' action='/adm/cfile' method='post'>\\n")    newWindow.document.write("<td><form name='fileaction' action='/adm/cfile' method='post'>\\n")
   newWindow.document.write("<font face='arial,helvetica,sans-serif'>Enter the name of the new directory where you will store the contents of your IMS package.<br /><br />")    newWindow.document.write("<font face='arial,helvetica,sans-serif'>Enter the name of the new directory where you will store the contents of your IMS package.<br /><br />")
   newWindow.document.write("<input type='hidden' name='filename' value='$fullpath'>")    newWindow.document.write("<input type='hidden' name='filename' value='$fullpath' />")
   newWindow.document.write("<input type='hidden' name='action' value='newdir'>")    newWindow.document.write("<input type='hidden' name='action' value='newdir' />")
   newWindow.document.write("<input type='hidden' name='callingmode' value='imsimport'>")    newWindow.document.write("<input type='hidden' name='callingmode' value='imsimport' />")
   newWindow.document.write("$fullpath<input type='text' name='newfilename' value=''/>")    newWindow.document.write("$fullpath<input type='text' name='newfilename' value='' />")
   newWindow.document.write("<input type='button' value='Go' onClick='document.fileaction.submit();' />")    newWindow.document.write("<input type='button' value='Go' onClick='document.fileaction.submit();' />")
   newWindow.document.write("</td></tr>\\n")    newWindow.document.write("</td></tr>\\n")
   newWindow.document.write("</table></body></html>")    newWindow.document.write("</table>")
     newWindow.document.write('$end_page')
   newWindow.document.close()    newWindow.document.close()
   newWindow.focus()    newWindow.focus()
 }  }
Line 269  sub display_one { Line 306  sub display_one {
         <font face='Arial,Helvetica,sans-serif'>          <font face='Arial,Helvetica,sans-serif'>
 Please choose the CMS used to create your IMS content package.&nbsp;&nbsp;  Please choose the CMS used to create your IMS content package.&nbsp;&nbsp;
         <select name="source">          <select name="source">
          <option value='-1' selected="true">Please select           <option value='-1' selected="true">Please select</option>
          <option value='bb5'>Blackboard 5           <option value='bb5'>Blackboard 5</option>
          <option value='angel'>ANGEL           <option value='bb6'>Blackboard 6</option>
            <option value='angel'>ANGEL</option>
            <option value='webctce4'>WebCT 4 Campus Edition</option>
            <option value='webctvista4'>WebCT Vista 4</option>
         </select>          </select>
         </font>          </font>
        </td>         </td>
Line 294  Please choose the CMS used to create you Line 334  Please choose the CMS used to create you
        <td>&nbsp;</td>         <td>&nbsp;</td>
        <td>         <td>
         <font face='Arial,Helvetica,sans-serif'>          <font face='Arial,Helvetica,sans-serif'>
 Please choose a destination LON-CAPA directory in which to store the contents of the IMS package file. <input type="button" name="createdir" value="Create Directory" onClick="javascript:createWin()"><input type="hidden" name="newdir" value=""></font>  Please choose a destination LON-CAPA directory in which to store the contents of the IMS package file. <input type="button" name="createdir" value="Create Directory" onClick="javascript:createWin()" /><input type="hidden" name="newdir" value="" /></font>
        </td>         </td>
       </tr>        </tr>
       <tr>        <tr>
Line 306  Please choose a destination LON-CAPA dir Line 346  Please choose a destination LON-CAPA dir
       </tr>        </tr>
       <tr>        <tr>
        <td colspan='2'>         <td colspan='2'>
           <input type="hidden" name="uploaduname" value="$uname">            <input type="hidden" name="uploaduname" value="$uname" />
           <input type="hidden" name="filename" value="$fn">            <input type="hidden" name="filename" value="$fn" />
           <input type="hidden" name="phase" value="three">            <input type="hidden" name="phase" value="three" />
        </td>         </td>
       </tr>        </tr>
       <tr>        <tr>
Line 319  Please choose a destination LON-CAPA dir Line 359  Please choose a destination LON-CAPA dir
         <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:location.href='$fullpath'">             <input type='button' name='exitpage' value='Exit now' onClick="javascript:location.href='$fullpath'" />
           </td>            </td>
           <td align='right'>            <td align='right'>
            <input type="button" name="nextpage" value="Proceed" onClick="javascript:nextPage()">             <input type="button" name="nextpage" value="Proceed" onClick="javascript:nextPage()" />
           </td>            </td>
          </tr>           </tr>
         </table>          </table>
Line 340  END_OF_ONE Line 380  END_OF_ONE
 sub display_two {  sub display_two {
     my ($r,$zipupload,$areas,$areaname,$cmsmap,$uname,$newdir,$numcrs,$fullpath) = @_;      my ($r,$zipupload,$areas,$areaname,$cmsmap,$uname,$newdir,$numcrs,$fullpath) = @_;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']);
     my $cms = $ENV{'form.source'};      my $cms = $env{'form.source'};
     my $dirname = $ENV{'form.newdir'};      my $dirname = $env{'form.newdir'};
     my $tempdir = &Apache::imsprocessor::create_tempdir('CSTR',$dirname,'');      my $tempdir = &Apache::imsprocessor::create_tempdir('CSTR',$dirname,'');
     my $fname = &Apache::imsprocessor::uploadzip('CSTR',$tempdir,$zipupload);      my $fname = &Apache::imsprocessor::uploadzip('CSTR',$tempdir,$zipupload);
     my $unzip_result = '';      my $unzip_result = '';
Line 350  sub display_two { Line 390  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 373  sub display_two { Line 415  sub display_two {
     my $conditions;      my $conditions;
   
     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' || $cms eq 'webctce4' 
                       || $cms eq 'webctvista4') {
                     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 455  ENDBLOCK Line 500  ENDBLOCK
                     if ($area eq 'board') {                      if ($area eq 'board') {
                         $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;                          $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;
                  <select name='db_handling'>                   <select name='db_handling'>
                   <option value='-2'>&lt;-- Check Import first                    <option value='-2'>&lt;-- Check Import first</option>
                  </select></font>                   </select></font>
                 </td>");                  </td>");
                     } elsif ($area eq 'users') {                      } elsif ($area eq 'users') {
                         $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;                          $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;
                  <select name='user_handling'>                   <select name='user_handling'>
                   <option value='-2'>&lt;-- Check Import first                    <option value='-2'>&lt;-- Check Import first</option>
                  </select>                   </select>
                  </font>                           </font>        
                 </td>");                  </td>");
Line 508  ENDBLOCKTWO Line 553  ENDBLOCKTWO
 <br /><br />  <br /><br />
 Choose course:&nbsp;&nbsp;  Choose course:&nbsp;&nbsp;
                  <select name='targetcourse'>                   <select name='targetcourse'>
                   <option value='-1'>Not required                    <option value='-1'>Not required</option>
                  </select></font>                   </select></font>
        </td>         </td>
       </tr>        </tr>
Line 530  Choose course:&nbsp;&nbsp; Line 575  Choose course:&nbsp;&nbsp;
       </tr>        </tr>
       <tr>        <tr>
        <td colspan='2'>&nbsp;         <td colspan='2'>&nbsp;
           <input type="hidden" name="newdir" value="$ENV{'form.newdir'}" />            <input type="hidden" name="newdir" value="$env{'form.newdir'}" />
           <input type="hidden" name="conditions" value="$conditions" />            <input type="hidden" name="conditions" value="$conditions" />
           <input type="hidden" name="source" value="$cms" />            <input type="hidden" name="source" value="$cms" />
           <input type="hidden" name="tempdir" value="$tempdir" />            <input type="hidden" name="tempdir" value="$tempdir" />
Line 552  ENDBLOCK Line 597  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:location.href='$fullpath'">             <input type='button' name='exitpage' value='Exit now' onClick="javascript:location.href='$fullpath'" />
           </td>            </td>
           <td align='right'>            <td align='right'>
            <input type="button" name="nextpage" value="Import package" onClick="javascript:nextPage($counter)">             <input type="button" name="nextpage" value="Import package" onClick="javascript:nextPage($counter)" />
           </td>            </td>
          </tr>           </tr>
         </table>          </table>
Line 579  sub display_three { Line 624  sub display_three {
     my ($r,$uname,$udom,$areas,$areaname,$cmsmap,$destdir,$newdir) = @_;      my ($r,$uname,$udom,$areas,$areaname,$cmsmap,$destdir,$newdir) = @_;
     my $crs = '';      my $crs = '';
     my $cdom = '';      my $cdom = '';
     my $chome = '';  
     my $db_handling = '';      my $db_handling = '';
     my $timenow = time;       my $timenow = time; 
     my $announce_handling = 'ok';      my $announce_handling = 'ok';
     my $cms = $ENV{'form.source'};      my $cms = $env{'form.source'};
     if ( defined($ENV{'form.bb_crs'}) ) {      if ( defined($env{'form.bb_crs'}) ) {
         ($cdom,$crs) = split/\//,$ENV{'form.bb_crs'};          ($cdom,$crs) = split/\//,$env{'form.bb_crs'};
         $chome = &Apache::lonnet::homeserver($crs,$cdom);  
     }       } 
     if ( defined($ENV{'form.bb_handling'}) ) {  
         $db_handling = $ENV{'form.bb_handling'};  
     }  
     my $user_crs = '';      my $user_crs = '';
     my $user_cdom = '';      my $user_cdom = '';
     my $user_handling = '';      my $user_handling = '';
     if ( defined($ENV{'form.user_crs'}) ) {      if ( defined($env{'form.user_crs'}) ) {
         ($user_cdom,$user_crs) = split/\//,$ENV{'form.user_crs'};          ($user_cdom,$user_crs) = split/\//,$env{'form.user_crs'};
     }  
     if ( defined($ENV{'form.user_handling'}) ) {  
         $user_handling = $ENV{'form.user_handling'};  
     }      }
     my $seqstem = "/res/$udom/$uname/$newdir";      my $seqstem = "/res/$udom/$uname/$newdir";
     my %imports = ();      my %importareas = ();
       my %includedres = ();
       my %includeditems = ();
       my %randompicks = ();
     my @targets = ();      my @targets = ();
     my %resources = ();      my %resources = ();
     my %items = ();      my %items = ();
Line 620  sub display_three { Line 660  sub display_three {
     my @pages = ();      my @pages = ();
     my @sequences = ();      my @sequences = ();
     my @resrcfiles = ();      my @resrcfiles = ();
       my @assessmentfiles = ();
   
     my $tempdir = $ENV{'form.tempdir'};      my $tempdir = $env{'form.tempdir'};
   
     foreach my $area (@{$areas}) {      foreach my $area (@{$areas}) {
         if (defined($ENV{"form.$area"}) ) {                    if (defined($env{"form.$area"}) ) {
             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'};
             } elsif ($area eq 'users') {              } elsif ($area eq 'users') {
                 $user_handling = $ENV{'form.user_handling'};                  $user_handling = $env{'form.user_handling'};
             }              }
         }          }
     }      }
     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);
     if ($manifest_result eq 'ok') {      if ($manifest_result eq 'ok') {
         &Apache::imsprocessor::target_resources(\%resources,\%imports,\@targets);          foreach my $res (sort keys %resources) {
         my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow);              if ($importareas{$resources{$res}{type}}) {
                   $includedres{$res} = 1;
                   if ($resources{$res}{type} eq 'webct.manifest' || 
                        $resources{$res}{type} eq 'webct.assessment' ||
                        $resources{$res}{type} eq 'webct.question') {
                       push(@assessmentfiles,$res);
                   }   
               }
           }
           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') {
           &Apache::imsprocessor::target_resources(\%resources,\%importareas,\@targets);
   
         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,'CSTR',$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,\%randompicks);
   
         &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$newdir,$seqstem,\@resrcfiles);          my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$destdir,$timenow,\%importareas,\@assessmentfiles);
         
         &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames);          &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\@targets,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems,\%randompicks);
   
         $r->print("<h3>Step 3: Publish your new LON-CAPA materials</h3>");          $r->print("<h3>IMS import completed</h3>");
   
         if ($cms eq 'bb5') {          if ($cms eq 'bb5') {
             $r->print("<font face='arial,helvetica,sans-serif'>Your IMS package has been processed successfully. A total of $total{seq} sequences, $total{page} pages, $total{board} bulletin boards, $total{quiz} quizzes, $total{surv} surveys and $total{prob} problems have been created.<br /><br />\n");              $r->print("<font face='arial,helvetica,sans-serif'>Your IMS package has been processed successfully. A total of $total{seq} sequences, $total{page} pages, $total{board} bulletin boards, $total{quiz} quizzes, $total{surv} surveys and $total{prob} problems have been created.<br /><br />\n");
         } elsif ($cms eq 'angel') {          } elsif ($cms eq 'angel') {
             $r->print("<font face='arial,helvetica,sans-serif'>Your IMS package has been processed successfully. A total of $total{seq} sequences, $total{page} pages, and $total{board} bulletin boards have been created.<br /><br />\n");              $r->print("<font face='arial,helvetica,sans-serif'>Your IMS package has been processed successfully. A total of $total{seq} sequences, $total{page} pages, and $total{board} bulletin boards have been created.<br /><br />\n");
         }          }
 #        system (" rm -r -f $destdir/temp");         $r->print("Please view the imported items and use the LON-CAPA editing tools to make changes.  The sequences directory contains a file named 'Top.sequence' which includes links to the items found at the top level of your IMS package. From there you can follow links to display all the imported items. Alternatively, you can browse the pages, sequences, problems and resfiles directories directly. Note if you rename a file, you will need to modify any .sequence files or .page files which include a reference to the renamed file.<br /><br />The final step in the IMS import process is to publish the materials you have imported into your Construction Space so that you can use them in a course. Once your file are published, subsequent re-publication will result in the storage of information about changes between the different versions.<br /><br /><a href='/priv/".$uname."/".$newdir."'>Display new directory</a></font>"); 
           if ($destdir =~ m-^/home/$uname/public_html/-) { 
               system (" rm -r -f $destdir/temp");
           }
     } elsif ($manifest_result eq 'nomanifest') {      } elsif ($manifest_result eq 'nomanifest') {
         $r->print("<font face='arial,helvetica,sans-serif'>Processing of your IMS package failed, because the IMS content package did not contain an IMS manifest file .");          $r->print("<font face='arial,helvetica,sans-serif'>Processing of your IMS package failed, because the IMS content package did not contain an IMS manifest file.</font>");
     }      }
 }  }
   
Line 685  sub get_ccroles { Line 758  sub get_ccroles {
     my @crslist = ();      my @crslist = ();
     my %descrip =();      my %descrip =();
     foreach my $key (keys %roles ) {      foreach my $key (keys %roles ) {
         if ($key =~ m/^\/(\w+)\/(\w+)_cc$/) {          if ($key =~ m{^/($LONCAPA::domain_re)/($LONCAPA::username_re)_cc$}) {
             my $cdom = $1;              my $cdom = $1;
             my $crs = $2;              my $crs = $2;
             my $role_end = 0;              my $role_end = 0;
Line 754  sub handler { Line 827  sub handler {
     my $javascript = '';      my $javascript = '';
     my $page_name = '';      my $page_name = '';
     my $current_page = '';      my $current_page = '';
     my $loadentries = '';  
     my $qcount = '';      my $qcount = '';
   
 # get personal information for this user  # get personal information for this user
     my $user=$ENV{'user.name'};      my $user=$env{'user.name'};
     my $dom=$ENV{'user.domain'};      my $dom=$env{'user.domain'};
   
 #  #
 # re-attach user  # re-attach user
 #  #
     if ($ENV{'form.uploaduname'}) {      if ($env{'form.uploaduname'}) {
         $ENV{'form.filename'}='/priv/'.$ENV{'form.uploaduname'}.'/'.          $env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'.
             $ENV{'form.filename'};              $env{'form.filename'};
     }      }
     ($uname,$udom)=      ($uname,$udom)=
         &Apache::loncacc::constructaccess($ENV{'form.filename'},          &Apache::loncacc::constructaccess($env{'form.filename'},
                                           $r->dir_config('lonDefDomain'));                                            $r->dir_config('lonDefDomain'));
     unless (($uname) && ($udom)) {      unless (($uname) && ($udom)) {
         $r->log_reason($uname.' at '.$udom.          $r->log_reason($uname.' at '.$udom.
                        ' trying to publish file '.$ENV{'form.filename'}.                         ' trying to publish file '.$env{'form.filename'}.
                        ' - not authorized',                         ' - not authorized',
                        $r->filename);                         $r->filename);
         return HTTP_NOT_ACCEPTABLE;          return HTTP_NOT_ACCEPTABLE;
     }      }
                                                                                                                                                                                             
     my $fn;      my $fn;
     if ($ENV{'form.filename'}) {      if ($env{'form.filename'}) {
         $fn=$ENV{'form.filename'};          $fn=$env{'form.filename'};
         $fn=~s/^http\:\/\/[^\/]+\///;          $fn=~s/^http\:\/\/[^\/]+\///;
         $fn=~s/^\///;          $fn=~s/^\///;
         $fn=~s/(\~|priv\/)(\w+)//;          $fn=~s/(\~|priv\/)(\w+)//;
         $fn=~s/\/+/\//g;          $fn=~s/\/+/\//g;
     } else {      } else {
         $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.          $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
                        ' unspecified filename for upload', $r->filename);                         ' unspecified filename for upload', $r->filename);
         return HTTP_NOT_FOUND;          return HTTP_NOT_FOUND;
     }      }
Line 797  sub handler { Line 869  sub handler {
     unless ($pathname eq '/') {      unless ($pathname eq '/') {
         $fullpath .= '/';          $fullpath .= '/';
     }      }
     my $loadentries = '';  
   
     my @areas = ();      my @areas = ();
     my %cmsmap = ();      my %cmsmap = ();
Line 809  sub handler { Line 880  sub handler {
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
   
     if ($ENV{'form.phase'} eq 'two') {      if ($env{'form.phase'} eq 'two') {
         &jscript_one($fullpath,\$javascript,$uname,$udom);          &jscript_one($fullpath,\$javascript,$uname,$udom);
     } elsif ($ENV{'form.phase'} eq 'three') {      } elsif ($env{'form.phase'} eq 'three') {
         &jscript_two(\$javascript,$user,$dom,\$numcrs);          &jscript_two(\$javascript,$user,$dom,\$numcrs);
     } elsif ($ENV{'form.phase'} eq 'four') {      } elsif ($env{'form.phase'} eq 'four') {
         &jscript_three(\$javascript);          &jscript_three(\$javascript);
     }      }
     $r->print("<html><head><title>LON-CAPA Construction Space</title><script type=\"text/javascript\">\n//<!--\n$javascript\n// --></script>\n</head>");      $javascript = "<script type=\"text/javascript\">\n//<!--\n$javascript\n// --></script>\n";
                                                                                                
     $r->print(&Apache::loncommon::bodytag('Upload IMS package to Construction Space',undef,$loadentries));      my $title = 'Upload IMS package to Construction Space';
                                                                                                    $r->print(&Apache::loncommon::start_page($title, $javascript));
     if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {  
       if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
         $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.          $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.
                   &mt(' at ').$udom.'</font></h3>');                    &mt(' at ').$udom.'</font></h3>');
     }         }   
     if ($ENV{'form.phase'} eq 'two') {      if ($env{'form.phase'} eq 'two') {
         my $flag = &Apache::lonupload::phasetwo($r,$fn,$uname,$udom,'imsimport');          my $flag = &Apache::lonupload::phasetwo($r,$fn,$uname,$udom,'imsimport');
         if ($flag eq 'ok') {          if ($flag eq 'ok') {
             &display_one($r,$uname,$fn,$fullpath);              &display_one($r,$uname,$fn,$fullpath);
         }          }
     } elsif ( ($ENV{'form.phase'} eq 'three') || ($ENV{'form.phase'} eq 'four') ) {      } elsif ( ($env{'form.phase'} eq 'three') || ($env{'form.phase'} eq 'four') ) {
         my $docroot = $ENV{'form.newdir'};          my $docroot = $env{'form.newdir'};
         my $newdir = '';          my $newdir = '';
         if ($docroot =~ m|public_html/(.+)$|) {          if ($docroot =~ m|public_html/(.+)$|) {
             $newdir = $1;              $newdir = $1;
         }          }
         if ($ENV{'form.phase'} eq 'three') {          if ($env{'form.phase'} eq 'three') {
             &display_two ($r,$zipupload,\@areas,\%areaname,\%cmsmap,$uname,$newdir,\$numcrs,$fullpath);              &display_two ($r,$zipupload,\@areas,\%areaname,\%cmsmap,$uname,$newdir,\$numcrs,$fullpath);
         } elsif ($ENV{'form.phase'} eq 'four') {          } elsif ($env{'form.phase'} eq 'four') {
             &display_three ($r,$uname,$udom,\@areas,\%areaname,\%cmsmap,$docroot,$newdir);              &display_three ($r,$uname,$udom,\@areas,\%areaname,\%cmsmap,$docroot,$newdir);
         }          }
     } else {      } else {
         &Apache::lonupload::phaseone($r,$fn,$uname,$udom,'imsimport');          &Apache::lonupload::phaseone($r,$fn,$uname,$udom,'imsimport');
     }      }
     $r->print('</body></html>');      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
 }  }
 1;  1;

Removed from v.1.6  
changed lines
  Added in v.1.21


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