--- loncom/interface/londocs.pm 2007/07/07 00:53:24 1.287 +++ loncom/interface/londocs.pm 2008/11/18 19:14:22 1.316 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.287 2007/07/07 00:53:24 albertel Exp $ +# $Id: londocs.pm,v 1.316 2008/11/18 19:14:22 jms Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,6 +26,22 @@ # http://www.lon-capa.org/ # + +=head1 NAME + +Apache::londocs.pm + +=head1 SYNOPSIS + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + +=head1 SUBROUTINES + +=over + +=cut + package Apache::londocs; use strict; @@ -53,15 +69,27 @@ my %alreadyseen=(); my $hadchanges; -# Available help topics + +=pod + +=item %help=() + + Available help topics + +=cut my %help=(); -# Mapread read maps into LONCAPA::map:: global arrays -# @order and @resources, determines status -# sets @order - pointer to resources in right order -# sets @resources - array with the resources with correct idx -# +=pod + +=item mapread() + +Mapread read maps into LONCAPA::map:: global arrays +@order and @resources, determines status +sets @order - pointer to resources in right order +sets @resources - array with the resources with correct idx + +=cut sub mapread { my ($coursenum,$coursedom,$map)=@_; @@ -81,7 +109,14 @@ sub storemap { return ($errtext,0); } -# ----------------------------------------- Return hash with valid author names + +=pod + +=item authorhosts() + + Return hash with valid author names + +=cut sub authorhosts { my %outhash=(); @@ -116,7 +151,13 @@ sub authorhosts { } return ($home,$other,%outhash); } -# ------------------------------------------------------ Generate "dump" button +=pod + +=item dumpbutton() + + Generate "dump" button + +=cut sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); @@ -141,7 +182,14 @@ sub clean { $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; return $title; } -# -------------------------------------------------------- Actually dump course + +=pod + +=item dumpcourse() + + Actually dump course + +=cut sub dumpcourse { my ($r) = @_; @@ -228,11 +276,19 @@ sub dumpcourse { my $title=$origcrsdata{'description'}; $title=~s/[\/\s]+/\_/gs; $title=&clean($title); - $r->print('

'.&mt('Folder in Construction Space').'


'); + $r->print('

'.&mt('Folder in Construction Space').'

' + .'
'); &tiehash(); - $r->print('

'.&mt('Filenames in Construction Space').'

'); + $r->print('

'.&mt('Filenames in Construction Space').'

' + .&Apache::loncommon::start_data_table() + .&Apache::loncommon::start_data_table_header_row() + .'' + .'' + .'' + .&Apache::loncommon::end_data_table_header_row()); foreach (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { - $r->print(''); + $r->print(&Apache::loncommon::start_data_table_row() + .''); my ($ext)=($_=~/\.(\w+)$/); my $title=$hash{'title_'.$hash{ 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}}; @@ -245,16 +301,23 @@ sub dumpcourse { $title=~s/\.(\w+)$//; $title=&clean($title); $title.='.'.$ext; - $r->print("\n\n"); + $r->print("\n" + .&Apache::loncommon::end_data_table_row()); } - $r->print("
'.&mt('Internal Filename').''.&mt('Title').''.&mt('Save as ...').'
'.&mt('Internal Filename').''.&mt('Title').''.&mt('Save as ...').'
'.$_.''.$_.'
\n"); + $r->print(&Apache::loncommon::end_data_table()); &untiehash(); $r->print( - '

'); + '

'); } } -# ------------------------------------------------------ Generate "export" button +=pod + +=item exportbutton() + + Generate "export" button + +=cut sub exportbutton { my $type = &Apache::loncommon::course_type(); @@ -264,6 +327,12 @@ sub exportbutton { &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').''; } +=pod + +=item exportcourse() + +=cut + sub exportcourse { my $r=shift; my $type = &Apache::loncommon::course_type(); @@ -309,10 +378,10 @@ sub exportcourse { chdir $cwd; $outcome .= &mt('Download the zip file from IMS '.lc($type).' archive
',$imszipfile,); if ($copyresult) { - $outcome .= 'The following errors occurred during export - '.$copyresult; + $outcome .= &mt('The following errors occurred during export - [_1]',$copyresult); } } else { - $outcome = '
Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.
'; + $outcome = '
'.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').'
'; } } $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package')); @@ -818,7 +887,7 @@ sub extract_media { $dirpath = $url; $container = ''; } - &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content); + &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content); foreach my $embed_file (keys(%allfiles)) { my $filename; if ($embed_file =~ m#([^/]+)$#) { @@ -902,8 +971,15 @@ sub store_template { } } -# Imports the given (name, url) resources into the course -# coursenum, coursedom, and folder must precede the list +=pod + +=item group_import() + + Imports the given (name, url) resources into the course + coursenum, coursedom, and folder must precede the list + +=cut + sub group_import { my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; @@ -924,7 +1000,7 @@ sub group_import { my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom, 'output',$1.$2); if ($result != m|^/uploaded/|) { - $errtext.='Map not saved: A network error occured when trying to save the new map. '; + $errtext.='Map not saved: A network error occurred when trying to save the new map. '; $fatal = 2; } if ($fatal) { @@ -932,9 +1008,10 @@ sub group_import { } } if ($url) { - if (!$residx) { - $residx = &LONCAPA::map::getresidx($url); - $LONCAPA::map::order[$#LONCAPA::map::order+1]=$residx; + if (!$residx + || defined($LONCAPA::map::zombies[$residx])) { + $residx = &LONCAPA::map::getresidx($url,$residx); + push(@LONCAPA::map::order, $residx); } my $ext = 'false'; if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } @@ -948,7 +1025,7 @@ sub group_import { } sub breadcrumbs { - my ($where)=@_; + my ($where,$allowed,$type)=@_; &Apache::lonhtmlcommon::clear_breadcrumbs(); my (@folders); if ($env{'form.pagepath'}) { @@ -962,23 +1039,32 @@ sub breadcrumbs { my $randompick=-1; my $isencrypted=0; my $ishidden=0; + my $is_random_order=0; while (@folders) { my $folder=shift(@folders); - my $foldername=shift(@folders); + my $foldername=shift(@folders); if ($folderpath) {$folderpath.='&';} $folderpath.=$folder.'&'.$foldername; my $url='/adm/coursedocs?folderpath='. &escape($folderpath); - my $name=&unescape($foldername); -# randompick number, hidden, encrypted is appended with ":"s to the foldername - $name=~s/\:(\d*)\:(\w*)\:(\w*)$//; - if ($1 ne '') { + my $name=&unescape($foldername); +# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername + $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; + if ($1 ne '') { $randompick=$1; } else { $randompick=-1; } if ($2) { $ishidden=1; } if ($3) { $isencrypted=1; } + if ($4 ne '') { $is_random_order = 1; } + if ($folder eq 'supplemental') { + if ($allowed) { + $name = &mt('Supplemental '.$type.' Documents'); + } else { + $name = &mt($type.' Documents'); + } + } &Apache::lonhtmlcommon::add_breadcrumb( {'href'=>$url.$cpinfo, 'title'=>$name, @@ -990,7 +1076,7 @@ sub breadcrumbs { } $plain=~s/\>\;\s*$//; return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', - 'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain); + 'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); } sub log_docs { @@ -1054,10 +1140,12 @@ sub log_docs { } } +=pod + +=item docs_change_log() + +=cut -# -# Docs Change Log -# sub docs_change_log { my ($r)=@_; my $folder=$env{'form.folder'}; @@ -1081,6 +1169,7 @@ sub docs_change_log { my %lt=('hiddenresource' => 'Resources hidden', 'encrypturl' => 'URL hidden', 'randompick' => 'Randomly pick', + 'randomorder' => 'Randomly ordered', 'set' => 'set to', 'del' => 'deleted'); $r->print(&Apache::loncommon::display_filter(). @@ -1163,7 +1252,7 @@ sub docs_change_log { $r->print(''); if ($docslog{$id}{'logentry'}{'parameter_res'}) { $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':