Diff for /loncom/interface/londocs.pm between versions 1.157 and 1.158

version 1.157, 2004/12/15 15:21:43 version 1.158, 2004/12/23 14:00:58
Line 30  package Apache::londocs; Line 30  package Apache::londocs;
   
 use strict;  use strict;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
   use Apache::imsexport;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonratedt;  use Apache::lonratedt;
Line 319  sub exportcourse { Line 320  sub exportcourse {
         }          }
   
         $r->print('<html><head><title>Export Course</title></head>'.          $r->print('<html><head><title>Export Course</title></head>'.
             &Apache::loncommon::bodytag('Export course to IMS or SCORM content package'));              &Apache::loncommon::bodytag('Export course to IMS content package'));
         $r->print($outcome);          $r->print($outcome);
         $r->print('</body></html>');          $r->print('</body></html>');
     } else {      } else {
Line 368  sub exportcourse { Line 369  sub exportcourse {
             }              }
             if (ref($curRes)) {              if (ref($curRes)) {
                 my $symb = $curRes->symb();                  my $symb = $curRes->symb();
                   my $ressymb = $symb;
                   if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {
                       unless ($ressymb =~ m|adm/wrapper/adm|) {
                           $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
                       }
                   }
                 my $color = $count%2;                  my $color = $count%2;
                 $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".                  $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
                     '<input type="checkbox" name="archive" value="'.$count.'" ';                      '<input type="checkbox" name="archive" value="'.$count.'" ';
Line 389  sub exportcourse { Line 396  sub exportcourse {
                 my $currelem = $count+$boards+$startcount;                  my $currelem = $count+$boards+$startcount;
                 $children{$parent{$depth}} .= $currelem.':';                  $children{$parent{$depth}} .= $currelem.':';
                 $display .= '&nbsp;'.$curRes->title().'</td>';                  $display .= '&nbsp;'.$curRes->title().'</td>';
                 if ($discussiontime{$symb} > 0) {                  if ($discussiontime{$ressymb} > 0) {
                     $boards ++;                      $boards ++;
                     $currelem = $count+$boards+$startcount;                      $currelem = $count+$boards+$startcount;
                     $display .= '<td>&nbsp;</td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" />&nbsp;</td>'."\n";                      $display .= '<td>&nbsp;</td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" />&nbsp;</td>'."\n";
Line 402  sub exportcourse { Line 409  sub exportcourse {
 <script>  <script>
   
 function checkAll(field) {  function checkAll(field) {
     for (i = 0; i < field.length; i++)      if (field.length > 0) {
         field[i].checked = true ;          for (i = 0; i < field.length; i++) {
               field[i].checked = true ;
           }
       } else {
           field.checked = true
       }
 }  }
                                                                                   
 function uncheckAll(field) {  function uncheckAll(field) {
     for (i = 0; i < field.length; i++)      if (field.length > 0) {
         field[i].checked = false ;          for (i = 0; i < field.length; i++) {
               field[i].checked = false ;
           }
       } else {
           field.checked = false ;
       }
 }  }
   
 function propagateCheck(item) {  function propagateCheck(item) {
Line 444  function containerCheck(item) { Line 461  function containerCheck(item) {
 </script>  </script>
         |;          |;
         $r->print('<html><head><title>Export Course</title>'.$scripttag.'</head>'.          $r->print('<html><head><title>Export Course</title>'.$scripttag.'</head>'.
             &Apache::loncommon::bodytag('Export course to IMS or SCORM content package'              &Apache::loncommon::bodytag('Export course to IMS content package'
 ));  ));
   
         $r->print($display.'</table>'.          $r->print($display.'</table>'.
Line 482  sub create_ims_store { Line 499  sub create_ims_store {
 ' identifier="MANIFEST-'.$ENV{'request.course.id'}.'-'.$now.'"'.  ' identifier="MANIFEST-'.$ENV{'request.course.id'}.'-'.$now.'"'.
 '  xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.  '  xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
 '  http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".  '  http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
 '  <organizations default="ORG-."'.$ENV{'request,course.id'}.'-'.$now.'">'."\n".  '  <organizations default="ORG-'.$ENV{'request.course.id'}.'-'.$now.'">'."\n".
 '    <organization identifier="ORG-'.$ENV{'request.course.id'}.'-'.$now.'"'.  '    <organization identifier="ORG-'.$ENV{'request.course.id'}.'-'.$now.'"'.
 ' structure="hierarchical">'."\n".  ' structure="hierarchical">'."\n".
 '      <title>'.$ENV{'request.'.$ENV{'request.course.id'}.'.description'}.'</title>'  '      <title>'.$ENV{'request.'.$ENV{'request.course.id'}.'.description'}.'</title>'
Line 581  sub build_package { Line 598  sub build_package {
                             $imsresources .=                              $imsresources .=
                      '        <file href="'.$_.'" />'."\n";                       '        <file href="'.$_.'" />'."\n";
                         }                          }
                           if (grep/^$count$/,@$discussions) {
                               my $ressymb = $symb;
                               my $mode;
                               if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {
                                   unless ($ressymb =~ m|adm/wrapper/adm|) {
                                       $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
                                   }
                                   $mode = 'board';
                               }
                               my %extras = (
                                             caller => 'imsexport',
                                             tempexport => $tempexport,
                                             count => $count
                                            );
                               my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
                           }
                         $imsresources .= '    </resource>'."\n";                          $imsresources .= '    </resource>'."\n";
                     }                      }
                 }                  }
Line 623  sub process_content { Line 656  sub process_content {
     my $message;      my $message;
 # find where user is author or co-author  # find where user is author or co-author
     my %roleshash = &Apache::lonnet::get_my_roles();      my %roleshash = &Apache::lonnet::get_my_roles();
       my @uploads = ();
     if ($curRes->is_sequence()) {      if ($curRes->is_sequence()) {
         $content_type = 'sequence';          $content_type = 'sequence';
     } elsif ($curRes->is_page()) {      } elsif ($curRes->is_page()) {
         $content_type = 'page'; # need to handle individual items in pages.          $content_type = 'page'; # need to handle individual items in pages.
     } elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {      } elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
         $content_type = 'syllabus';          $content_type = 'syllabus';
           my $contents = &Apache::imsexport::templatedpage($content_type);
           if ($contents) {
               $$content_file = &store_template($contents,$tempexport,$count,$content_type);
           }
     } elsif ($symb =~ m-\.sequence___\d+___ext-) {      } elsif ($symb =~ m-\.sequence___\d+___ext-) {
         $content_type = 'external';          $content_type = 'external';
           my $title = $curRes->title;
           my $contents =  &Apache::imsexport::external($symb,$title);
           if ($contents) {
               $$content_file = &store_template($contents,$tempexport,$count,$content_type);
           }
     } elsif ($symb =~ m-adm/navmaps$-) {      } elsif ($symb =~ m-adm/navmaps$-) {
         $content_type =  'navmap';          $content_type =  'navmap';
     } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/smppg$-) {      } elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) {
         $content_type = 'simplepage';          $content_type = 'simplepage';
     } elsif ($symb =~ m-/lib/templates/simpleproblem\.problem$-) {          my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads);
           if ($contents) {
               $$content_file = &store_template($contents,$tempexport,$count,$content_type);
           }
       } elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) {
         $content_type = 'simpleproblem';          $content_type = 'simpleproblem';
     } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/bulletinboard$-) {          my $contents =  &Apache::imsexport::simpleproblem($symb);
           if ($contents) {
               $$content_file = &store_template($contents,$tempexport,$count,$content_type);
           }
       } elsif ($symb =~ m-lib/templates/examupload\.problem-m) {
           $content_type = 'examupload';
       } elsif ($symb =~ m-adm/(\w+)/(\w+)/(\d+)/bulletinboard$-) {
         $content_type = 'bulletinboard';          $content_type = 'bulletinboard';
     } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/aboutme$-) {          my $contents =  &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
           if ($contents) {
               $$content_file = &store_template($contents,$tempexport,$count,$content_type);
           }
       } elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) {
         $content_type = 'aboutme';          $content_type = 'aboutme';
           my $contents =  &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2);
           if ($contents) {
               $$content_file = &store_template($contents,$tempexport,$count,$content_type);
           }
     } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {      } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
         $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');          $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
     } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {      } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
Line 665  sub process_content { Line 726  sub process_content {
             $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');              $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
         }          }
     }      }
       if (@uploads > 0) {
           foreach my $item (@uploads) {
               my $uploadmsg = '';
               &replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'uploaded');
               if ($uploadmsg) {
                   $$copyresult .= $uploadmsg."\n";
               }
           }
       }
     if ($message) {      if ($message) {
         $$copyresult .= $message."\n";          $$copyresult .= $message."\n";
     }      }
Line 735  sub extract_media { Line 805  sub extract_media {
     return;      return;
 }  }
   
   sub store_template {
       my ($contents,$tempexport,$count,$content_type) = @_;
       if ($contents) {
           my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
           my $storetemplate;
           if ($storetemplate = Apache::File->new('>'.$destination)) {
               print $storetemplate $contents;
               close($storetemplate);
           }
           return $count.'/'.$content_type.'.xml';
       }
   }
   
 # Imports the given (name, url) resources into the course  # Imports the given (name, url) resources into the course
 # coursenum, coursedom, and folder must precede the list  # coursenum, coursedom, and folder must precede the list
 sub group_import {  sub group_import {

Removed from v.1.157  
changed lines
  Added in v.1.158


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