--- loncom/interface/londocs.pm 2004/08/17 19:02:57 1.137 +++ loncom/interface/londocs.pm 2004/08/22 18:15:54 1.138 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.137 2004/08/17 19:02:57 albertel Exp $ +# $Id: londocs.pm,v 1.138 2004/08/22 18:15:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::lonratedt; use Apache::lonratsrv; use Apache::lonxml; use Apache::loncreatecourse; +use Apache::lonnavmaps; use HTML::Entities; use GDBM_File; use Apache::lonlocal; @@ -236,6 +237,202 @@ sub dumpcourse { } } +# ------------------------------------------------------ Generate "export" button + +sub exportbutton { + return ''. + ''. + &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); +} + +sub exportcourse { + my $r=shift; + my %discussiontime = &Apache::lonnet::dump('discussiontimes', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + my $numdisc = keys %discussiontime; + my $navmap = Apache::lonnavmaps::navmap->new(); + my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); + my $curRes; + + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['finishexport']); + if ($ENV{'form.finishexport'}) { + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['archive','discussion']); + + my @exportitems = (); + if (defined($ENV{'form.archive'})) { + if (ref($ENV{'form.archive'}) eq 'ARRAY') { + @exportitems = @{$ENV{'form.archive'}}; + } else { + $exportitems[0] = $ENV{'form.archive'}; + } + } + my @discussions = (); + if (defined($ENV{'form.discussion'})) { + if (ref($ENV{'form.discussion'}) eq 'ARRAY') { + @discussions = $ENV{'form.discussion'}; + } else { + $discussions[0] = $ENV{'form.discussion'}; + } + } + my $curRes; + my $count; + my %symbs; + my $display; + while ($curRes = $it->next()) { + if (ref($curRes)) { + $count ++; + $symbs{$count} = $curRes->symb(); + if (grep/^$count$/,@exportitems) { + $display.= 'Export content item '.$curRes->title()."
\n"; + } + if (grep/^$count$/,@discussions) { + $display.= 'Export discussion posts '.$curRes->title()."
\n"; + } + } + } + + $r->print('Export Course'. + &Apache::loncommon::bodytag('Export course to IMS or SCORM content package' +)); + + my $exportfile; + $r->print($display); + $r->print(''); + } else { + my $display; + $display = '
'."\n"; + $display .= 'Choose which items you wish to export from your course.

'; + $display .= ''. + ''. + ''. + ''. + '
 Content items'. + ''. + '  
  
 Discussion posts'. + ''. + '  
'; + my $curRes; + my $depth = 0; + my $count = 0; + my $boards = 0; + my $startcount = 5; + my %parent = (); + my %children = (); + my $lastcontainer = $startcount; + my @bgcolors = ('#F6F6F6','#FFFFFF'); + $display .= ''. + ''; + while ($curRes = $it->next()) { + if (ref($curRes)) { + $count ++; + } + if ($curRes == $it->BEGIN_MAP()) { + $depth++; + $parent{$depth} = $lastcontainer; + } + if ($curRes == $it->END_MAP()) { + $depth--; + $lastcontainer = $parent{$depth}; + } + if (ref($curRes)) { + my $symb = $curRes->symb(); + my $color = $count%2; + $display .=''; + if ($discussiontime{$symb} > 0) { + $boards ++; + $currelem = $count+$boards+$startcount; + $display .= ''."\n"; + } else { + $display .= ''."\n"; + } + } + } + my $scripttag = qq| + + |; + $r->print('Export Course'.$scripttag.''. + &Apache::loncommon::bodytag('Export course to IMS or SCORM content package' +)); + + $r->print($display.'
Export content item?
 '."\n"; + if ($numdisc > 0) { + $display.='Export discussion posts?'."\n"; + } + $display.=' 
'."\n". + 'is_sequence()) || ($curRes->is_page())) { + my $checkitem = $count + $boards + $startcount; + $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"'; + } + $display .= ' />'."\n"; + for (my $i=0; $i<$depth; $i++) { + $display .= ''."\n"; + } + if ($curRes->is_sequence()) { + $display .= ' '."\n"; + $lastcontainer = $count + $startcount + $boards; + } elsif ($curRes->is_page()) { + $display .= ' '."\n"; + $lastcontainer = $count + $startcount + $boards; + } + my $currelem = $count+$boards+$startcount; + $children{$parent{$depth}} .= $currelem.':'; + $display .= ' '.$curRes->title().'   
'. + '

'. + '

'); + } +} + # Imports the given (name, url) resources into the course # coursenum, coursedom, and folder must precede the list @@ -1089,6 +1286,8 @@ sub handler { &checkversions($r); } elsif ($ENV{'form.dumpcourse'}) { &dumpcourse($r); + } elsif ($ENV{'form.exportcourse'}) { + &exportcourse($r); } else { # is this a standard course? @@ -1293,6 +1492,7 @@ ENDNEWSCRIPT # ----------------------------------------------------------------------------- if ($allowed) { my $dumpbut=&dumpbutton(); + my $exportbut=&exportbutton(); my %lt=&Apache::lonlocal::texthash( 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', @@ -1323,6 +1523,7 @@ ENDNEWSCRIPT $help{'Check_Resource_Versions'} $dumpbut +$exportbut ENDCOURSEVERIFY