version 1.208, 2005/11/04 20:52:35
|
version 1.328, 2009/01/28 13:24:54
|
Line 1
|
Line 1
|
# The LearningOnline Network |
# The LearningOnline Network
|
# Documents |
# Documents
|
# |
#
|
# $Id$ |
# $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).
|
# |
#
|
# LON-CAPA is free software; you can redistribute it and/or modify |
# 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 |
# it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 2 of the License, or |
# the Free Software Foundation; either version 2 of the License, or
|
# (at your option) any later version. |
# (at your option) any later version.
|
# |
#
|
# LON-CAPA is distributed in the hope that it will be useful, |
# LON-CAPA is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details. |
# GNU General Public License for more details.
|
# |
#
|
# You should have received a copy of the GNU General Public License |
# You should have received a copy of the GNU General Public License
|
# along with LON-CAPA; if not, write to the Free Software |
# along with LON-CAPA; if not, write to the Free Software
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# |
#
|
# /home/httpd/html/adm/gpl.txt |
# /home/httpd/html/adm/gpl.txt
|
# |
#
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/
|
# |
#
|
|
|
package Apache::londocs; |
|
|
|
use strict; |
package Apache::londocs;
|
use Apache::Constants qw(:common :http); |
|
use Apache::imsexport; |
use strict;
|
use Apache::lonnet; |
use Apache::Constants qw(:common :http);
|
use Apache::loncommon; |
use Apache::imsexport;
|
use Apache::lonratedt; |
use Apache::lonnet;
|
use Apache::lonratsrv; |
use Apache::loncommon;
|
use Apache::lonxml; |
use LONCAPA::map();
|
use Apache::loncreatecourse; |
use Apache::lonratedt();
|
use Apache::lonnavmaps; |
use Apache::lonxml;
|
use HTML::Entities; |
use Apache::lonclonecourse;
|
use GDBM_File; |
use Apache::lonnavmaps;
|
use Apache::lonlocal; |
use HTML::Entities;
|
use Cwd; |
use GDBM_File;
|
|
use Apache::lonlocal;
|
my $iconpath; |
use Cwd;
|
|
use LONCAPA qw(:DEFAULT :match);
|
my %hash; |
|
|
my $iconpath;
|
my $hashtied; |
|
my %alreadyseen=(); |
my %hash;
|
|
|
my $hadchanges; |
my $hashtied;
|
|
my %alreadyseen=();
|
# Available help topics |
|
|
my $hadchanges;
|
my %help=(); |
|
|
|
# Mapread read maps into lonratedt::global arrays |
my %help=();
|
# @order and @resources, determines status |
|
# sets @order - pointer to resources in right order |
|
# sets @resources - array with the resources with correct idx |
sub mapread {
|
# |
my ($coursenum,$coursedom,$map)=@_;
|
|
return
|
sub mapread { |
&LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
|
my ($coursenum,$coursedom,$map)=@_; |
$map);
|
return |
}
|
&Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'. |
|
$map); |
sub storemap {
|
} |
my ($coursenum,$coursedom,$map)=@_;
|
|
my ($outtext,$errtext)=
|
sub storemap { |
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
|
my ($coursenum,$coursedom,$map)=@_; |
$map,1);
|
my ($outtext,$errtext)= |
if ($errtext) { return ($errtext,2); }
|
&Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. |
|
$map,1); |
$hadchanges=1;
|
if ($errtext) { return ($errtext,2); } |
return ($errtext,0);
|
|
}
|
$hadchanges=1; |
|
return ($errtext,0); |
|
} |
|
|
sub authorhosts {
|
# ----------------------------------------- Return hash with valid author names |
my %outhash=();
|
|
my $home=0;
|
sub authorhosts { |
my $other=0;
|
my %outhash=(); |
foreach my $key (keys(%env)) {
|
my $home=0; |
if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
|
my $other=0; |
my $role=$1;
|
foreach (keys %env) { |
my $realm=$2;
|
if ($_=~/^user\.role\.(au|ca)\.(.+)$/) { |
my ($start,$end)=split(/\./,$env{$key});
|
my $role=$1; |
if (($start) && ($start>time)) { next; }
|
my $realm=$2; |
if (($end) && (time>$end)) { next; }
|
my ($start,$end)=split(/\./,$env{$_}); |
my ($ca,$cd);
|
if (($start) && ($start>time)) { next; } |
if ($1 eq 'au') {
|
if (($end) && (time>$end)) { next; } |
$ca=$env{'user.name'};
|
my $ca; my $cd; |
$cd=$env{'user.domain'};
|
if ($1 eq 'au') { |
} else {
|
$ca=$env{'user.name'}; |
($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
|
$cd=$env{'user.domain'}; |
}
|
} else { |
my $allowed=0;
|
($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); |
my $myhome=&Apache::lonnet::homeserver($ca,$cd);
|
} |
my @ids=&Apache::lonnet::current_machine_ids();
|
my $allowed=0; |
foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
|
my $myhome=&Apache::lonnet::homeserver($ca,$cd); |
if ($allowed) {
|
my @ids=&Apache::lonnet::current_machine_ids(); |
$home++;
|
foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } } |
$outhash{'home_'.$ca.'@'.$cd}=1;
|
if ($allowed) { |
} else {
|
$home++; |
$outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
|
$outhash{'home_'.$ca.'@'.$cd}=1; |
$other++;
|
} else { |
}
|
$outhash{'otherhome_'.$ca.'@'.$cd}=$myhome; |
}
|
$other++; |
}
|
} |
return ($home,$other,%outhash);
|
} |
}
|
} |
|
return ($home,$other,%outhash); |
|
} |
sub dumpbutton {
|
# ------------------------------------------------------ Generate "dump" button |
my ($home,$other,%outhash)=&authorhosts();
|
|
my $type = &Apache::loncommon::course_type();
|
sub dumpbutton { |
if ($home+$other==0) { return ''; }
|
my ($home,$other,%outhash)=&authorhosts(); |
if ($home) {
|
if ($home+$other==0) { return ''; } |
return '<input type="submit" name="dumpcourse" value="'.
|
my $output='</td><td bgcolor="#DDDDCC">'; |
&mt('Dump '.$type.' DOCS to Construction Space').'" />'.
|
if ($home) { |
&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
|
return '</td><td bgcolor="#DDDDCC">'. |
} else {
|
'<input type="submit" name="dumpcourse" value="'. |
return '<div>'.
|
&mt('Dump Course DOCS to Construction Space').'" />'. |
&mt('Dump '.$type.
|
&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs'); |
' DOCS to Construction Space: available on other servers').
|
} else { |
'</div>';
|
return'</td><td bgcolor="#DDDDCC">'. |
}
|
&mt('Dump Course DOCS to Construction Space: available on other servers'); |
}
|
} |
|
} |
sub clean {
|
|
my ($title)=@_;
|
sub clean { |
$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
|
my ($title)=@_; |
return $title;
|
$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; |
}
|
return $title; |
|
} |
|
# -------------------------------------------------------- Actually dump course |
|
|
sub dumpcourse {
|
sub dumpcourse { |
my ($r) = @_;
|
my $r=shift; |
my $type = &Apache::loncommon::course_type();
|
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
|
$r->print($html.'<head><title>Dump DOCS</title></head>'. |
'<form name="dumpdoc" method="post">');
|
&Apache::loncommon::bodytag('Dump Course DOCS to Construction Space'). |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space'));
|
'<form name="dumpdoc" method="post">'); |
my ($home,$other,%outhash)=&authorhosts();
|
my ($home,$other,%outhash)=&authorhosts(); |
unless ($home) { return ''; }
|
unless ($home) { return ''; } |
my $origcrsid=$env{'request.course.id'};
|
my $origcrsid=$env{'request.course.id'}; |
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
|
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); |
if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
|
if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) { |
# Do the dumping
|
# Do the dumping |
unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; }
|
unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; } |
my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
|
my ($ca,$cd)=split(/\@/,$env{'form.authorspace'}); |
$r->print('<h3>'.&mt('Copying Files').'</h3>');
|
$r->print('<h3>'.&mt('Copying Files').'</h3>'); |
my $title=$env{'form.authorfolder'};
|
my $title=$env{'form.authorfolder'}; |
$title=&clean($title);
|
$title=&clean($title); |
my %replacehash=();
|
my %replacehash=(); |
foreach my $key (keys(%env)) {
|
foreach (keys %env) { |
if ($key=~/^form\.namefor\_(.+)/) {
|
if ($_=~/^form\.namefor\_(.+)/) { |
$replacehash{$1}=$env{$key};
|
$replacehash{$1}=$env{$_}; |
}
|
} |
}
|
} |
my $crs='/uploaded/'.$env{'request.course.id'}.'/';
|
my $crs='/uploaded/'.$env{'request.course.id'}.'/'; |
$crs=~s/\_/\//g;
|
$crs=~s/\_/\//g; |
foreach my $item (keys(%replacehash)) {
|
foreach (keys %replacehash) { |
my $newfilename=$title.'/'.$replacehash{$item};
|
my $newfilename=$title.'/'.$replacehash{$_}; |
$newfilename=~s/\.(\w+)$//;
|
$newfilename=~s/\.(\w+)$//; |
my $ext=$1;
|
my $ext=$1; |
$newfilename=&clean($newfilename);
|
$newfilename=&clean($newfilename); |
$newfilename.='.'.$ext;
|
$newfilename.='.'.$ext; |
my @dirs=split(/\//,$newfilename);
|
my @dirs=split(/\//,$newfilename); |
my $path='/home/'.$ca.'/public_html';
|
my $path='/home/'.$ca.'/public_html'; |
my $makepath=$path;
|
my $makepath=$path; |
my $fail=0;
|
my $fail=0; |
for (my $i=0;$i<$#dirs;$i++) {
|
for (my $i=0;$i<$#dirs;$i++) { |
$makepath.='/'.$dirs[$i];
|
$makepath.='/'.$dirs[$i]; |
unless (-e $makepath) {
|
unless (-e $makepath) { |
unless(mkdir($makepath,0777)) { $fail=1; }
|
unless(mkdir($makepath,0777)) { $fail=1; } |
}
|
} |
}
|
} |
$r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
|
$r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: '); |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
|
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
|
if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) { |
print $fh &Apache::lonclonecourse::rewritefile(
|
print $fh &Apache::loncreatecourse::rewritefile( |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
|
&Apache::loncreatecourse::readfile($env{'request.course.id'},$_), |
(%replacehash,$crs => '')
|
(%replacehash,$crs => '') |
);
|
); |
} else {
|
} else { |
print $fh
|
print $fh |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
|
&Apache::loncreatecourse::readfile($env{'request.course.id'},$_); |
}
|
} |
$fh->close();
|
$fh->close(); |
} else {
|
} else { |
$fail=1;
|
$fail=1; |
}
|
} |
if ($fail) {
|
if ($fail) { |
$r->print('<span class="LC_error">'.&mt('fail').'</span>');
|
$r->print('<font color="red">fail</font>'); |
} else {
|
} else { |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
$r->print('<font color="green">ok</font>'); |
}
|
} |
}
|
} |
} else {
|
} else { |
# Input form
|
# Input form |
unless ($home==1) {
|
unless ($home==1) { |
$r->print(
|
$r->print( |
'<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
|
'<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">'); |
}
|
} |
foreach my $key (sort(keys(%outhash))) {
|
foreach (sort keys %outhash) { |
if ($key=~/^home_(.+)$/) {
|
if ($_=~/^home_(.+)$/) { |
if ($home==1) {
|
if ($home==1) { |
$r->print(
|
$r->print( |
'<input type="hidden" name="authorspace" value="'.$1.'" />');
|
'<input type="hidden" name="authorspace" value="'.$1.'" />'); |
} else {
|
} else { |
$r->print('<option value="'.$1.'">'.$1.' - '.
|
$r->print('<option value="'.$1.'">'.$1.' - '. |
&Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
|
&Apache::loncommon::plainname(split(/\@/,$1)).'</option>'); |
}
|
} |
}
|
} |
}
|
} |
unless ($home==1) {
|
unless ($home==1) { |
$r->print('</select>');
|
$r->print('</select>'); |
}
|
} |
my $title=$origcrsdata{'description'};
|
my $title=$origcrsdata{'description'}; |
$title=~s/[\/\s]+/\_/gs;
|
$title=~s/\s+/\_/gs; |
$title=&clean($title);
|
$title=&clean($title); |
$r->print('<h3>'.&mt('Folder in Construction Space').'</h3>'
|
$r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />'); |
.'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
|
&tiehash(); |
&tiehash();
|
$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>'); |
$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>'
|
foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) { |
.&Apache::loncommon::start_data_table()
|
$r->print('<tr><td>'.$_.'</td>'); |
.&Apache::loncommon::start_data_table_header_row()
|
my ($ext)=($_=~/\.(\w+)$/); |
.'<th>'.&mt('Internal Filename').'</th>'
|
my $title=$hash{'title_'.$hash{ |
.'<th>'.&mt('Title').'</th>'
|
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}}; |
.'<th>'.&mt('Save as ...').'</th>'
|
$title=~s/:/:/g; |
.&Apache::loncommon::end_data_table_header_row());
|
$r->print('<td>'.($title?$title:' ').'</td>'); |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
|
unless ($title) { |
$r->print(&Apache::loncommon::start_data_table_row()
|
$title=$_; |
.'<td>'.$file.'</td>');
|
} |
my ($ext)=($file=~/\.(\w+)$/);
|
$title=~s/\.(\w+)$//; |
my $title=$hash{'title_'.$hash{
|
$title=&clean($title); |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
|
$title.='.'.$ext; |
$r->print('<td>'.($title?$title:' ').'</td>');
|
$r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n"); |
if (!$title) {
|
} |
$title=$file;
|
$r->print("</table>\n"); |
} else {
|
&untiehash(); |
$title=~s|/|_|g;
|
$r->print( |
}
|
'<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>'); |
$title=~s/\.(\w+)$//;
|
} |
$title=&clean($title);
|
} |
$title.='.'.$ext;
|
|
$r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
|
# ------------------------------------------------------ Generate "export" button |
.&Apache::loncommon::end_data_table_row());
|
|
}
|
sub exportbutton { |
$r->print(&Apache::loncommon::end_data_table());
|
return '</td><td bgcolor="#DDDDCC">'. |
&untiehash();
|
'<input type="submit" name="exportcourse" value="'. |
$r->print(
|
&mt('Export Course to IMS').'" />'. |
'<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $type DOCS").'" /></p></form>');
|
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); |
}
|
} |
}
|
|
|
sub exportcourse { |
|
my $r=shift; |
|
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
sub exportbutton {
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); |
my $type = &Apache::loncommon::course_type();
|
my $numdisc = keys %discussiontime; |
return '<input type="submit" name="exportcourse" value="'.
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
&mt('Export '.$type.' to IMS').'" />'.
|
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); |
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
|
my $curRes; |
}
|
my $outcome; |
|
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['finishexport']); |
sub exportcourse {
|
if ($env{'form.finishexport'}) { |
my $r=shift;
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
my $type = &Apache::loncommon::course_type();
|
['archive','discussion']); |
my %discussiontime = &Apache::lonnet::dump('discussiontimes',
|
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
|
my @exportitems = &Apache::loncommon::get_env_multiple('form.archive'); |
my $numdisc = keys(%discussiontime);
|
my @discussions = &Apache::loncommon::get_env_multiple('form.discussion'); |
my $navmap = Apache::lonnavmaps::navmap->new();
|
if (@exportitems == 0 && @discussions == 0) { |
if (!defined($navmap)) {
|
$outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created. Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export'; |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package').
|
} else { |
'<h2>IMS Export Failed</h2>'.
|
my $now = time; |
'<div class="LC_error">'.
|
my %symbs; |
&mt('Unable to retrieve information about course contents').
|
my $manifestok = 0; |
'</div><a href="/adm/coursedocs">'.&mt('Return to Course Editor').'</a>');
|
my $imsresources; |
&Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
|
my $tempexport; |
return;
|
my $copyresult; |
}
|
my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport); |
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
|
if ($manifestok) { |
my $curRes;
|
&build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest); |
my $outcome;
|
close($ims_manifest); |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
#Create zip file in prtspool |
['finishexport']);
|
my $imszipfile = '/prtspool/'. |
if ($env{'form.finishexport'}) {
|
$env{'user.name'}.'_'.$env{'user.domain'}.'_'. |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
time.'_'.rand(1000000000).'.zip'; |
['archive','discussion']);
|
my $cwd = &Cwd::getcwd(); |
|
my $imszip = '/home/httpd/'.$imszipfile; |
my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
|
chdir $tempexport; |
my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
|
open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); |
if (@exportitems == 0 && @discussions == 0) {
|
close(OUTPUT); |
$outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created. Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
|
chdir $cwd; |
} else {
|
$outcome .= 'Download the zip file from <a href="'.$imszipfile.'">IMS course archive</a><br />'; |
my $now = time;
|
if ($copyresult) { |
my %symbs;
|
$outcome .= 'The following errors occurred during export - '.$copyresult; |
my $manifestok = 0;
|
} |
my $imsresources;
|
} else { |
my $tempexport;
|
$outcome = '<br />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.<br />'; |
my $copyresult;
|
} |
my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
|
} |
if ($manifestok) {
|
my $html=&Apache::lonxml::xmlbegin(); |
&build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest);
|
$r->print($html.'<head><title>Export Course</title></head>'. |
close($ims_manifest);
|
&Apache::loncommon::bodytag('Export course to IMS content package')); |
|
$r->print($outcome); |
#Create zip file in prtspool
|
$r->print('</body></html>'); |
my $imszipfile = '/prtspool/'.
|
} else { |
$env{'user.name'}.'_'.$env{'user.domain'}.'_'.
|
my $display; |
time.'_'.rand(1000000000).'.zip';
|
$display = '<form name="exportdoc" method="post">'."\n"; |
my $cwd = &Cwd::getcwd();
|
$display .= 'Choose which items you wish to export from your course.<br /><br />'; |
my $imszip = '/home/httpd/'.$imszipfile;
|
$display .= '<table border="0" cellspacing="0" cellpadding="3">'. |
chdir $tempexport;
|
'<tr><td><fieldset><legend> <b>Content items</b></legend>'. |
open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
|
'<input type="button" value="check all" '. |
close(OUTPUT);
|
'onclick="javascript:checkAll(document.exportdoc.archive)" />'. |
chdir $cwd;
|
' <input type="button" value="uncheck all"'. |
$outcome .= &mt('Download the zip file from <a href="[_1]">IMS '.lc($type).' archive</a><br />',$imszipfile,);
|
' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'. |
if ($copyresult) {
|
'<td> </td><td> </td>'. |
$outcome .= &mt('The following errors occurred during export - [_1]',$copyresult);
|
'<td align="right"><fieldset><legend> <b>Discussion posts'. |
}
|
'</b></legend><input type="button" value="check all"'. |
} else {
|
' onclick="javascript:checkAll(document.exportdoc.discussion)" />'. |
$outcome = '<br />'.&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.').'<br />';
|
' <input type="button" value="uncheck all"'. |
}
|
' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'. |
}
|
'</tr></table>'; |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
|
my $curRes; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
|
my $depth = 0; |
$r->print($outcome);
|
my $count = 0; |
$r->print(&Apache::loncommon::end_page());
|
my $boards = 0; |
} else {
|
my $startcount = 5; |
my $display;
|
my %parent = (); |
$display = '<form name="exportdoc" method="post">'."\n";
|
my %children = (); |
$display .= &mt('Choose which items you wish to export from your '.$type.'.<br /><br />');
|
my $lastcontainer = $startcount; |
$display .= '<table border="0" cellspacing="0" cellpadding="3">'.
|
my @bgcolors = ('#F6F6F6','#FFFFFF'); |
'<tr><td><fieldset><legend> <b>Content items</b></legend>'.
|
$display .= '<table cellspacing="0"><tr>'. |
'<input type="button" value="check all" '.
|
'<td><b>Export content item?<br /></b></td><td> </td><td align="right">'."\n"; |
'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
|
if ($numdisc > 0) { |
' <input type="button" value="uncheck all"'.
|
$display.='<b>Export discussion posts?</b>'."\n"; |
' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
|
} |
'<td> </td><td> </td>'.
|
$display.=' </td></tr>'; |
'<td align="right"><fieldset><legend> <b>Discussion posts'.
|
while ($curRes = $it->next()) { |
'</b></legend><input type="button" value="check all"'.
|
if (ref($curRes)) { |
' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
|
$count ++; |
' <input type="button" value="uncheck all"'.
|
} |
' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
|
if ($curRes == $it->BEGIN_MAP()) { |
'</tr></table>';
|
$depth++; |
my $curRes;
|
$parent{$depth} = $lastcontainer; |
my $depth = 0;
|
} |
my $count = 0;
|
if ($curRes == $it->END_MAP()) { |
my $boards = 0;
|
$depth--; |
my $startcount = 5;
|
$lastcontainer = $parent{$depth}; |
my %parent = ();
|
} |
my %children = ();
|
if (ref($curRes)) { |
my $lastcontainer = $startcount;
|
my $symb = $curRes->symb(); |
my @bgcolors = ('#F6F6F6','#FFFFFF');
|
my $ressymb = $symb; |
$display .= '<table cellspacing="0"><tr>'.
|
if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { |
'<td><b>Export content item?<br /></b></td><td> </td><td align="right">'."\n";
|
unless ($ressymb =~ m|adm/wrapper/adm|) { |
if ($numdisc > 0) {
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
$display.='<b>Export discussion posts?</b>'."\n";
|
} |
}
|
} |
$display.=' </td></tr>';
|
my $color = $count%2; |
while ($curRes = $it->next()) {
|
$display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n". |
if (ref($curRes)) {
|
'<input type="checkbox" name="archive" value="'.$count.'" '; |
$count ++;
|
if (($curRes->is_sequence()) || ($curRes->is_page())) { |
}
|
my $checkitem = $count + $boards + $startcount; |
if ($curRes == $it->BEGIN_MAP()) {
|
$display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"'; |
$depth++;
|
} |
$parent{$depth} = $lastcontainer;
|
$display .= ' />'."\n"; |
}
|
for (my $i=0; $i<$depth; $i++) { |
if ($curRes == $it->END_MAP()) {
|
$display .= '<img src="/adm/lonIcons/whitespace1.gif" width="25" height="1" alt="" border="0" /><img src="/adm/lonIcons/whitespace1.gif" width="25" height="1" alt="" border="0" />'."\n"; |
$depth--;
|
} |
$lastcontainer = $parent{$depth};
|
if ($curRes->is_sequence()) { |
}
|
$display .= '<img src="/adm/lonIcons/navmap.folder.open.gif"> '."\n"; |
if (ref($curRes)) {
|
$lastcontainer = $count + $startcount + $boards; |
my $symb = $curRes->symb();
|
} elsif ($curRes->is_page()) { |
my $ressymb = $symb;
|
$display .= '<img src="/adm/lonIcons/navmap.page.open.gif"> '."\n"; |
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
|
$lastcontainer = $count + $startcount + $boards; |
unless ($ressymb =~ m|adm/wrapper/adm|) {
|
} |
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
|
my $currelem = $count+$boards+$startcount; |
}
|
$children{$parent{$depth}} .= $currelem.':'; |
}
|
$display .= ' '.$curRes->title().'</td>'; |
my $color = $count%2;
|
if ($discussiontime{$ressymb} > 0) { |
$display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
|
$boards ++; |
'<input type="checkbox" name="archive" value="'.$count.'" ';
|
$currelem = $count+$boards+$startcount; |
if (($curRes->is_sequence()) || ($curRes->is_page())) {
|
$display .= '<td> </td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" /> </td>'."\n"; |
my $checkitem = $count + $boards + $startcount;
|
} else { |
$display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
|
$display .= '<td colspan="2"> </td>'."\n"; |
}
|
} |
$display .= ' />'."\n";
|
} |
for (my $i=0; $i<$depth; $i++) {
|
} |
$display .= '<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" /><img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" />'."\n";
|
my $scripttag = qq| |
}
|
<script> |
if ($curRes->is_sequence()) {
|
|
$display .= '<img src="/adm/lonIcons/navmap.folder.open.gif"> '."\n";
|
function checkAll(field) { |
$lastcontainer = $count + $startcount + $boards;
|
if (field.length > 0) { |
} elsif ($curRes->is_page()) {
|
for (i = 0; i < field.length; i++) { |
$display .= '<img src="/adm/lonIcons/navmap.page.open.gif"> '."\n";
|
field[i].checked = true ; |
$lastcontainer = $count + $startcount + $boards;
|
} |
}
|
} else { |
my $currelem = $count+$boards+$startcount;
|
field.checked = true |
$children{$parent{$depth}} .= $currelem.':';
|
} |
$display .= ' '.$curRes->title().'</td>';
|
} |
if ($discussiontime{$ressymb} > 0) {
|
|
$boards ++;
|
function uncheckAll(field) { |
$currelem = $count+$boards+$startcount;
|
if (field.length > 0) { |
$display .= '<td> </td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" /> </td>'."\n";
|
for (i = 0; i < field.length; i++) { |
} else {
|
field[i].checked = false ; |
$display .= '<td colspan="2"> </td>'."\n";
|
} |
}
|
} else { |
}
|
field.checked = false ; |
}
|
} |
my $scripttag = qq|
|
} |
<script>
|
|
|
function propagateCheck(item) { |
function checkAll(field) {
|
if (document.exportdoc.elements[item].checked == true) { |
if (field.length > 0) {
|
containerCheck(item) |
for (i = 0; i < field.length; i++) {
|
} |
field[i].checked = true ;
|
} |
}
|
|
} else {
|
function containerCheck(item) { |
field.checked = true
|
document.exportdoc.elements[item].checked = true |
}
|
var numitems = $count + $boards + $startcount |
}
|
var parents = new Array(numitems) |
|
for (var i=$startcount; i<numitems; i++) { |
function uncheckAll(field) {
|
parents[i] = new Array |
if (field.length > 0) {
|
} |
for (i = 0; i < field.length; i++) {
|
|; |
field[i].checked = false ;
|
|
}
|
foreach my $container (sort { $a <=> $b } keys %children) { |
} else {
|
my @contents = split/:/,$children{$container}; |
field.checked = false ;
|
for (my $i=0; $i<@contents; $i ++) { |
}
|
$scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n"; |
}
|
} |
|
} |
function propagateCheck(item) {
|
|
if (document.exportdoc.elements[item].checked == true) {
|
$scripttag .= qq| |
containerCheck(item)
|
if (parents[item].length > 0) { |
}
|
for (var j=0; j<parents[item].length; j++) { |
}
|
containerCheck(parents[item][j]) |
|
} |
function containerCheck(item) {
|
} |
document.exportdoc.elements[item].checked = true
|
} |
var numitems = $count + $boards + $startcount
|
|
var parents = new Array(numitems)
|
</script> |
for (var i=$startcount; i<numitems; i++) {
|
|; |
parents[i] = new Array
|
my $html=&Apache::lonxml::xmlbegin(); |
}
|
$r->print($html.'<head><title>Export Course</title>'.$scripttag.'</head>'. |
|;
|
&Apache::loncommon::bodytag('Export course to IMS content package' |
|
)); |
foreach my $container (sort { $a <=> $b } (keys(%children))) {
|
|
my @contents = split(/:/,$children{$container});
|
$r->print($display.'</table>'. |
for (my $i=0; $i<@contents; $i ++) {
|
'<p><input type="hidden" name="finishexport" value="1">'. |
$scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
|
'<input type="submit" name="exportcourse" value="'. |
}
|
&mt('Export Course DOCS').'" /></p></form></body></html>'); |
}
|
} |
|
} |
$scripttag .= qq|
|
|
if (parents[item].length > 0) {
|
sub create_ims_store { |
for (var j=0; j<parents[item].length; j++) {
|
my ($now,$manifestok,$outcome,$tempexport) = @_; |
containerCheck(parents[item][j])
|
$$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports'; |
}
|
my $ims_manifest; |
}
|
if (!-e $$tempexport) { |
}
|
mkdir($$tempexport,0700); |
|
} |
</script>
|
$$tempexport .= '/'.$now; |
|;
|
if (!-e $$tempexport) { |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package',
|
mkdir($$tempexport,0700); |
$scripttag));
|
} |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
|
$$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'}; |
$r->print($display.'</table>'.
|
if (!-e $$tempexport) { |
'<p><input type="hidden" name="finishexport" value="1">'.
|
mkdir($$tempexport,0700); |
'<input type="submit" name="exportcourse" value="'.
|
} |
&mt('Export '.$type.' DOCS').'" /></p></form>');
|
if (!-e "$$tempexport/resources") { |
}
|
mkdir("$$tempexport/resources",0700); |
}
|
} |
|
# open manifest file |
sub create_ims_store {
|
my $manifest = '/imsmanifest.xml'; |
my ($now,$manifestok,$outcome,$tempexport) = @_;
|
my $manifestfilename = $$tempexport.$manifest; |
$$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
|
if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) { |
my $ims_manifest;
|
$$manifestok=1; |
if (!-e $$tempexport) {
|
print $ims_manifest |
mkdir($$tempexport,0700);
|
'<?xml version="1.0" encoding="UTF-8"?>'."\n". |
}
|
'<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'. |
$$tempexport .= '/'.$now;
|
' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'. |
if (!-e $$tempexport) {
|
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
mkdir($$tempexport,0700);
|
' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'. |
}
|
' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'. |
$$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
|
' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n". |
if (!-e $$tempexport) {
|
' <metadata> |
mkdir($$tempexport,0700);
|
<schema></schema> |
}
|
<imsmd:lom> |
if (!-e "$$tempexport/resources") {
|
<imsmd:general> |
mkdir("$$tempexport/resources",0700);
|
<imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier> |
}
|
<imsmd:title> |
# open manifest file
|
<imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring> |
my $manifest = '/imsmanifest.xml';
|
</imsmd:title> |
my $manifestfilename = $$tempexport.$manifest;
|
</imsmd:general> |
if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
|
</imsmd:lom> |
$$manifestok=1;
|
</metadata>'."\n". |
print $ims_manifest
|
' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n". |
'<?xml version="1.0" encoding="UTF-8"?>'."\n".
|
' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'. |
'<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
|
' structure="hierarchical">'."\n". |
' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
|
' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>' |
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
|
} else { |
' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.
|
$$outcome .= 'An error occurred opening the IMS manifest file.<br />' |
' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
|
; |
' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
|
} |
' <metadata>
|
return $ims_manifest; |
<schema></schema>
|
} |
<imsmd:lom>
|
|
<imsmd:general>
|
sub build_package { |
<imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier>
|
my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_; |
<imsmd:title>
|
# first iterator to look for dependencies |
<imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring>
|
my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef); |
</imsmd:title>
|
my $curRes; |
</imsmd:general>
|
my $count = 0; |
</imsmd:lom>
|
my $depth = 0; |
</metadata>'."\n".
|
my $lastcontainer = 0; |
' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".
|
my %parent = (); |
' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.
|
my @dependencies = (); |
' structure="hierarchical">'."\n".
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>'
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
} else {
|
while ($curRes = $it->next()) { |
$$outcome .= 'An error occurred opening the IMS manifest file.<br />'
|
if (ref($curRes)) { |
;
|
$count ++; |
}
|
} |
return $ims_manifest;
|
if ($curRes == $it->BEGIN_MAP()) { |
}
|
$depth++; |
|
$parent{$depth} = $lastcontainer; |
sub build_package {
|
} |
my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
|
if ($curRes == $it->END_MAP()) { |
# first iterator to look for dependencies
|
$depth--; |
my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
|
$lastcontainer = $parent{$depth}; |
my $curRes;
|
} |
my $count = 0;
|
if (ref($curRes)) { |
my $depth = 0;
|
if ($curRes->is_sequence() || $curRes->is_page()) { |
my $lastcontainer = 0;
|
$lastcontainer = $count; |
my %parent = ();
|
} |
my @dependencies = ();
|
if (grep/^$count$/,@$exportitems) { |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
|
&get_dependencies($exportitems,\%parent,$depth,\@dependencies); |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
|
} |
while ($curRes = $it->next()) {
|
} |
if (ref($curRes)) {
|
} |
$count ++;
|
# second iterator to build manifest and store resources |
}
|
$it = $navmap->getIterator(undef,undef,undef,1,undef,undef); |
if ($curRes == $it->BEGIN_MAP()) {
|
$depth = 0; |
$depth++;
|
my $prevdepth; |
$parent{$depth} = $lastcontainer;
|
$count = 0; |
}
|
my $imsresources; |
if ($curRes == $it->END_MAP()) {
|
my $pkgdepth; |
$depth--;
|
while ($curRes = $it->next()) { |
$lastcontainer = $parent{$depth};
|
if ($curRes == $it->BEGIN_MAP()) { |
}
|
$prevdepth = $depth; |
if (ref($curRes)) {
|
$depth++; |
if ($curRes->is_sequence() || $curRes->is_page()) {
|
} |
$lastcontainer = $count;
|
if ($curRes == $it->END_MAP()) { |
}
|
$prevdepth = $depth; |
if (grep(/^$count$/,@$exportitems)) {
|
$depth--; |
&get_dependencies($exportitems,\%parent,$depth,\@dependencies);
|
} |
}
|
|
}
|
if (ref($curRes)) { |
}
|
$count ++; |
# second iterator to build manifest and store resources
|
if ((grep/^$count$/,@$exportitems) || (grep/^$count$/,@dependencies)) { |
$it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
|
my $symb = $curRes->symb(); |
$depth = 0;
|
my $isvisible = 'true'; |
my $prevdepth;
|
my $resourceref; |
$count = 0;
|
if ($curRes->randomout()) { |
my $imsresources;
|
$isvisible = 'false'; |
my $pkgdepth;
|
} |
while ($curRes = $it->next()) {
|
unless ($curRes->is_sequence()) { |
if ($curRes == $it->BEGIN_MAP()) {
|
$resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"'; |
$prevdepth = $depth;
|
} |
$depth++;
|
my $step = $prevdepth - $depth; |
}
|
if (($step >= 0) && ($count > 1)) { |
if ($curRes == $it->END_MAP()) {
|
while ($step >= 0) { |
$prevdepth = $depth;
|
print $ims_manifest "\n".' </item>'."\n"; |
$depth--;
|
$step --; |
}
|
} |
|
} |
if (ref($curRes)) {
|
$prevdepth = $depth; |
$count ++;
|
|
if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) {
|
my $itementry = |
my $symb = $curRes->symb();
|
'<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count. |
my $isvisible = 'true';
|
'" isvisible="'.$isvisible.'" '.$resourceref.'>'. |
my $resourceref;
|
'<title>'.$curRes->title().'</title>'; |
if ($curRes->randomout()) {
|
print $ims_manifest "\n".$itementry; |
$isvisible = 'false';
|
|
}
|
unless ($curRes->is_sequence()) { |
unless ($curRes->is_sequence()) {
|
my $content_file; |
$resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';
|
my @hrefs = (); |
}
|
&process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport); |
my $step = $prevdepth - $depth;
|
if ($content_file) { |
if (($step >= 0) && ($count > 1)) {
|
$imsresources .= "\n". |
while ($step >= 0) {
|
' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count. |
print $ims_manifest "\n".' </item>'."\n";
|
'" type="webcontent" href="'.$content_file.'">'."\n". |
$step --;
|
' <file href="'.$content_file.'" />'."\n"; |
}
|
foreach (@hrefs) { |
}
|
$imsresources .= |
$prevdepth = $depth;
|
' <file href="'.$_.'" />'."\n"; |
|
} |
my $itementry =
|
if (grep/^$count$/,@$discussions) { |
'<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count.
|
my $ressymb = $symb; |
'" isvisible="'.$isvisible.'" '.$resourceref.'>'.
|
my $mode; |
'<title>'.$curRes->title().'</title>';
|
if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { |
print $ims_manifest "\n".$itementry;
|
unless ($ressymb =~ m|adm/wrapper/adm|) { |
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
unless ($curRes->is_sequence()) {
|
} |
my $content_file;
|
$mode = 'board'; |
my @hrefs = ();
|
} |
&process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport);
|
my %extras = ( |
if ($content_file) {
|
caller => 'imsexport', |
$imsresources .= "\n".
|
tempexport => $tempexport.'/resources', |
' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count.
|
count => $count |
'" type="webcontent" href="'.$content_file.'">'."\n".
|
); |
' <file href="'.$content_file.'" />'."\n";
|
my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras); |
foreach my $item (@hrefs) {
|
} |
$imsresources .=
|
$imsresources .= ' </resource>'."\n"; |
' <file href="'.$item.'" />'."\n";
|
} |
}
|
} |
if (grep(/^$count$/,@$discussions)) {
|
$pkgdepth = $depth; |
my $ressymb = $symb;
|
} |
my $mode;
|
} |
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
|
} |
unless ($ressymb =~ m|adm/wrapper/adm|) {
|
while ($pkgdepth > 0) { |
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
|
print $ims_manifest " </item>\n"; |
}
|
$pkgdepth --; |
$mode = 'board';
|
} |
}
|
my $resource_text = qq| |
my %extras = (
|
</organization> |
caller => 'imsexport',
|
</organizations> |
tempexport => $tempexport.'/resources',
|
<resources> |
count => $count
|
$imsresources |
);
|
</resources> |
my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
|
</manifest> |
}
|
|; |
$imsresources .= ' </resource>'."\n";
|
print $ims_manifest $resource_text; |
}
|
} |
}
|
|
$pkgdepth = $depth;
|
sub get_dependencies { |
}
|
my ($exportitems,$parent,$depth,$dependencies) = @_; |
}
|
if ($depth > 1) { |
}
|
if ((!grep/^$$parent{$depth}$/,@$exportitems) && (!grep/^$$parent{$depth}$/,@$dependencies)) { |
while ($pkgdepth > 0) {
|
push @$dependencies, $$parent{$depth}; |
print $ims_manifest " </item>\n";
|
if ($depth > 2) { |
$pkgdepth --;
|
&get_dependencies($exportitems,$parent,$depth-1,$dependencies); |
}
|
} |
my $resource_text = qq|
|
} |
</organization>
|
} |
</organizations>
|
} |
<resources>
|
|
$imsresources
|
sub process_content { |
</resources>
|
my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_; |
</manifest>
|
my $content_type; |
|;
|
my $message; |
print $ims_manifest $resource_text;
|
my @uploads = (); |
}
|
if ($curRes->is_sequence()) { |
|
$content_type = 'sequence'; |
sub get_dependencies {
|
} elsif ($curRes->is_page()) { |
my ($exportitems,$parent,$depth,$dependencies) = @_;
|
$content_type = 'page'; # need to handle individual items in pages. |
if ($depth > 1) {
|
} elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) { |
if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) {
|
$content_type = 'syllabus'; |
push(@{$dependencies},$$parent{$depth});
|
my $contents = &Apache::imsexport::templatedpage($content_type); |
if ($depth > 2) {
|
if ($contents) { |
&get_dependencies($exportitems,$parent,$depth-1,$dependencies);
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
}
|
} |
}
|
} elsif ($symb =~ m-\.sequence___\d+___ext-) { |
}
|
$content_type = 'external'; |
}
|
my $title = $curRes->title; |
|
my $contents = &Apache::imsexport::external($symb,$title); |
sub process_content {
|
if ($contents) { |
my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
my $content_type;
|
} |
my $message;
|
} elsif ($symb =~ m-adm/navmaps$-) { |
my @uploads = ();
|
$content_type = 'navmap'; |
if ($curRes->is_sequence()) {
|
} elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) { |
$content_type = 'sequence';
|
$content_type = 'simplepage'; |
} elsif ($curRes->is_page()) {
|
my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads); |
$content_type = 'page'; # need to handle individual items in pages.
|
if ($contents) { |
} elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
$content_type = 'syllabus';
|
} |
my $contents = &Apache::imsexport::templatedpage($content_type);
|
} elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) { |
if ($contents) {
|
$content_type = 'simpleproblem'; |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
my $contents = &Apache::imsexport::simpleproblem($symb); |
}
|
if ($contents) { |
} elsif ($symb =~ m-\.sequence___\d+___ext-) {
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
$content_type = 'external';
|
} |
my $title = $curRes->title;
|
} elsif ($symb =~ m-lib/templates/examupload\.problem$-) { |
my $contents = &Apache::imsexport::external($symb,$title);
|
$content_type = 'examupload'; |
if ($contents) {
|
} elsif ($symb =~ m-adm/(\w+)/(\w+)/(\d+)/bulletinboard$-) { |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
$content_type = 'bulletinboard'; |
}
|
my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2); |
} elsif ($symb =~ m-adm/navmaps$-) {
|
if ($contents) { |
$content_type = 'navmap';
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
} elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) {
|
} |
$content_type = 'simplepage';
|
} elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) { |
my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads);
|
$content_type = 'aboutme'; |
if ($contents) {
|
my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2); |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
if ($contents) { |
}
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
} elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) {
|
} |
$content_type = 'simpleproblem';
|
} elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) { |
my $contents = &Apache::imsexport::simpleproblem($symb);
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded'); |
if ($contents) {
|
} elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) { |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
my $canedit = 0; |
}
|
if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) { |
} elsif ($symb =~ m-lib/templates/examupload\.problem$-) {
|
$canedit= 1; |
$content_type = 'examupload';
|
} |
} elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) {
|
# only include problem code where current user is author |
$content_type = 'bulletinboard';
|
if ($canedit) { |
my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource'); |
if ($contents) {
|
} else { |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit'); |
}
|
} |
} elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) {
|
} elsif ($symb =~ m-uploaded/$cdom/$cnum-) { |
$content_type = 'aboutme';
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded'); |
my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2);
|
} |
if ($contents) {
|
if (@uploads > 0) { |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
foreach my $item (@uploads) { |
}
|
my $uploadmsg = ''; |
} elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
|
&replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload'); |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
|
if ($uploadmsg) { |
} elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
|
$$copyresult .= $uploadmsg."\n"; |
my $canedit = 0;
|
} |
if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) {
|
} |
$canedit= 1;
|
} |
}
|
if ($message) { |
# only include problem code where current user is author
|
$$copyresult .= $message."\n"; |
if ($canedit) {
|
} |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
|
} |
} else {
|
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
|
sub replicate_content { |
}
|
my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_; |
} elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
|
my ($map,$ind,$url); |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
|
if ($caller eq 'templateupload') { |
}
|
$url = $symb; |
if (@uploads > 0) {
|
$url =~ s#//#/#g; |
foreach my $item (@uploads) {
|
} else { |
my $uploadmsg = '';
|
($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); |
&replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload');
|
} |
if ($uploadmsg) {
|
my $content; |
$$copyresult .= $uploadmsg."\n";
|
my $filename; |
}
|
my $repstatus; |
}
|
my $content_name; |
}
|
if ($url =~ m-/([^/]+)$-) { |
if ($message) {
|
$filename = $1; |
$$copyresult .= $message."\n";
|
if (!-e $tempexport.'/resources') { |
}
|
mkdir($tempexport.'/resources',0700); |
}
|
} |
|
if (!-e $tempexport.'/resources/'.$count) { |
sub replicate_content {
|
mkdir($tempexport.'/resources/'.$count,0700); |
my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;
|
} |
my ($map,$ind,$url);
|
my $destination = $tempexport.'/resources/'.$count.'/'.$filename; |
if ($caller eq 'templateupload') {
|
my $copiedfile; |
$url = $symb;
|
if ($copiedfile = Apache::File->new('>'.$destination)) { |
$url =~ s#//#/#g;
|
my $content; |
} else {
|
if ($caller eq 'resource') { |
($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
|
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; |
}
|
my $filepath = &Apache::lonnet::filelocation($respath,$url); |
my $content;
|
$content = &Apache::lonnet::getfile($filepath); |
my $filename;
|
if ($content eq -1) { |
my $repstatus;
|
$$message = 'Could not copy file '.$filename; |
my $content_name;
|
} else { |
if ($url =~ m-/([^/]+)$-) {
|
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource'); |
$filename = $1;
|
$repstatus = 'ok'; |
if (!-e $tempexport.'/resources') {
|
} |
mkdir($tempexport.'/resources',0700);
|
} elsif ($caller eq 'uploaded' || $caller eq 'templateupload') { |
}
|
my $rtncode; |
if (!-e $tempexport.'/resources/'.$count) {
|
$repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode); |
mkdir($tempexport.'/resources/'.$count,0700);
|
if ($repstatus eq 'ok') { |
}
|
if ($url =~ /\.html?$/i) { |
my $destination = $tempexport.'/resources/'.$count.'/'.$filename;
|
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded'); |
my $copiedfile;
|
} |
if ($copiedfile = Apache::File->new('>'.$destination)) {
|
} else { |
my $content;
|
$$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n"; |
if ($caller eq 'resource') {
|
} |
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
|
} elsif ($caller eq 'noedit') { |
my $filepath = &Apache::lonnet::filelocation($respath,$url);
|
# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. |
$content = &Apache::lonnet::getfile($filepath);
|
$repstatus = 'ok'; |
if ($content eq -1) {
|
$content = 'Not the owner of this resource'; |
$$message = 'Could not copy file '.$filename;
|
} |
} else {
|
if ($repstatus eq 'ok') { |
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource');
|
print $copiedfile $content; |
$repstatus = 'ok';
|
} |
}
|
close($copiedfile); |
} elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
|
} else { |
my $rtncode;
|
$$message = 'Could not open destination file for '.$filename."<br />\n"; |
$repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
|
} |
if ($repstatus eq 'ok') {
|
} else { |
if ($url =~ /\.html?$/i) {
|
$$message = 'Could not determine name of file for '.$symb."<br />\n"; |
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded');
|
} |
}
|
if ($repstatus eq 'ok') { |
} else {
|
$content_name = 'resources/'.$count.'/'.$filename; |
$$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n";
|
} |
}
|
return $content_name; |
} elsif ($caller eq 'noedit') {
|
} |
# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this.
|
|
$repstatus = 'ok';
|
sub extract_media { |
$content = 'Not the owner of this resource';
|
my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_; |
}
|
my ($dirpath,$container); |
if ($repstatus eq 'ok') {
|
my %allfiles = (); |
print $copiedfile $content;
|
my %codebase = (); |
}
|
if ($url =~ m-(.*/)([^/]+)$-) { |
close($copiedfile);
|
$dirpath = $1; |
} else {
|
$container = $2; |
$$message = 'Could not open destination file for '.$filename."<br />\n";
|
} else { |
}
|
$dirpath = $url; |
} else {
|
$container = ''; |
$$message = 'Could not determine name of file for '.$symb."<br />\n";
|
} |
}
|
&Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content); |
if ($repstatus eq 'ok') {
|
foreach my $embed_file (keys(%allfiles)) { |
$content_name = 'resources/'.$count.'/'.$filename;
|
my $filename; |
}
|
if ($embed_file =~ m#([^/]+)$#) { |
return $content_name;
|
$filename = $1; |
}
|
} else { |
|
$filename = $embed_file; |
sub extract_media {
|
} |
my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
|
my $newname = 'res/'.$filename; |
my ($dirpath,$container);
|
my ($rtncode,$embed_content,$repstatus); |
my %allfiles = ();
|
my $embed_url; |
my %codebase = ();
|
if ($embed_file =~ m-^/-) { |
if ($url =~ m-(.*/)([^/]+)$-) {
|
$embed_url = $embed_file; # points to absolute path |
$dirpath = $1;
|
} else { |
$container = $2;
|
if ($embed_file =~ m-https?://-) { |
} else {
|
next; # points to url |
$dirpath = $url;
|
} else { |
$container = '';
|
$embed_url = $dirpath.$embed_file; # points to relative path |
}
|
} |
&Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
|
} |
foreach my $embed_file (keys(%allfiles)) {
|
if ($caller eq 'resource') { |
my $filename;
|
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; |
if ($embed_file =~ m#([^/]+)$#) {
|
my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url); |
$filename = $1;
|
$embed_content = &Apache::lonnet::getfile($embed_path); |
} else {
|
unless ($embed_content eq -1) { |
$filename = $embed_file;
|
$repstatus = 'ok'; |
}
|
} |
my $newname = 'res/'.$filename;
|
} elsif ($caller eq 'uploaded') { |
my ($rtncode,$embed_content,$repstatus);
|
|
my $embed_url;
|
$repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode); |
if ($embed_file =~ m-^/-) {
|
} |
$embed_url = $embed_file; # points to absolute path
|
if ($repstatus eq 'ok') { |
} else {
|
my $destination = $tempexport.'/resources/'.$count.'/res'; |
if ($embed_file =~ m-https?://-) {
|
if (!-e "$destination") { |
next; # points to url
|
mkdir($destination,0755); |
} else {
|
} |
$embed_url = $dirpath.$embed_file; # points to relative path
|
$destination .= '/'.$filename; |
}
|
my $copiedfile; |
}
|
if ($copiedfile = Apache::File->new('>'.$destination)) { |
if ($caller eq 'resource') {
|
print $copiedfile $embed_content; |
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
|
push @{$href}, 'resources/'.$count.'/res/'.$filename; |
my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url);
|
my $attrib_regexp = ''; |
$embed_content = &Apache::lonnet::getfile($embed_path);
|
if (@{$allfiles{$embed_file}} > 1) { |
unless ($embed_content eq -1) {
|
$attrib_regexp = join('|',@{$allfiles{$embed_file}}); |
$repstatus = 'ok';
|
} else { |
}
|
$attrib_regexp = $allfiles{$embed_file}[0]; |
} elsif ($caller eq 'uploaded') {
|
} |
|
$$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi; |
$repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode);
|
if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) { |
}
|
$$content =~ s#\Q$embed_file\E#$newname#gi; |
if ($repstatus eq 'ok') {
|
} |
my $destination = $tempexport.'/resources/'.$count.'/res';
|
} |
if (!-e "$destination") {
|
} else { |
mkdir($destination,0755);
|
$$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n"; |
}
|
} |
$destination .= '/'.$filename;
|
} |
my $copiedfile;
|
return; |
if ($copiedfile = Apache::File->new('>'.$destination)) {
|
} |
print $copiedfile $embed_content;
|
|
push(@{$href},'resources/'.$count.'/res/'.$filename);
|
sub store_template { |
my $attrib_regexp = '';
|
my ($contents,$tempexport,$count,$content_type) = @_; |
if (@{$allfiles{$embed_file}} > 1) {
|
if ($contents) { |
$attrib_regexp = join('|',@{$allfiles{$embed_file}});
|
if ($tempexport) { |
} else {
|
if (!-e $tempexport.'/resources') { |
$attrib_regexp = $allfiles{$embed_file}[0];
|
mkdir($tempexport.'/resources',0700); |
}
|
} |
$$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;
|
if (!-e $tempexport.'/resources/'.$count) { |
if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) {
|
mkdir($tempexport.'/resources/'.$count,0700); |
$$content =~ s#\Q$embed_file\E#$newname#gi;
|
} |
}
|
my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml'; |
}
|
my $storetemplate; |
} else {
|
if ($storetemplate = Apache::File->new('>'.$destination)) { |
$$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n";
|
print $storetemplate $contents; |
}
|
close($storetemplate); |
}
|
} |
return;
|
if ($content_type eq 'external') { |
}
|
return 'resources/'.$count.'/'.$content_type.'.html'; |
|
} else { |
sub store_template {
|
return 'resources/'.$count.'/'.$content_type.'.xml'; |
my ($contents,$tempexport,$count,$content_type) = @_;
|
} |
if ($contents) {
|
} |
if ($tempexport) {
|
} |
if (!-e $tempexport.'/resources') {
|
} |
mkdir($tempexport.'/resources',0700);
|
|
}
|
# Imports the given (name, url) resources into the course |
if (!-e $tempexport.'/resources/'.$count) {
|
# coursenum, coursedom, and folder must precede the list |
mkdir($tempexport.'/resources/'.$count,0700);
|
sub group_import { |
}
|
my $coursenum = shift; |
my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
|
my $coursedom = shift; |
my $storetemplate;
|
my $folder = shift; |
if ($storetemplate = Apache::File->new('>'.$destination)) {
|
my $container = shift; |
print $storetemplate $contents;
|
my $caller = shift; |
close($storetemplate);
|
while (@_) { |
}
|
my $name = shift; |
if ($content_type eq 'external') {
|
my $url = shift; |
return 'resources/'.$count.'/'.$content_type.'.html';
|
if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) { |
} else {
|
my $errtext = ''; |
return 'resources/'.$count.'/'.$content_type.'.xml';
|
my $fatal = 0; |
}
|
my $newmapstr = '<map>'."\n". |
}
|
'<resource id="1" src="" type="start"></resource>'."\n". |
}
|
'<link from="1" to="2" index="1"></link>'."\n". |
}
|
'<resource id="2" src="" type="finish"></resource>'."\n". |
|
'</map>'; |
|
$env{'form.output'}=$newmapstr; |
sub group_import {
|
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom, |
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
|
'output',$1.$2); |
|
if ($result != m|^/uploaded/|) { |
while (@files) {
|
$errtext.='Map not saved: A network error occured when trying to save the new map. '; |
my ($name, $url, $residx) = @{ shift(@files) };
|
$fatal = 2; |
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
|
} |
&& ($caller eq 'londocs')
|
if ($fatal) { |
&& (!&Apache::lonnet::stat_file($url))) {
|
return ($errtext,$fatal); |
|
} |
my $errtext = '';
|
} |
my $fatal = 0;
|
if ($url) { |
my $newmapstr = '<map>'."\n".
|
my $idx = &Apache::lonratedt::getresidx($url); |
'<resource id="1" src="" type="start"></resource>'."\n".
|
$Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx; |
'<link from="1" to="2" index="1"></link>'."\n".
|
my $ext = 'false'; |
'<resource id="2" src="" type="finish"></resource>'."\n".
|
if ($url=~/^http:\/\//) { $ext = 'true'; } |
'</map>';
|
$url =~ s/:/\:/g; |
$env{'form.output'}=$newmapstr;
|
$name =~ s/:/\:/g; |
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
|
$Apache::lonratedt::resources[$idx] = |
'output',$1.$2);
|
join ':', ($name, $url, $ext, 'normal', 'res'); |
if ($result != m|^/uploaded/|) {
|
} |
$errtext.='Map not saved: A network error occurred when trying to save the new map. ';
|
} |
$fatal = 2;
|
return &storemap($coursenum, $coursedom, $folder.'.'.$container); |
}
|
} |
if ($fatal) {
|
|
return ($errtext,$fatal);
|
sub breadcrumbs { |
}
|
my ($where)=@_; |
}
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
if ($url) {
|
my (@folders); |
if (!$residx
|
if ($env{'form.pagepath'}) { |
|| defined($LONCAPA::map::zombies[$residx])) {
|
@folders = split('&',$env{'form.pagepath'}); |
$residx = &LONCAPA::map::getresidx($url,$residx);
|
} else { |
push(@LONCAPA::map::order, $residx);
|
@folders=split('&',$env{'form.folderpath'}); |
}
|
} |
my $ext = 'false';
|
my $folderpath; |
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
|
my $cpinfo=''; |
$url = &LONCAPA::map::qtunescape($url);
|
if ($env{'form.markedcopy_url'}) { |
$name = &LONCAPA::map::qtunescape($name);
|
&Apache::lonnet::logthis('Found '.$env{'form.markedcopy_url'}); |
$LONCAPA::map::resources[$residx] =
|
$cpinfo='&markedcopy_url='. |
join(':', ($name, $url, $ext, 'normal', 'res'));
|
&Apache::lonnet::escape($env{'form.markedcopy_url'}). |
}
|
'&markedcopy_title='. |
}
|
&Apache::lonnet::escape($env{'form.markedcopy_title'}); |
return &storemap($coursenum, $coursedom, $folder.'.'.$container);
|
} |
}
|
while (@folders) { |
|
my $folder=shift(@folders); |
sub breadcrumbs {
|
my $foldername=shift(@folders); |
my ($where,$allowed,$type)=@_;
|
if ($folderpath) {$folderpath.='&';} |
&Apache::lonhtmlcommon::clear_breadcrumbs();
|
$folderpath.=$folder.'&'.$foldername; |
my (@folders);
|
my $url='/adm/coursedocs?folderpath='. |
if ($env{'form.pagepath'}) {
|
&Apache::lonnet::escape($folderpath); |
@folders = split('&',$env{'form.pagepath'});
|
&Apache::lonhtmlcommon::add_breadcrumb( |
} else {
|
{'href'=>$url.$cpinfo, |
@folders=split('&',$env{'form.folderpath'});
|
'title'=>&Apache::lonnet::unescape($foldername), |
}
|
'text'=>'<font size="+1">'. |
my $folderpath;
|
&Apache::lonnet::unescape($foldername).'</font>' |
my $cpinfo='';
|
}); |
my $plain='';
|
|
my $randompick=-1;
|
|
my $isencrypted=0;
|
} |
my $ishidden=0;
|
return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,undef,undef,undef, |
my $is_random_order=0;
|
0,'nohelp'); |
while (@folders) {
|
} |
my $folder=shift(@folders);
|
|
my $foldername=shift(@folders);
|
sub editor { |
if ($folderpath) {$folderpath.='&';}
|
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output)=@_; |
$folderpath.=$folder.'&'.$foldername;
|
my $errtext=''; |
my $url='/adm/coursedocs?folderpath='.
|
my $fatal=0; |
&escape($folderpath);
|
my $container='sequence'; |
my $name=&unescape($foldername);
|
if ($env{'form.pagepath'}) { |
# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
|
$container='page'; |
$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
|
} |
if ($1 ne '') {
|
($errtext,$fatal)= |
$randompick=$1;
|
&mapread($coursenum,$coursedom,$folder.'.'.$container); |
} else {
|
if ($#Apache::lonratedt::order<1) { |
$randompick=-1;
|
my $idx=&Apache::lonratedt::getresidx(); |
}
|
if ($idx<=0) { $idx=1; } |
if ($2) { $ishidden=1; }
|
$Apache::lonratedt::order[0]=$idx; |
if ($3) { $isencrypted=1; }
|
$Apache::lonratedt::resources[$idx]=''; |
if ($4 ne '') { $is_random_order = 1; }
|
} |
if ($folder eq 'supplemental') {
|
if (defined($env{'form.markcopy'})) { |
if ($allowed) {
|
# Mark for copying |
$name = &mt('Supplemental '.$type.' Documents');
|
my ($title,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$env{'form.markcopy'}]]); |
} else {
|
$env{'form.markedcopy_title'}=$title; |
$name = &mt($type.' Documents');
|
$env{'form.markedcopy_url'}=$url; |
}
|
} |
}
|
$r->print(&breadcrumbs($folder)); |
&Apache::lonhtmlcommon::add_breadcrumb(
|
if ($fatal) { |
{'href'=>$url.$cpinfo,
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
'title'=>$name,
|
} else { |
'text'=>'<font size="+1">'.
|
# ------------------------------------------------------------ Process commands |
$name.'</font>',
|
|
'no_mt'=>1,
|
# ---------------- if they are for this folder and user allowed to make changes |
});
|
if (($allowed) && ($env{'form.folder'} eq $folder)) { |
$plain.=$name.' > ';
|
# set parameters and change order |
}
|
if (defined($env{'form.setparms'})) { |
$plain=~s/\>\;\s*$//;
|
my $idx=$env{'form.setparms'}; |
return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
|
# set parameters |
'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
|
if ($env{'form.randpick_'.$idx}) { |
}
|
&Apache::lonratedt::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); |
|
} else { |
sub log_docs {
|
&Apache::lonratedt::delparameter($idx,'parameter_randompick'); |
return &Apache::lonnet::instructor_log('docslog',@_);
|
} |
}
|
if ($env{'form.hidprs_'.$idx}) { |
|
&Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); |
{
|
} else { |
my @oldresources=();
|
&Apache::lonratedt::delparameter($idx,'parameter_hiddenresource'); |
my @oldorder=();
|
} |
my $parmidx;
|
if ($env{'form.encprs_'.$idx}) { |
my %parmaction=();
|
&Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); |
my %parmvalue=();
|
} else { |
my $changedflag;
|
&Apache::lonratedt::delparameter($idx,'parameter_encrypturl'); |
|
} |
sub snapshotbefore {
|
|
@oldresources=@LONCAPA::map::resources;
|
if ($env{'form.newpos'}) { |
@oldorder=@LONCAPA::map::order;
|
# change order |
$parmidx=undef;
|
|
%parmaction=();
|
my $newpos=$env{'form.newpos'}-1; |
%parmvalue=();
|
my $currentpos=$env{'form.currentpos'}-1; |
$changedflag=0;
|
my $i; |
}
|
my @neworder=(); |
|
if ($newpos>$currentpos) { |
sub remember_parms {
|
# moving stuff up |
my ($idx,$parameter,$action,$value)=@_;
|
for ($i=0;$i<$currentpos;$i++) { |
$parmidx=$idx;
|
$neworder[$i]=$Apache::lonratedt::order[$i]; |
$parmaction{$parameter}=$action;
|
} |
$parmvalue{$parameter}=$value;
|
for ($i=$currentpos;$i<$newpos;$i++) { |
$changedflag=1;
|
$neworder[$i]=$Apache::lonratedt::order[$i+1]; |
}
|
} |
|
$neworder[$newpos]=$Apache::lonratedt::order[$currentpos]; |
sub log_differences {
|
for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) { |
my ($plain)=@_;
|
$neworder[$i]=$Apache::lonratedt::order[$i]; |
my %storehash=('folder' => $plain,
|
} |
'currentfolder' => $env{'form.folder'});
|
} else { |
if ($parmidx) {
|
# moving stuff down |
$storehash{'parameter_res'}=$oldresources[$parmidx];
|
for ($i=0;$i<$newpos;$i++) { |
foreach my $parm (keys(%parmaction)) {
|
$neworder[$i]=$Apache::lonratedt::order[$i]; |
$storehash{'parameter_action_'.$parm}=$parmaction{$parm};
|
} |
$storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
|
$neworder[$newpos]=$Apache::lonratedt::order[$currentpos]; |
}
|
for ($i=$newpos+1;$i<$currentpos+1;$i++) { |
}
|
$neworder[$i]=$Apache::lonratedt::order[$i-1]; |
my $maxidx=$#oldresources;
|
} |
if ($#LONCAPA::map::resources>$#oldresources) {
|
for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) { |
$maxidx=$#LONCAPA::map::resources;
|
$neworder[$i]=$Apache::lonratedt::order[$i]; |
}
|
} |
for (my $idx=0; $idx<=$maxidx; $idx++) {
|
} |
if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
|
@Apache::lonratedt::order=@neworder; |
$storehash{'before_resources_'.$idx}=$oldresources[$idx];
|
} |
$storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
|
# store the changed version |
$changedflag=1;
|
|
}
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
|
if ($fatal) { |
$storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
$storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
|
return; |
$changedflag=1;
|
} |
}
|
|
}
|
} |
$storehash{'maxidx'}=$maxidx;
|
if ($env{'form.pastemarked'}) { |
if ($changedflag) { &log_docs(\%storehash); }
|
# paste resource to end of list |
}
|
my $url=$env{'form.markedcopy_url'}; |
}
|
my $title=$env{'form.markedcopy_title'}; |
|
# Maps need to be copied first |
|
if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) { |
|
$title=&mt('Copy of').' '.$title; |
|
my $newid=$$.time; |
|
$url=~/^(.+)\.(\w+)$/; |
sub docs_change_log {
|
my $newurl=$1.$newid.'.'.$2; |
my ($r)=@_;
|
my $storefn=$newurl; |
my $folder=$env{'form.folder'};
|
$storefn=~s/^\/\w+\/\w+\/\w+\///; |
$r->print(&Apache::loncommon::start_page('Course Document Change Log'));
|
&Apache::loncreatecourse::writefile |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
|
($env{'request.course.id'},$storefn, |
my %docslog=&Apache::lonnet::dump('nohist_docslog',
|
&Apache::lonnet::getfile($url)); |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
$url=$newurl; |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
} |
|
$title=~s/\</\<\;/g; |
if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
|
$title=~s/\>/\>\;/g; |
|
$title=~s/\:/\:/g; |
$r->print('<form action="/adm/coursedocs" method="post" name="docslog">'.
|
my $ext='false'; |
'<input type="hidden" name="docslog" value="1" />');
|
if ($url=~/^http\:\/\//) { $ext='true'; } |
|
$url=~s/\:/\:/g; |
my %saveable_parameters = ('show' => 'scalar',);
|
# Now insert the URL at the bottom |
&Apache::loncommon::store_course_settings('docs_log',
|
my $newidx=&Apache::lonratedt::getresidx($url); |
\%saveable_parameters);
|
$Apache::lonratedt::resources[$newidx]= |
&Apache::loncommon::restore_course_settings('docs_log',
|
$title.':'.$url.':'.$ext.':normal:res'; |
\%saveable_parameters);
|
$Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx; |
if (!$env{'form.show'}) { $env{'form.show'}=10; }
|
# Store the result |
my %lt=('hiddenresource' => 'Resources hidden',
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
'encrypturl' => 'URL hidden',
|
if ($fatal) { |
'randompick' => 'Randomly pick',
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
'randomorder' => 'Randomly ordered',
|
return; |
'set' => 'set to',
|
} |
'del' => 'deleted');
|
|
$r->print(&Apache::loncommon::display_filter().
|
} |
'<input type="hidden" name="folder" value="'.$folder.'" />'.
|
$r->print($upload_output); |
'<input type="submit" value="'.&mt('Display').'" /></form>');
|
if ($env{'form.cmd'}) { |
$r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
|
my ($cmd,$idx)=split(/\_/,$env{'form.cmd'}); |
'<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
|
if ($cmd eq 'del') { |
&mt('After').'</th>'.
|
my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); |
&Apache::loncommon::end_data_table_header_row());
|
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && |
my $shown=0;
|
($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) { |
foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
|
&Apache::lonnet::removeuploadedurl($url); |
if ($env{'form.displayfilter'} eq 'currentfolder') {
|
} else { |
if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
|
&Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); |
}
|
} |
my @changes=keys(%{$docslog{$id}{'logentry'}});
|
for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) { |
if ($env{'form.displayfilter'} eq 'containing') {
|
$Apache::lonratedt::order[$i]= |
my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
|
$Apache::lonratedt::order[$i+1]; |
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
|
} |
foreach my $key (@changes) {
|
$#Apache::lonratedt::order--; |
$wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
|
} elsif ($cmd eq 'cut') { |
}
|
my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); |
if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
|
&Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); |
}
|
for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) { |
my $count = 0;
|
$Apache::lonratedt::order[$i]= |
my $time =
|
$Apache::lonratedt::order[$i+1]; |
&Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
|
} |
my $plainname =
|
$#Apache::lonratedt::order--; |
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
|
} elsif ($cmd eq 'up') { |
$docslog{$id}{'exe_udom'});
|
if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) { |
my $about_me_link =
|
my $i=$Apache::lonratedt::order[$idx-1]; |
&Apache::loncommon::aboutmewrapper($plainname,
|
$Apache::lonratedt::order[$idx-1]= |
$docslog{$id}{'exe_uname'},
|
$Apache::lonratedt::order[$idx]; |
$docslog{$id}{'exe_udom'});
|
$Apache::lonratedt::order[$idx]=$i; |
my $send_msg_link='';
|
} |
if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
|
} elsif ($cmd eq 'down') { |
|| ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
|
if (defined($Apache::lonratedt::order[$idx+1])) { |
$send_msg_link ='<br />'.
|
my $i=$Apache::lonratedt::order[$idx+1]; |
&Apache::loncommon::messagewrapper(&mt('Send message'),
|
$Apache::lonratedt::order[$idx+1]= |
$docslog{$id}{'exe_uname'},
|
$Apache::lonratedt::order[$idx]; |
$docslog{$id}{'exe_udom'});
|
$Apache::lonratedt::order[$idx]=$i; |
}
|
} |
$r->print(&Apache::loncommon::start_data_table_row());
|
} elsif ($cmd eq 'rename') { |
$r->print('<td>'.$time.'</td>
|
my $ratstr = $Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]; |
<td>'.$about_me_link.
|
my ($rtitle,@rrest)=split(/\:/, |
'<br /><tt>'.$docslog{$id}{'exe_uname'}.
|
$Apache::lonratedt::resources[ |
':'.$docslog{$id}{'exe_udom'}.'</tt>'.
|
$Apache::lonratedt::order[$idx]]); |
$send_msg_link.'</td><td>'.
|
my $comment= |
$docslog{$id}{'logentry'}{'folder'}.'</td><td>');
|
&HTML::Entities::decode($env{'form.title'}); |
# Before
|
$comment=~s/\</\<\;/g; |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
$comment=~s/\>/\>\;/g; |
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
|
$comment=~s/\:/\:/g; |
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
|
if ($comment=~/\S/) { |
if ($oldname ne $newname) {
|
$Apache::lonratedt::resources[ |
$r->print(&LONCAPA::map::qtescape($oldname));
|
$Apache::lonratedt::order[$idx]]= |
}
|
$comment.':'.join(':',@rrest); |
}
|
} |
$r->print('<ul>');
|
} |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
# Store the changed version |
if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>');
|
$folder.'.'.$container); |
}
|
if ($fatal) { |
}
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
$r->print('</ul>');
|
return; |
# After
|
} |
$r->print('</td><td>');
|
} |
|
# Group import/search |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
if ($env{'form.importdetail'}) { |
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
|
my @imports; |
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
|
foreach (split(/\&/,$env{'form.importdetail'})) { |
if ($oldname ne '' && $oldname ne $newname) {
|
if (defined($_)) { |
$r->print(&LONCAPA::map::qtescape($newname));
|
my ($name,$url)=split(/\=/,$_); |
}
|
$name=&Apache::lonnet::unescape($name); |
}
|
$url=&Apache::lonnet::unescape($url); |
$r->print('<ul>');
|
push @imports, $name, $url; |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
} |
if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
|
} |
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>');
|
# Store the changed version |
}
|
($errtext,$fatal)=group_import($coursenum, $coursedom, $folder, |
}
|
$container,'londocs',@imports); |
$r->print('</ul>');
|
if ($fatal) { |
if ($docslog{$id}{'logentry'}{'parameter_res'}) {
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
|
return; |
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
|
} |
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
|
} |
$r->print('<li>'.
|
# Loading a complete map |
&mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
|
if (($env{'form.importmap'}) && ($env{'form.loadmap'})) { |
$docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
|
foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { |
.'</li>');
|
my ($title,$url,$ext,$type)=split(/\:/,$_); |
}
|
my $idx=&Apache::lonratedt::getresidx($url); |
}
|
$Apache::lonratedt::resources[$idx]=$_; |
$r->print('</ul>');
|
$Apache::lonratedt::order |
}
|
[$#Apache::lonratedt::order+1]=$idx; |
# End
|
} |
$r->print('</td>'.&Apache::loncommon::end_data_table_row());
|
|
$shown++;
|
# Store the changed version |
if (!($env{'form.show'} eq &mt('all')
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
|| $shown<=$env{'form.show'})) { last; }
|
$folder.'.'.$container); |
}
|
if ($fatal) { |
$r->print(&Apache::loncommon::end_data_table());
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
}
|
return; |
|
} |
sub update_paste_buffer {
|
} |
my ($coursenum,$coursedom) = @_;
|
} |
|
# ---------------------------------------------------------------- End commands |
return if (!defined($env{'form.markcopy'}));
|
# ---------------------------------------------------------------- Print screen |
return if (!defined($env{'form.copyfolder'}));
|
my $idx=0; |
return if ($env{'form.markcopy'} < 0);
|
my $shown=0; |
|
$r->print('<table>'); |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
|
foreach (@Apache::lonratedt::order) { |
$env{'form.copyfolder'});
|
my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]); |
|
$name=&Apache::lonratsrv::qtescape($name); |
return if ($fatal);
|
$url=&Apache::lonratsrv::qtescape($url); |
|
unless ($name) { $name=(split(/\//,$url))[-1]; } |
# Mark for copying
|
unless ($name) { $idx++; next; } |
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
|
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum)); |
if (&is_supplemental_title($title)) {
|
$idx++; |
&Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
|
$shown++; |
($title) = &parse_supplemental_title($title);
|
} |
} elsif ($env{'docs.markedcopy_supplemental'}) {
|
unless ($shown) { |
&Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
|
$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>'); |
}
|
} |
$url=~s{http(:|:)//https(:|:)//}{https$2//};
|
$r->print("\n</table>\n"); |
|
if ($env{'form.markedcopy_url'}) { |
&Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
|
$r->print(<<ENDPASTE); |
'docs.markedcopy_url' => $url});
|
<p><form name="pasteform" action="/adm/coursedocs" method="post"> |
delete($env{'form.markcopy'});
|
<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" /> |
}
|
<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" /> |
|
ENDPASTE |
sub print_paste_buffer {
|
$r->print( |
my ($r,$container) = @_;
|
'<input type="submit" name="pastemarked" value="'.&mt('Paste'). |
return if (!defined($env{'docs.markedcopy_url'}));
|
'" /> '.&Apache::loncommon::filedescription( |
|
(split(/\./,$env{'form.markedcopy_url'}))[-1]).': '. |
$r->print(<<ENDPASTE);
|
$env{'form.markedcopy_title'}); |
<form name="pasteform" action="/adm/coursedocs" method="post"><p>
|
if ($container eq 'page') { |
ENDPASTE
|
$r->print(<<PAGEINFO); |
$r->print('<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ');
|
<input type="hidden" name="pagepath" value="$env{'form.pagepath'}" /> |
|
<input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" /> |
my $type;
|
PAGEINFO |
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
|
} else { |
$type = &mt('External Resource');
|
$r->print(<<FOLDERINFO); |
$r->print($type.': '.
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
|
FOLDERINFO |
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
|
} |
} else {
|
$r->print('</form></p>'); |
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
|
} |
my $icon = &Apache::loncommon::icon($extension);
|
} |
if ($extension eq 'sequence' &&
|
} |
$env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
|
|
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
|
sub process_file_upload { |
$icon .= '/folder_closed.gif';
|
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; |
}
|
# upload a file, if present |
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
|
my $parseaction; |
$r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
|
if ($env{'form.parserflag'}) { |
}
|
$parseaction = 'parse'; |
if ($container eq 'page') {
|
} |
$r->print('
|
my $phase_status; |
<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
|
my $folder=$env{'form.folder'}; |
<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
|
if ($folder eq '') { |
');
|
$folder='default'; |
} else {
|
} |
$r->print('
|
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) { |
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
|
my $errtext=''; |
');
|
my $fatal=0; |
}
|
my $container='sequence'; |
$r->print('</p></form>');
|
if ($env{'form.pagepath'}) { |
}
|
$container='page'; |
|
} |
sub do_paste_from_buffer {
|
($errtext,$fatal)= |
my ($coursenum,$coursedom,$folder) = @_;
|
&mapread($coursenum,$coursedom,$folder.'.'.$container); |
|
if ($#Apache::lonratedt::order<1) { |
if (!$env{'form.pastemarked'}) {
|
$Apache::lonratedt::order[0]=1; |
return;
|
$Apache::lonratedt::resources[1]=''; |
}
|
} |
|
if ($fatal) { |
# paste resource to end of list
|
return 'failed'; |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
|
} |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
|
my $destination = 'docs/'; |
# Maps need to be copied first
|
if ($folder =~ /^supplemental/) { |
if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
|
$destination = 'supplemental/'; |
$title=&mt('Copy of').' '.$title;
|
} |
my $newid=$$.int(rand(100)).time;
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
|
$destination .= 'default/'; |
if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
my $path = $1;
|
$destination .= $2.'/'; |
my $prefix = $2;
|
} |
my $ancestor = $3;
|
# this is for a course, not a user, so set coursedoc flag |
if (length($ancestor) > 10) {
|
# probably the only place in the system where this should be "1" |
$ancestor = substr($ancestor,-10,10);
|
my $newidx=&Apache::lonratedt::getresidx(); |
}
|
$destination .= $newidx; |
$oldid = $path.$prefix.$ancestor;
|
my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination, |
}
|
$parseaction,$allfiles, |
my $counter = 0;
|
$codebase); |
my $newurl=$oldid.$newid.'.'.$ext;
|
my $ext='false'; |
my $is_unique = &uniqueness_check($newurl);
|
if ($url=~/^http\:\/\//) { $ext='true'; } |
while (!$is_unique && $counter < 100) {
|
$url=~s/\:/\:/g; |
$counter ++;
|
my $comment=$env{'form.comment'}; |
$newid ++;
|
$comment=~s/\</\<\;/g; |
$newurl = $oldid.$newid;
|
$comment=~s/\>/\>\;/g; |
$is_unique = &uniqueness_check($newurl);
|
$comment=~s/\:/\:/g; |
}
|
if ($folder=~/^supplemental/) { |
if (!$is_unique) {
|
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
if ($url=~/\.page$/) {
|
$env{'user.domain'}.'___&&&___'.$comment; |
return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
|
} |
} else {
|
|
return &mt('Paste failed: an error occurred creating a unique URL for the folder');
|
$Apache::lonratedt::resources[$newidx]= |
}
|
$comment.':'.$url.':'.$ext.':normal:res'; |
}
|
$Apache::lonratedt::order[$#Apache::lonratedt::order+1]= $newidx; |
my $storefn=$newurl;
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
$storefn=~s{^/\w+/$match_domain/$match_username/}{};
|
$folder.'.'.$container); |
my $paste_map_result =
|
if ($fatal) { |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
|
$$upload_output .= '<p><font color="red">'.$errtext.'</font></p>'; |
&Apache::lonnet::getfile($url));
|
return 'failed'; |
if ($paste_map_result eq '/adm/notfound.html') {
|
} else { |
if ($url=~/\.page$/) {
|
if ($parseaction eq 'parse') { |
return &mt('Paste failed: an error occurred saving the composite page');
|
my $total_embedded = keys(%{$allfiles}); |
} else {
|
if ($total_embedded > 0) { |
return &mt('Paste failed: an error occurred saving the folder');
|
my $num = 0; |
}
|
$$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br /> |
}
|
<form name="upload_embedded" action="/adm/coursedocs" |
$url = $newurl;
|
method="post" enctype="multipart/form-data"> |
}
|
<input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" /> <input type="hidden" name="cmd" value="upload_embedded" /> |
# published maps can only exists once, so remove it from paste buffer when done
|
<input type="hidden" name="newidx" value="'.$newidx.'" /> |
if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
|
<input type="hidden" name="primaryurl" value="'.&Apache::lonnet::escape($url).'" /> |
&Apache::lonnet::delenv('docs\\.markedcopy');
|
<input type="hidden" name="phasetwo" value="'.$total_embedded.'" />'; |
}
|
$$upload_output .= '<b>Upload embedded files</b>:<br /> |
if ($url=~ m{/smppg$}) {
|
<table>'; |
my $db_name = &Apache::lonsimplepage::get_db_name($url);
|
foreach my $embed_file (keys(%{$allfiles})) { |
if ($db_name =~ /^smppage_/) {
|
$$upload_output .= '<tr><td>'.$embed_file. |
#simple pages, need to copy the db contents to a new one.
|
'<input name="embedded_item_'.$num.'" type="file" /> |
my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
|
<input name="embedded_orig_'.$num.'" type="hidden" value="'.&Apache::lonnet::escape($embed_file).'" />'; |
my $now = time();
|
my $attrib; |
$db_name =~ s{_\d*$ }{_$now}x;
|
if (@{$$allfiles{$embed_file}} > 1) { |
my $result=&Apache::lonnet::put($db_name,\%contents,
|
$attrib = join(':',@{$$allfiles{$embed_file}}); |
$coursedom,$coursenum);
|
} else { |
$url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
|
$attrib = $$allfiles{$embed_file}[0]; |
$title=&mt('Copy of').' '.$title;
|
} |
}
|
$$upload_output .= |
}
|
'<input name="embedded_attrib_'.$num.'" type="hidden" value="'.$attrib.'" />'; |
$title = &LONCAPA::map::qtunescape($title);
|
if (exists($$codebase{$embed_file})) { |
my $ext='false';
|
$$upload_output .= |
if ($url=~m{^http(|s)://}) { $ext='true'; }
|
'<input name="codebase_'.$num.'" type="hidden" value="'.&Apache::lonnet::escape($$codebase{$embed_file}).'" />'; |
$url = &LONCAPA::map::qtunescape($url);
|
} |
# Now insert the URL at the bottom
|
$$upload_output .= '</td></tr>'; |
my $newidx = &LONCAPA::map::getresidx($url);
|
$num ++; |
if ($env{'docs.markedcopy_supplemental'}) {
|
} |
if ($folder =~ /^supplemental/) {
|
$phase_status = 'phasetwo'; |
$title = $env{'docs.markedcopy_supplemental'};
|
$$upload_output .= '</table><br /> |
} else {
|
<input type ="submit" value="Complete upload" /> |
(undef,undef,$title) =
|
</form>'; |
&parse_supplemental_title($env{'docs.markedcopy_supplemental'});
|
} else { |
}
|
$$upload_output .= 'No embedded items identified<br />'; |
} else {
|
} |
if ($folder=~/^supplemental/) {
|
} |
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
|
} |
$env{'user.domain'}.'___&&&___'.$title;
|
} |
}
|
return $phase_status; |
}
|
} |
|
|
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
|
sub process_secondary_uploads { |
push(@LONCAPA::map::order, $newidx);
|
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_; |
return 'ok';
|
my $folder=$env{'form.folder'}; |
# Store the result
|
my $destination = 'docs/'; |
}
|
if ($folder =~ /^supplemental/) { |
|
$destination = 'supplemental/'; |
sub uniqueness_check {
|
} |
my ($newurl) = @_;
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
my $unique = 1;
|
$destination .= 'default/'; |
foreach my $res (@LONCAPA::map::order) {
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
|
$destination .= $1.'/'; |
$url=&LONCAPA::map::qtescape($url);
|
} |
if ($newurl eq $url) {
|
$destination .= $newidx; |
$unique = 0;
|
my ($url,$filename); |
last;
|
$url=&Apache::lonnet::userfileupload($formname.$num,1,$destination); |
}
|
($filename) = ($url =~ m-^/uploaded/$coursedom/$coursenum/$destination/(.+)$-); |
}
|
return $filename; |
return $unique;
|
} |
}
|
|
|
# --------------------------------------------------------------- An entry line |
my %parameter_type = ( 'randompick' => 'int_pos',
|
|
'hiddenresource' => 'string_yesno',
|
sub entryline { |
'encrypturl' => 'string_yesno',
|
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_; |
'randomorder' => 'string_yesno',);
|
$title=~s/\&colon\;/\:/g; |
my $valid_parameters_re = join('|',keys(%parameter_type));
|
$title=&HTML::Entities::encode(&HTML::Entities::decode( |
# set parameters
|
&Apache::lonnet::unescape($title)),'"<>&\''); |
sub update_parameter {
|
my $renametitle=$title; |
|
my $foldertitle=$title; |
return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
|
my $pagetitle=$title; |
|
my $orderidx=$Apache::lonratedt::order[$index]; |
my $which = $env{'form.changeparms'};
|
if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) { |
my $idx = $env{'form.setparms'};
|
$foldertitle=&Apache::lontexconvert::msgtexconverted($4); |
if ($env{'form.'.$which.'_'.$idx}) {
|
$renametitle=$4; |
my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
|
$title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '. |
: 'yes';
|
&Apache::loncommon::plainname($2,$3).': <br />'. |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
|
$foldertitle; |
$parameter_type{$which});
|
} |
&remember_parms($idx,$which,'set',$value);
|
$renametitle=~s/\"\;/\\\"/g; |
} else {
|
my $line='<tr>'; |
&LONCAPA::map::delparameter($idx,'parameter_'.$which);
|
# Edit commands |
|
my $container; |
&remember_parms($idx,$which,'del');
|
my $folderpath; |
}
|
if ($env{'form.folderpath'}) { |
return 1;
|
$container = 'sequence'; |
}
|
$folderpath=&Apache::lonnet::escape($env{'form.folderpath'}); |
|
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"'); |
|
} |
sub handle_edit_cmd {
|
my ($pagepath,$pagesymb); |
my ($coursenum,$coursedom) =@_;
|
if ($env{'form.pagepath'}) { |
|
$container = 'page'; |
my ($cmd,$idx)=split('_',$env{'form.cmd'});
|
$pagepath=&Apache::lonnet::escape($env{'form.pagepath'}); |
|
$pagesymb=&Apache::lonnet::escape($env{'form.pagesymb'}); |
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
|
} |
my ($title, $url, @rrest) = split(':', $ratstr);
|
my $cpinfo=''; |
|
if ($env{'form.markedcopy_url'}) { |
if ($cmd eq 'del') {
|
$cpinfo='&markedcopy_url='. |
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
|
&Apache::lonnet::escape($env{'form.markedcopy_url'}). |
($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
|
'&markedcopy_title='. |
&Apache::lonnet::removeuploadedurl($url);
|
&Apache::lonnet::escape($env{'form.markedcopy_title'}); |
} else {
|
} |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
|
if ($allowed) { |
}
|
my $incindex=$index+1; |
splice(@LONCAPA::map::order, $idx, 1);
|
my $selectbox=''; |
|
if (($folder!~/^supplemental/) && |
} elsif ($cmd eq 'cut') {
|
($#Apache::lonratedt::order>0) && |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
|
((split(/\:/, |
splice(@LONCAPA::map::order, $idx, 1);
|
$Apache::lonratedt::resources[$Apache::lonratedt::order[0]]))[1] |
|
ne '') && |
} elsif ($cmd eq 'up'
|
((split(/\:/, |
&& ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
|
$Apache::lonratedt::resources[$Apache::lonratedt::order[1]]))[1] |
@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
|
ne '')) { |
|
$selectbox= |
} elsif ($cmd eq 'down'
|
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'. |
&& defined($LONCAPA::map::order[$idx+1])) {
|
'<select name="newpos" onChange="this.form.submit()">'; |
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
|
for (my $i=1;$i<=$#Apache::lonratedt::order+1;$i++) { |
|
if ($i==$incindex) { |
} elsif ($cmd eq 'rename') {
|
$selectbox.='<option value="" selected="1">('.$i.')</option>'; |
|
} else { |
my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
|
$selectbox.='<option value="'.$i.'">'.$i.'</option>'; |
if ($comment=~/\S/) {
|
} |
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
|
} |
$comment.':'.join(':', $url, @rrest);
|
$selectbox.='</select>'; |
}
|
} |
# Devalidate title cache
|
my %lt=&Apache::lonlocal::texthash( |
my $renamed_url=&LONCAPA::map::qtescape($url);
|
'up' => 'Move Up', |
&Apache::lonnet::devalidate_title_cache($renamed_url);
|
'dw' => 'Move Down', |
} else {
|
'rm' => 'Remove', |
return 0;
|
'ct' => 'Cut', |
}
|
'rn' => 'Rename', |
return 1;
|
'cp' => 'Copy'); |
}
|
if ($env{'form.pagepath'}) { |
|
$line.=(<<END); |
sub editor {
|
<form name="entry_$index" action="/adm/coursedocs" method="post"> |
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
|
<input type="hidden" name="pagepath" value="$env{'form.pagepath'}" /> |
|
<input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" /> |
my $container= ($env{'form.pagepath'}) ? 'page'
|
<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" /> |
: 'sequence';
|
<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" /> |
|
<input type="hidden" name="setparms" value="$orderidx" /> |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
|
<td><table border='0' cellspacing='2' cellpadding='0'> |
$folder.'.'.$container);
|
<tr><td bgcolor="#DDDDDD"> |
return $errtext if ($fatal);
|
<a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath&pagesymb=$pagesymb$cpinfo'> |
|
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr> |
if ($#LONCAPA::map::order<1) {
|
<tr><td bgcolor="#DDDDDD"> |
my $idx=&LONCAPA::map::getresidx();
|
<a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath&pagesymb=$pagesymb$cpinfo'> |
if ($idx<=0) { $idx=1; }
|
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr> |
$LONCAPA::map::order[0]=$idx;
|
</table></td> |
$LONCAPA::map::resources[$idx]='';
|
<td>$selectbox |
}
|
</td><td bgcolor="#DDDDDD"> |
|
<a href='javascript:removeres("$pagepath","$index","$renametitle","page","$pagesymb");'> |
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
|
<font size="-2" color="#990000">$lt{'rm'}</font></a> |
&breadcrumbs($folder,$allowed,$type);
|
<a href='javascript:cutres("$pagepath","$index","$renametitle","page","$pagesymb");'> |
$r->print($breadcrumbtrail);
|
<font size="-2" color="#550044">$lt{'ct'}</font></a> |
|
<a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'> |
# ------------------------------------------------------------ Process commands
|
<font size="-2" color="#009900">$lt{'rn'}</font></a> |
|
<a href='javascript:markcopy("$pagepath","$index","$renametitle","page","$pagesymb");'> |
# ---------------- if they are for this folder and user allowed to make changes
|
<font size="-2" color="#000099">$lt{'cp'}</font></a></td> |
if (($allowed) && ($env{'form.folder'} eq $folder)) {
|
END |
# set parameters and change order
|
} else { |
&snapshotbefore();
|
$line.=(<<END); |
|
<form name="entry_$index" action="/adm/coursedocs" method="post"> |
if (&update_parameter()) {
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" /> |
return $errtext if ($fatal);
|
<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" /> |
}
|
<input type="hidden" name="setparms" value="$orderidx" /> |
|
<td><table border='0' cellspacing='2' cellpadding='0'> |
if ($env{'form.newpos'} && $env{'form.currentpos'}) {
|
<tr><td bgcolor="#DDDDDD"> |
# change order
|
<a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath$cpinfo'> |
my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
|
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr> |
splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
|
<tr><td bgcolor="#DDDDDD"> |
|
<a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath$cpinfo'> |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr> |
return $errtext if ($fatal);
|
</table></td> |
}
|
<td>$selectbox |
|
</td><td bgcolor="#DDDDDD"> |
if ($env{'form.pastemarked'}) {
|
<a href='javascript:removeres("$folderpath","$index","$renametitle","sequence");'> |
my $paste_res =
|
<font size="-2" color="#990000">$lt{'rm'}</font></a> |
&do_paste_from_buffer($coursenum,$coursedom,$folder);
|
<a href='javascript:cutres("$folderpath","$index","$renametitle","sequence");'> |
if ($paste_res eq 'ok') {
|
<font size="-2" color="#550044">$lt{'ct'}</font></a> |
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
|
<a href='javascript:changename("$folderpath","$index","$renametitle","sequence");'> |
return $errtext if ($fatal);
|
<font size="-2" color="#009900">$lt{'rn'}</font></a> |
} elsif ($paste_res ne '') {
|
<a href='javascript:markcopy("$folderpath","$index","$renametitle","sequence");'> |
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
|
<font size="-2" color="#000099">$lt{'cp'}</font></a></td> |
}
|
END |
}
|
} |
|
} |
$r->print($upload_output);
|
# Figure out what kind of a resource this is |
|
my ($extension)=($url=~/\.(\w+)$/); |
if (&handle_edit_cmd()) {
|
my $uploaded=($url=~/^\/*uploaded\//); |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
my $icon=&Apache::loncommon::icon($url); |
return $errtext if ($fatal);
|
my $isfolder=0; |
}
|
my $ispage=0; |
# Group import/search
|
my $folderarg; |
if ($env{'form.importdetail'}) {
|
my $pagearg; |
my @imports;
|
my $pagefile; |
foreach my $item (split(/\&/,$env{'form.importdetail'})) {
|
if ($uploaded) { |
if (defined($item)) {
|
if ($extension eq 'sequence') { |
my ($name,$url,$residx)=
|
$icon=$iconpath.'/folder_closed.gif'; |
map {&unescape($_)} split(/\=/,$item);
|
$url=~/$coursenum\/([\/\w]+)\.sequence$/; |
push(@imports, [$name, $url, $residx]);
|
$url='/adm/coursedocs?'; |
}
|
$folderarg=$1; |
}
|
$isfolder=1; |
($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
|
} elsif ($extension eq 'page') { |
$container,'londocs',@imports);
|
$icon=$iconpath.'/page.gif'; |
return $errtext if ($fatal);
|
$url=~/$coursenum\/([\/\w]+)\.page$/; |
}
|
$pagearg=$1; |
# Loading a complete map
|
$url='/adm/coursedocs?'; |
if ($env{'form.loadmap'}) {
|
$ispage=1; |
if ($env{'form.importmap'}=~/\w/) {
|
} else { |
foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
|
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url); |
my ($title,$url,$ext,$type)=split(/\:/,$res);
|
} |
my $idx=&LONCAPA::map::getresidx($url);
|
} |
$LONCAPA::map::resources[$idx]=$res;
|
$url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//; |
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
|
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { |
}
|
my $symb=&Apache::lonnet::symbclean( |
($errtext,$fatal)=&storemap($coursenum,$coursedom,
|
&Apache::lonnet::declutter('uploaded/'. |
$folder.'.'.$container);
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
return $errtext if ($fatal);
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder. |
} else {
|
'.sequence'). |
$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
|
'___'.$residx.'___'. |
|
&Apache::lonnet::declutter($url)); |
}
|
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
}
|
$url=&Apache::lonnet::clutter($url); |
&log_differences($plain);
|
if ($url=~/^\/*uploaded\//) { |
}
|
$url=~/\.(\w+)$/; |
# ---------------------------------------------------------------- End commands
|
my $embstyle=&Apache::loncommon::fileembstyle($1); |
# ---------------------------------------------------------------- Print screen
|
if (($embstyle eq 'img') || ($embstyle eq 'emb')) { |
my $idx=0;
|
$url='/adm/wrapper'.$url; |
my $shown=0;
|
} elsif ($embstyle eq 'ssi') { |
if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
|
#do nothing with these |
$r->print('<p>'.&mt('Parameters').':<ul>'.
|
} elsif ($url!~/\.(sequence|page)$/) { |
($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':'').
|
$url='/adm/coursedocs/showdoc'.$url; |
($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
|
} |
($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
|
} elsif ($url=~m|^/ext/|) { |
'</ul></p>');
|
$url='/adm/wrapper'.$url; |
}
|
} |
if ($randompick>=0) {
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb); |
$r->print('<p>'.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'</p>');
|
if ($container eq 'page') { |
}
|
my $symb=$env{'form.pagesymb'}; |
if ($is_random_order) {
|
|
$r->print('<p>'.&mt('Caution: this folder is set to randomly order its contents. Adding or removing resources from this folder will change the order of resources shown.').'</p>');
|
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); |
}
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb); |
$r->print('<table class="LC_docs_editor">');
|
} |
foreach my $res (@LONCAPA::map::order) {
|
} |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
|
my $parameterset=' '; |
$name=&LONCAPA::map::qtescape($name);
|
if ($isfolder) { |
$url=&LONCAPA::map::qtescape($url);
|
my $foldername=&Apache::lonnet::escape($foldertitle); |
unless ($name) { $name=(split(/\//,$url))[-1]; }
|
my $folderpath=$env{'form.folderpath'}; |
unless ($name) { $idx++; next; }
|
if ($folderpath) { $folderpath.='&' }; |
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$res,
|
$folderpath.=$folderarg.'&'.$foldername; |
$coursenum));
|
$url.='folderpath='.&Apache::lonnet::escape($folderpath).$cpinfo; |
$idx++;
|
$parameterset='<label>'.&mt('Randomly Pick: '). |
$shown++;
|
'<input type="text" size="4" onChange="this.form.submit()" name="randpick_'.$orderidx.'" value="'. |
}
|
(&Apache::lonratedt::getparameter($orderidx, |
unless ($shown) {
|
'parameter_randompick'))[0]. |
$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
|
'" />'. |
}
|
'<font size="-2"><a href="javascript:void(0)">'.&mt('Store').'</a></font></label>'; |
$r->print("\n</table>\n");
|
|
if ($allowed) {
|
} |
&print_paste_buffer($r,$container);
|
if ($ispage) { |
}
|
my $pagename=&Apache::lonnet::escape($pagetitle); |
return;
|
my $pagepath; |
}
|
my $folderpath=$env{'form.folderpath'}; |
|
if ($folderpath) { $pagepath = $folderpath.'&' }; |
sub process_file_upload {
|
$pagepath.=$pagearg.'&'.$pagename; |
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
|
my $symb=$env{'form.pagesymb'}; |
# upload a file, if present
|
if (!$symb) { |
my $parseaction;
|
my $path='uploaded/'. |
if ($env{'form.parserflag'}) {
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
$parseaction = 'parse';
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'; |
}
|
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', |
my $phase_status;
|
$residx, |
my $folder=$env{'form.folder'};
|
$path.$pagearg.'.page'); |
if ($folder eq '') {
|
} |
$folder='default';
|
$url.='pagepath='.&Apache::lonnet::escape($pagepath). |
}
|
'&pagesymb='.&Apache::lonnet::escape($symb).$cpinfo; |
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
|
} |
my $errtext='';
|
$line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon. |
my $fatal=0;
|
'" border="0"></a></td>'. |
my $container='sequence';
|
"<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>"; |
if ($env{'form.pagepath'}) {
|
if (($allowed) && ($folder!~/^supplemental/)) { |
$container='page';
|
my %lt=&Apache::lonlocal::texthash( |
}
|
'hd' => 'Hidden', |
($errtext,$fatal)=
|
'ec' => 'URL hidden'); |
&mapread($coursenum,$coursedom,$folder.'.'.$container);
|
my $enctext= |
if ($#LONCAPA::map::order<1) {
|
((&Apache::lonratedt::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':''); |
$LONCAPA::map::order[0]=1;
|
my $hidtext= |
$LONCAPA::map::resources[1]='';
|
((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':''); |
}
|
$line.=(<<ENDPARMS); |
if ($fatal) {
|
<td bgcolor="#BBBBFF"><font size='-2'> |
return 'failed';
|
<nobr><label><input type="checkbox" name="hidprs_$orderidx" onClick="this.form.submit()" $hidtext /> $lt{'hd'}</label></nobr></td> |
}
|
<td bgcolor="#BBBBFF"><font size='-2'> |
my $destination = 'docs/';
|
<nobr><label><input type="checkbox" name="encprs_$orderidx" onClick="this.form.submit()" $enctext /> $lt{'ec'}</label></nobr></td> |
if ($folder =~ /^supplemental/) {
|
<td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td> |
$destination = 'supplemental/';
|
ENDPARMS |
}
|
} |
if (($folder eq 'default') || ($folder eq 'supplemental')) {
|
$line.="</form></tr>"; |
$destination .= 'default/';
|
return $line; |
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
|
} |
$destination .= $2.'/';
|
|
}
|
# ---------------------------------------------------------------- tie the hash |
# this is for a course, not a user, so set coursedoc flag
|
|
# probably the only place in the system where this should be "1"
|
sub tiehash { |
my $newidx=&LONCAPA::map::getresidx();
|
my ($mode)=@_; |
$destination .= $newidx;
|
$hashtied=0; |
my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
|
if ($env{'request.course.fn'}) { |
$parseaction,$allfiles,
|
if ($mode eq 'write') { |
$codebase);
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
my $ext='false';
|
&GDBM_WRCREAT(),0640)) { |
if ($url=~m{^http://}) { $ext='true'; }
|
$hashtied=2; |
$url = &LONCAPA::map::qtunescape($url);
|
} |
my $comment=$env{'form.comment'};
|
} else { |
$comment = &LONCAPA::map::qtunescape($comment);
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
if ($folder=~/^supplemental/) {
|
&GDBM_READER(),0640)) { |
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
|
$hashtied=1; |
$env{'user.domain'}.'___&&&___'.$comment;
|
} |
}
|
} |
|
} |
$LONCAPA::map::resources[$newidx]=
|
} |
$comment.':'.$url.':'.$ext.':normal:res';
|
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
|
sub untiehash { |
($errtext,$fatal)=&storemap($coursenum,$coursedom,
|
if ($hashtied) { untie %hash; } |
$folder.'.'.$container);
|
$hashtied=0; |
if ($fatal) {
|
} |
$$upload_output .= '<p><span class="LC_error">'.$errtext.'</span></p>';
|
|
return 'failed';
|
# --------------------------------------------------------------- check on this |
} else {
|
|
if ($parseaction eq 'parse') {
|
sub checkonthis { |
my $total_embedded = keys(%{$allfiles});
|
my ($r,$url,$level,$title)=@_; |
if ($total_embedded > 0) {
|
$url=&Apache::lonnet::unescape($url); |
my $num = 0;
|
$alreadyseen{$url}=1; |
my $state = '
|
$r->rflush(); |
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
|
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) { |
<input type="hidden" name="cmd" value="upload_embedded" />
|
$r->print("\n<br />"); |
<input type="hidden" name="newidx" value="'.$newidx.'" />
|
for (my $i=0;$i<=$level*5;$i++) { |
<input type="hidden" name="primaryurl" value="'.&escape($url).'" />
|
$r->print(' '); |
<input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
|
} |
$phase_status = 'phasetwo';
|
$r->print('<a href="'.$url.'" target="cat">'. |
|
($title?$title:$url).'</a> '); |
$$upload_output .=
|
if ($url=~/^\/res\//) { |
'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
|
my $result=&Apache::lonnet::repcopy( |
&Apache::loncommon::ask_for_embedded_content(
|
&Apache::lonnet::filelocation('',$url)); |
'/adm/coursedocs',$state,$allfiles,$codebase);
|
if ($result eq 'ok') { |
} else {
|
$r->print('<font color="green">'.&mt('ok').'</font>'); |
$$upload_output .= 'No embedded items identified<br />';
|
$r->rflush(); |
}
|
&Apache::lonnet::countacc($url); |
}
|
$url=~/\.(\w+)$/; |
}
|
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') { |
}
|
$r->print('<br />'); |
return $phase_status;
|
$r->rflush(); |
}
|
for (my $i=0;$i<=$level*5;$i++) { |
|
$r->print(' '); |
sub process_secondary_uploads {
|
} |
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
|
$r->print('- '.&mt('Rendering').': '); |
my $folder=$env{'form.folder'};
|
my ($errorcount,$warningcount)=split(/:/, |
my $destination = 'docs/';
|
&Apache::lonnet::ssi_body($url, |
if ($folder =~ /^supplemental/) {
|
('grade_target'=>'web', |
$destination = 'supplemental/';
|
'return_only_error_and_warning_counts' => 1))); |
}
|
if (($errorcount) || |
if (($folder eq 'default') || ($folder eq 'supplemental')) {
|
($warningcount)) { |
$destination .= 'default/';
|
if ($errorcount) { |
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
|
$r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'. |
$destination .= $2.'/';
|
$errorcount.' '. |
}
|
&mt('error(s)').'</b></font> '); |
$destination .= $newidx;
|
} |
my ($url,$filename);
|
if ($warningcount) { |
$url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
|
$r->print('<font color="blue">'. |
($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$});
|
$warningcount.' '. |
return $filename;
|
&mt('warning(s)').'</font>'); |
}
|
} |
|
} else { |
sub is_supplemental_title {
|
$r->print('<font color="green">'.&mt('ok').'</font>'); |
my ($title) = @_;
|
} |
return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
|
$r->rflush(); |
}
|
} |
|
my $dependencies= |
sub parse_supplemental_title {
|
&Apache::lonnet::metadata($url,'dependencies'); |
my ($title) = @_;
|
foreach (split(/\,/,$dependencies)) { |
|
if (($_=~/^\/res\//) && (!$alreadyseen{$_})) { |
my ($foldertitle,$renametitle);
|
&checkonthis($r,$_,$level+1); |
if ($title =~ /&&&/) {
|
} |
$title = &HTML::Entites::decode($title);
|
} |
}
|
} elsif ($result eq 'unavailable') { |
if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
|
$r->print('<font color="red"><b>'.&mt('connection down').'</b></font>'); |
$renametitle=$4;
|
} elsif ($result eq 'not_found') { |
my ($time,$uname,$udom) = ($1,$2,$3);
|
unless ($url=~/\$/) { |
$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
|
$r->print('<font color="red"><b>'.&mt('not found').'</b></font>'); |
my $name = &Apache::loncommon::plainname($uname,$udom);
|
} else { |
$name = &HTML::Entities::encode($name,'"<>&\'');
|
$r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>'); |
$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
|
} |
$name.': <br />'.$foldertitle;
|
} else { |
}
|
$r->print('<font color="red"><b>'.&mt('access denied').'</b></font>'); |
if (wantarray) {
|
} |
return ($title,$foldertitle,$renametitle);
|
} |
}
|
} |
return $title;
|
} |
}
|
|
|
|
# --------------------------------------------------------------- An entry line
|
# |
|
# ----------------------------------------------------------------- List Symbs |
sub entryline {
|
# |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
|
sub list_symbs { |
|
my $r=shift; |
my ($foldertitle,$pagetitle,$renametitle);
|
my $html=&Apache::lonxml::xmlbegin(); |
if (&is_supplemental_title($title)) {
|
$r->print($html.'<head><title>Symb List</title></head>'. |
($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
|
&Apache::loncommon::bodytag('Symb List')); |
$pagetitle = $foldertitle;
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
} else {
|
$r->print("<pre>\n"); |
$title=&HTML::Entities::encode($title,'"<>&\'');
|
foreach my $res ($navmap->retrieveResources()) { |
$renametitle=$title;
|
$r->print($res->compTitle()."\t".$res->symb()."\n"); |
$foldertitle=$title;
|
} |
$pagetitle=$title;
|
$r->print("\n</pre>\n"); |
}
|
$r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>'); |
|
} |
my $orderidx=$LONCAPA::map::order[$index];
|
|
|
|
|
# |
$renametitle=~s/\\/\\\\/g;
|
# -------------------------------------------------------------- Verify Content |
$renametitle=~s/\"\;/\\\"/g;
|
# |
$renametitle=~s/ /%20/g;
|
sub verifycontent { |
my $line='<tr>';
|
my $r=shift; |
my ($form_start,$form_end);
|
my $loaderror=&Apache::lonnet::overloaderror($r); |
# Edit commands
|
if ($loaderror) { return $loaderror; } |
my ($container, $type, $esc_path, $path, $symb);
|
my $html=&Apache::lonxml::xmlbegin(); |
if ($env{'form.folderpath'}) {
|
$r->print($html.'<head><title>Verify Content</title></head>'. |
$type = 'folder';
|
&Apache::loncommon::bodytag('Verify Course Documents')); |
$container = 'sequence';
|
$hashtied=0; |
$esc_path=&escape($env{'form.folderpath'});
|
undef %alreadyseen; |
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
%alreadyseen=(); |
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
|
&tiehash(); |
}
|
foreach (keys %hash) { |
if ($env{'form.pagepath'}) {
|
if ($hash{$_}=~/\.(page|sequence)$/) { |
$type = $container = 'page';
|
if (($_=~/^src_/) && ($alreadyseen{&Apache::lonnet::unescape($hash{$_})})) { |
$esc_path=&escape($path = $env{'form.pagepath'});
|
$r->print('<hr /><font color="red">'. |
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
|
&mt('The following sequence or page is included more than once in your course: '). |
$symb=&escape($env{'form.pagesymb'});
|
&Apache::lonnet::unescape($hash{$_}).'</font><br />'. |
}
|
&mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />')); |
my $cpinfo='';
|
} |
if ($allowed) {
|
} |
my $incindex=$index+1;
|
if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&Apache::lonnet::unescape($hash{$_})})) { |
my $selectbox='';
|
&checkonthis($r,$hash{$_},0,$hash{'title_'.$1}); |
if (($folder!~/^supplemental/) &&
|
} |
($#LONCAPA::map::order>0) &&
|
} |
((split(/\:/,
|
&untiehash(); |
$LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
|
$r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'. |
ne '') &&
|
&mt('Return to DOCS').'</a>'); |
((split(/\:/,
|
} |
$LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
|
|
ne '')) {
|
|
$selectbox=
|
# -------------------------------------------------------------- Check Versions |
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
|
|
'<select name="newpos" onChange="this.form.submit()">';
|
sub devalidateversioncache { |
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
|
my $src=shift; |
if ($i==$incindex) {
|
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. |
$selectbox.='<option value="" selected="1">('.$i.')</option>';
|
&Apache::lonnet::clutter($src)); |
} else {
|
} |
$selectbox.='<option value="'.$i.'">'.$i.'</option>';
|
|
}
|
sub checkversions { |
}
|
my $r=shift; |
$selectbox.='</select>';
|
my $html=&Apache::lonxml::xmlbegin(); |
}
|
$r->print($html.'<head><title>Check Versions</title></head>'. |
my %lt=&Apache::lonlocal::texthash(
|
&Apache::loncommon::bodytag('Check Course Document Versions')); |
'up' => 'Move Up',
|
my $header=''; |
'dw' => 'Move Down',
|
my $startsel=''; |
'rm' => 'Remove',
|
my $monthsel=''; |
'ct' => 'Cut',
|
my $weeksel=''; |
'rn' => 'Rename',
|
my $daysel=''; |
'cp' => 'Copy');
|
my $allsel=''; |
my $nocopy=0;
|
my %changes=(); |
my $nocut=0;
|
my $starttime=0; |
if ($url=~/\.(page|sequence)$/) {
|
my $haschanged=0; |
if ($url =~ m{/res/}) {
|
my %setversions=&Apache::lonnet::dump('resourceversions', |
# no copy for published maps
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$nocopy = 1;
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
} else {
|
|
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
|
$hashtied=0; |
my ($title,$url,$ext,$type)=split(/\:/,$item);
|
&tiehash(); |
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
|
my %newsetversions=(); |
$nocopy=1;
|
if ($env{'form.setmostrecent'}) { |
last;
|
$haschanged=1; |
}
|
foreach (keys %hash) { |
}
|
if ($_=~/^ids\_(\/res\/.+)$/) { |
}
|
$newsetversions{$1}='mostrecent'; |
}
|
&devalidateversioncache($1); |
if ($url=~/^\/res\/lib\/templates\//) {
|
} |
$nocopy=1;
|
} |
$nocut=1;
|
} elsif ($env{'form.setcurrent'}) { |
}
|
$haschanged=1; |
my $copylink=' ';
|
foreach (keys %hash) { |
my $cutlink=' ';
|
if ($_=~/^ids\_(\/res\/.+)$/) { |
|
my $getvers=&Apache::lonnet::getversion($1); |
my $skip_confirm = 0;
|
if ($getvers>0) { |
if ( $folder =~ /^supplemental/
|
$newsetversions{$1}=$getvers; |
|| ($url =~ m{( /smppg$
|
&devalidateversioncache($1); |
|/syllabus$
|
} |
|/aboutme$
|
} |
|/navmaps$
|
} |
|/bulletinboard$
|
} elsif ($env{'form.setversions'}) { |
|\.html$
|
$haschanged=1; |
|^/adm/wrapper/ext)}x)) {
|
foreach (keys %env) { |
$skip_confirm = 1;
|
if ($_=~/^form\.set_version_(.+)$/) { |
}
|
my $src=$1; |
|
if (($env{$_}) && ($env{$_} ne $setversions{$src})) { |
if (!$nocopy) {
|
$newsetversions{$src}=$env{$_}; |
$copylink=(<<ENDCOPY);
|
&devalidateversioncache($src); |
<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
|
} |
ENDCOPY
|
} |
}
|
} |
if (!$nocut) {
|
} |
$cutlink=(<<ENDCUT);
|
if ($haschanged) { |
<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
|
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
ENDCUT
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
}
|
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
$form_start = (<<END);
|
$r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>'); |
<form action="/adm/coursedocs" method="post">
|
} else { |
<input type="hidden" name="${type}path" value="$path" />
|
$r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>'); |
<input type="hidden" name="${type}symb" value="$symb" />
|
} |
<input type="hidden" name="setparms" value="$orderidx" />
|
&mark_hash_old(); |
<input type="hidden" name="changeparms" value="0" />
|
} |
END
|
&changewarning($r,''); |
$form_end = '</form>';
|
if ($env{'form.timerange'} eq 'all') { |
$line.=(<<END);
|
# show all documents |
<td>
|
$header=&mt('All Documents in Course'); |
<table class="LC_docs_entry_move">
|
$allsel=1; |
<tr>
|
foreach (keys %hash) { |
<td>
|
if ($_=~/^ids\_(\/res\/.+)$/) { |
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /></a>
|
my $src=$1; |
</td>
|
$changes{$src}=1; |
</tr>
|
} |
<tr>
|
} |
<td>
|
} else { |
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /></a>
|
# show documents which changed |
</td>
|
%changes=&Apache::lonnet::dump |
</tr>
|
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'}, |
</table>
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
</td>
|
my $firstkey=(keys %changes)[0]; |
<td>
|
unless ($firstkey=~/^error\:/) { |
$form_start
|
unless ($env{'form.timerange'}) { |
$selectbox
|
$env{'form.timerange'}=604800; |
$form_end
|
} |
</td>
|
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' ' |
<td class="LC_docs_entry_commands">
|
.&mt('seconds'); |
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
|
if ($env{'form.timerange'}==-1) { |
$cutlink
|
$seltext='since start of course'; |
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
|
$startsel='selected'; |
$copylink
|
$env{'form.timerange'}=time; |
</td>
|
} |
END
|
$starttime=time-$env{'form.timerange'}; |
|
if ($env{'form.timerange'}==2592000) { |
}
|
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
# Figure out what kind of a resource this is
|
$monthsel='selected'; |
my ($extension)=($url=~/\.(\w+)$/);
|
} elsif ($env{'form.timerange'}==604800) { |
my $uploaded=($url=~/^\/*uploaded\//);
|
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
my $icon=&Apache::loncommon::icon($url);
|
$weeksel='selected'; |
my $isfolder=0;
|
} elsif ($env{'form.timerange'}==86400) { |
my $ispage=0;
|
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
my $folderarg;
|
$daysel='selected'; |
my $pagearg;
|
} |
my $pagefile;
|
$header=&mt('Content changed').' '.$seltext; |
if ($uploaded) {
|
} else { |
if ($extension eq 'sequence') {
|
$header=&mt('No content modifications yet.'); |
$icon=$iconpath.'/folder_closed.gif';
|
} |
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
|
} |
$url='/adm/coursedocs?';
|
%setversions=&Apache::lonnet::dump('resourceversions', |
$folderarg=$1;
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$isfolder=1;
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
} elsif ($extension eq 'page') {
|
my %lt=&Apache::lonlocal::texthash |
$icon=$iconpath.'/page.gif';
|
('st' => 'Version changes since start of Course', |
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
|
'lm' => 'Version changes since last Month', |
$pagearg=$1;
|
'lw' => 'Version changes since last Week', |
$url='/adm/coursedocs?';
|
'sy' => 'Version changes since Yesterday', |
$ispage=1;
|
'al' => 'All Resources (possibly large output)', |
} else {
|
'sd' => 'Display', |
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
|
'fi' => 'File', |
}
|
'md' => 'Modification Date', |
}
|
'mr' => 'Most recently published Version', |
|
've' => 'Version used in Course', |
my $orig_url = $url;
|
'vu' => 'Set Version to be used in Course', |
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
|
'sv' => 'Set Versions to be used in Course according to Selections below', |
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
|
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)', |
my $symb=&Apache::lonnet::symbclean(
|
'sc' => 'Set all Resource Versions to current Version (Fix Versions)', |
&Apache::lonnet::declutter('uploaded/'.
|
'di' => 'Differences'); |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
$r->print(<<ENDHEADERS); |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
|
<form action="/adm/coursedocs" method="post"> |
'.sequence').
|
<input type="hidden" name="versions" value="1" /> |
'___'.$residx.'___'.
|
<input type="submit" name="setmostrecent" value="$lt{'sm'}" /> |
&Apache::lonnet::declutter($url));
|
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr /> |
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
|
<select name="timerange"> |
$url=&Apache::lonnet::clutter($url);
|
<option value='all' $allsel>$lt{'al'}</option> |
if ($url=~/^\/*uploaded\//) {
|
<option value="-1" $startsel>$lt{'st'}</option> |
$url=~/\.(\w+)$/;
|
<option value="2592000" $monthsel>$lt{'lm'}</option> |
my $embstyle=&Apache::loncommon::fileembstyle($1);
|
<option value="604800" $weeksel>$lt{'lw'}</option> |
if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
|
<option value="86400" $daysel>$lt{'sy'}</option> |
$url='/adm/wrapper'.$url;
|
</select> |
} elsif ($embstyle eq 'ssi') {
|
<input type="submit" name="display" value="$lt{'sd'}" /> |
#do nothing with these
|
<h3>$header</h3> |
} elsif ($url!~/\.(sequence|page)$/) {
|
<input type="submit" name="setversions" value="$lt{'sv'}" /> |
$url='/adm/coursedocs/showdoc'.$url;
|
<table border="0"> |
}
|
ENDHEADERS |
} elsif ($url=~m|^/ext/|) {
|
foreach (sort keys %changes) { |
$url='/adm/wrapper'.$url;
|
if ($changes{$_}>$starttime) { |
$external = 1;
|
my ($root,$extension)=($_=~/^(.*)\.(\w+)$/); |
}
|
my $currentversion=&Apache::lonnet::getversion($_); |
if (&Apache::lonnet::symbverify($symb,$url)) {
|
if ($currentversion<0) { |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
$currentversion=&mt('Could not be determined.'); |
} else {
|
} |
$url='';
|
my $linkurl=&Apache::lonnet::clutter($_); |
}
|
$r->print( |
if ($container eq 'page') {
|
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'. |
my $symb=$env{'form.pagesymb'};
|
&Apache::lonnet::gettitle($linkurl). |
|
'</b></font></td></tr>'. |
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
|
'<tr><td> </td>'. |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
'<td colspan="4">'. |
}
|
'<a href="'.$linkurl.'" target="cat">'.$linkurl. |
}
|
'</a></td></tr>'. |
my ($parameterset,$rand_order_text) = (' ', ' ');
|
'<tr><td></td>'. |
if ($isfolder || $extension eq 'sequence') {
|
'<td title="'.$lt{'md'}.'">'. |
my $foldername=&escape($foldertitle);
|
&Apache::lonlocal::locallocaltime( |
my $folderpath=$env{'form.folderpath'};
|
&Apache::lonnet::metadata($root.'.'.$extension, |
if ($folderpath) { $folderpath.='&' };
|
'lastrevisiondate') |
# Append randompick number, hidden, and encrypted with ":" to foldername,
|
). |
# so it gets transferred between levels
|
'</td>'. |
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
|
'<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '. |
'parameter_randompick'))[0]
|
'<font size="+1">'.$currentversion.'</font>'. |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
'</nobr></td>'. |
'parameter_hiddenresource'))[0]=~/^yes$/i)
|
'<td title="'.$lt{'ve'}.'"><nobr>In Course: '. |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
'<font size="+1">'); |
'parameter_encrypturl'))[0]=~/^yes$/i)
|
# Used in course |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
my $usedversion=$hash{'version_'.$linkurl}; |
'parameter_randomorder'))[0]=~/^yes$/i);
|
if (($usedversion) && ($usedversion ne 'mostrecent')) { |
$url.='folderpath='.&escape($folderpath).$cpinfo;
|
$r->print($usedversion); |
$parameterset='<label>'.&mt('Randomly Pick: ').
|
} else { |
'<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'.
|
$r->print($currentversion); |
(&LONCAPA::map::getparameter($orderidx,
|
} |
'parameter_randompick'))[0].
|
$r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'. |
'" />'.
|
'<nobr>Use: '); |
'<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
|
# Set version |
my $ro_set=
|
$r->print(&Apache::loncommon::select_form($setversions{$linkurl}, |
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
|
'set_version_'.$linkurl, |
$rand_order_text ='
|
('select_form_order' => |
<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';
|
['',1..$currentversion,'mostrecent'], |
}
|
'' => '', |
if ($ispage) {
|
'mostrecent' => 'most recent', |
my $pagename=&escape($pagetitle);
|
map {$_,$_} (1..$currentversion)))); |
my $pagepath;
|
$r->print('</nobr></td></tr><tr><td></td>'); |
my $folderpath=$env{'form.folderpath'};
|
my $lastold=1; |
if ($folderpath) { $pagepath = $folderpath.'&' };
|
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
$pagepath.=$pagearg.'&'.$pagename;
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
my $symb=$env{'form.pagesymb'};
|
if (&Apache::lonnet::metadata($url,'lastrevisiondate')< |
if (!$symb) {
|
$starttime) { |
my $path='uploaded/'.
|
$lastold=$prevvers; |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
} |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/';
|
} |
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
|
# |
$residx,
|
# Code to figure out how many version entries should go in |
$path.$pagearg.'.page');
|
# each of the four columns |
}
|
my $entries_per_col = 0; |
$url.='pagepath='.&escape($pagepath).
|
my $num_entries = ($currentversion-$lastold); |
'&pagesymb='.&escape($symb).$cpinfo;
|
if ($num_entries % 4 == 0) { |
}
|
$entries_per_col = $num_entries/4; |
if ($external) {
|
} else { |
my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
|
$entries_per_col = $num_entries/4 + 1; |
$external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
|
} |
} else {
|
my $entries_count = 0; |
undef($external);
|
$r->print('<td valign="top"><font size="-2">'); |
}
|
my $cols_output = 1; |
$line.='
|
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { |
<td class="LC_docs_entry_icon">
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
'.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').'
|
$r->print('<nobr><a href="'.&Apache::lonnet::clutter($url). |
</td>
|
'">'.&mt('Version').' '.$prevvers.'</a> ('. |
<td class="LC_docs_entry_title">
|
&Apache::lonlocal::locallocaltime( |
'.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.&mt('(re-initialize course to access)').'</span>').$external."
|
&Apache::lonnet::metadata($url, |
</td>";
|
'lastrevisiondate') |
if (($allowed) && ($folder!~/^supplemental/)) {
|
). |
my %lt=&Apache::lonlocal::texthash(
|
')'); |
'hd' => 'Hidden',
|
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { |
'ec' => 'URL hidden');
|
$r->print(' <a href="/adm/diff?filename='. |
my $enctext=
|
&Apache::lonnet::clutter($root.'.'.$extension). |
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
|
'&versionone='.$prevvers. |
my $hidtext=
|
'">'.&mt('Diffs').'</a>'); |
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
|
} |
$line.=(<<ENDPARMS);
|
$r->print('</nobr><br />'); |
<td class="LC_docs_entry_parameter">
|
if (++$entries_count % $entries_per_col == 0) { |
$form_start
|
$r->print('</font></td>'); |
<label><input type="checkbox" name="hiddenresource_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
|
if ($cols_output != 4) { |
$form_end
|
$r->print('<td valign="top"><font size="-2">'); |
</td>
|
$cols_output++; |
<td class="LC_docs_entry_parameter">
|
} |
$form_start
|
} |
<label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
|
} |
$form_end
|
while($cols_output++ < 4) { |
</td>
|
$r->print('</font></td><td><font>') |
<td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
|
} |
<td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>
|
$r->print('</font></td></tr>'."\n"); |
ENDPARMS
|
} |
}
|
} |
$line.="</tr>";
|
$r->print('</table></form>'); |
return $line;
|
$r->print('<h1>'.&mt('Done').'.</h1>'); |
}
|
|
|
&untiehash(); |
=pod
|
} |
|
|
=item tiehash()
|
sub mark_hash_old { |
|
my $retie_hash=0; |
tie the hash
|
if ($hashtied) { |
|
$retie_hash=1; |
=cut
|
&untiehash(); |
|
} |
sub tiehash {
|
&tiehash('write'); |
my ($mode)=@_;
|
$hash{'old'}=1; |
$hashtied=0;
|
&untiehash(); |
if ($env{'request.course.fn'}) {
|
if ($retie_hash) { &tiehash(); } |
if ($mode eq 'write') {
|
} |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
|
&GDBM_WRCREAT(),0640)) {
|
sub is_hash_old { |
$hashtied=2;
|
my $untie_hash=0; |
}
|
if (!$hashtied) { |
} else {
|
$untie_hash=1; |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
&tiehash(); |
&GDBM_READER(),0640)) {
|
} |
$hashtied=1;
|
my $return=$hash{'old'}; |
}
|
if ($untie_hash) { &untiehash(); } |
}
|
return $return; |
}
|
} |
}
|
|
|
sub changewarning { |
sub untiehash {
|
my ($r,$postexec,$message,$url)=@_; |
if ($hashtied) { untie %hash; }
|
if (!&is_hash_old()) { return; } |
$hashtied=0;
|
my $pathvar='folderpath'; |
return OK;
|
my $path=&Apache::lonnet::escape($env{'form.folderpath'}); |
}
|
if (!defined($url)) { |
|
if (defined($env{'form.pagepath'})) { |
|
$pathvar='pagepath'; |
|
$path=&Apache::lonnet::escape($env{'form.pagepath'}); |
|
$path.='&pagesymb='.&Apache::lonnet::escape($env{'form.pagesymb'}); |
sub checkonthis {
|
} |
my ($r,$url,$level,$title)=@_;
|
$url='/adm/coursedocs?'.$pathvar.'='.$path; |
$url=&unescape($url);
|
} |
$alreadyseen{$url}=1;
|
if (!defined($message)) { |
$r->rflush();
|
$message='Changes will become active for your current session after [_1], or the next time you log in.'; |
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
|
} |
$r->print("\n<br />");
|
$r->print("\n\n". |
if ($level==0) {
|
'<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n". |
$r->print("<br />");
|
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'. |
}
|
'<input type="hidden" name="orgurl" value="'.$url. |
for (my $i=0;$i<=$level*5;$i++) {
|
'" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'. |
$r->print(' ');
|
&mt($message,' <input type="hidden" name="'. |
}
|
$env{'request.role'}.'" value="1" /><input type="button" value="'. |
$r->print('<a href="'.$url.'" target="cat">'.
|
&mt('re-initializing course').'" onClick="reinit(this.form)" />'). |
($title?$title:$url).'</a> ');
|
$help{'Caching'}.'</font></h3></form>'."\n\n"); |
if ($url=~/^\/res\//) {
|
} |
my $result=&Apache::lonnet::repcopy(
|
|
&Apache::lonnet::filelocation('',$url));
|
# ================================================================ Main Handler |
if ($result eq 'ok') {
|
sub handler { |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
my $r = shift; |
$r->rflush();
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::lonnet::countacc($url);
|
$r->send_http_header; |
$url=~/\.(\w+)$/;
|
return OK if $r->header_only; |
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
|
|
$r->print('<br />');
|
# --------------------------------------------- Initialize help topics for this |
$r->rflush();
|
foreach ('Adding_Course_Doc','Main_Course_Documents', |
for (my $i=0;$i<=$level*5;$i++) {
|
'Adding_External_Resource','Navigate_Content', |
$r->print(' ');
|
'Adding_Folders','Docs_Overview', 'Load_Map', |
}
|
'Supplemental','Score_Upload_Form','Adding_Pages', |
$r->print('- '.&mt('Rendering:').' ');
|
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', |
my ($errorcount,$warningcount)=split(/:/,
|
'Check_Resource_Versions','Verify_Content') { |
&Apache::lonnet::ssi_body($url,
|
$help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_); |
('grade_target'=>'web',
|
} |
'return_only_error_and_warning_counts' => 1)));
|
# Composite help files |
if (($errorcount) ||
|
$help{'Syllabus'} = &Apache::loncommon::help_open_topic( |
($warningcount)) {
|
'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); |
if ($errorcount) {
|
$help{'Simple Page'} = &Apache::loncommon::help_open_topic( |
$r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.
|
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages'); |
&mt('[quant,_1,error]',$errorcount).'</span>');
|
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic( |
}
|
'Option_Response_Simple'); |
if ($warningcount) {
|
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( |
$r->print('<span class="LC_warning">'.
|
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); |
&mt('[quant,_1,warning]',$warningcount).'</span>');
|
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic( |
}
|
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); |
} else {
|
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
|
}
|
if ($env{'form.verify'}) { |
$r->rflush();
|
&verifycontent($r); |
}
|
} elsif ($env{'form.listsymbs'}) { |
my $dependencies=
|
&list_symbs($r); |
&Apache::lonnet::metadata($url,'dependencies');
|
} elsif ($env{'form.versions'}) { |
foreach my $dep (split(/\,/,$dependencies)) {
|
&checkversions($r); |
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
|
} elsif ($env{'form.dumpcourse'}) { |
&checkonthis($r,$dep,$level+1);
|
&dumpcourse($r); |
}
|
} elsif ($env{'form.exportcourse'}) { |
}
|
&exportcourse($r); |
} elsif ($result eq 'unavailable') {
|
} else { |
$r->print('<span class="LC_error">'.&mt('connection down').'</span>');
|
# is this a standard course? |
} elsif ($result eq 'not_found') {
|
|
unless ($url=~/\$/) {
|
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//); |
$r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
|
my $forcestandard = 0; |
} else {
|
my $forcesupplement; |
$r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');
|
my $script=''; |
}
|
my $allowed; |
} else {
|
my $events=''; |
$r->print('<span class="LC_error">'.&mt('access denied').'</span>');
|
my $showdoc=0; |
}
|
my $containertag; |
}
|
my $uploadtag; |
}
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
}
|
['folderpath','pagepath','pagesymb','markedcopy_url','markedcopy_title']); |
|
if ($env{'form.folderpath'}) { |
|
my (@folderpath)=split('&',$env{'form.folderpath'}); |
|
$env{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath)); |
=pod
|
$env{'form.folder'}=pop(@folderpath); |
|
} |
=item list_symbs()
|
if ($env{'form.pagepath'}) { |
|
my (@pagepath)=split('&',$env{'form.pagepath'}); |
List Symbs
|
$env{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath)); |
|
$env{'form.folder'}=pop(@pagepath); |
=cut
|
$containertag = '<input type="hidden" name="pagepath" value="" />'. |
|
'<input type="hidden" name="pagesymb" value="" />'; |
sub list_symbs {
|
$uploadtag = '<input type="hidden" name="pagepath" value="'.$env{'form.pagepath'}.'" />'. |
my ($r) = @_;
|
'<input type="hidden" name="pagesymb" value="'.$env{'form.pagesymb'}.'" />'; |
|
} |
my $type = &Apache::loncommon::course_type();
|
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { |
$r->print(&Apache::loncommon::start_page('Symb List'));
|
$showdoc='/'.$1; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
|
} |
my $navmap = Apache::lonnavmaps::navmap->new();
|
unless ($showdoc) { # got called from remote |
if (!defined($navmap)) {
|
if (($env{'form.folder'}=~/^default_/) || |
$r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
|
($env{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) { |
'<div class="LC_error">'.
|
$forcestandard = 1; |
&mt('Unable to retrieve information about course contents').
|
} |
'</div>');
|
$forcesupplement=($env{'form.folder'}=~/^supplemental_/); |
&Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
|
|
} else {
|
# does this user have privileges to post, etc? |
$r->print("<pre>\n");
|
$allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
foreach my $res ($navmap->retrieveResources()) {
|
if ($allowed) { |
$r->print($res->compTitle()."\t".$res->symb()."\n");
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); |
}
|
$script=&Apache::lonratedt::editscript('simple'); |
$r->print("\n</pre>\n");
|
} |
}
|
} else { # got called in sequence from course |
$r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
|
$allowed=0; |
}
|
$script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>'; |
|
$events='onLoad="'.&Apache::lonmenu::loadevents. |
|
'" onUnload="'.&Apache::lonmenu::unloadevents.'"'; |
sub verifycontent {
|
} |
my ($r) = @_;
|
|
my $type = &Apache::loncommon::course_type();
|
# get course data |
my $loaderror=&Apache::lonnet::overloaderror($r);
|
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
if ($loaderror) { return $loaderror; }
|
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
$r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
|
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
|
# get personal data |
$hashtied=0;
|
|
undef %alreadyseen;
|
my $uname=$env{'user.name'}; |
%alreadyseen=();
|
my $udom=$env{'user.domain'}; |
&tiehash();
|
my $plainname=&Apache::lonnet::escape( |
foreach my $key (keys(%hash)) {
|
&Apache::loncommon::plainname($uname,$udom)); |
if ($hash{$key}=~/\.(page|sequence)$/) {
|
|
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
|
# graphics settings |
$r->print('<hr /><span class="LC_error">'.
|
|
&mt('The following sequence or page is included more than once in your '.$type.': ').
|
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/"); |
&unescape($hash{$key}).'</span><br />'.
|
|
&mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
|
my $now=time; |
}
|
|
}
|
# print screen |
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
|
my $html=&Apache::lonxml::xmlbegin(); |
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
|
$r->print(<<ENDDOCUMENT); |
}
|
$html |
}
|
<head> |
&untiehash();
|
<title>The LearningOnline Network with CAPA</title> |
$r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
|
<script> |
&mt('Return to DOCS').'</a>');
|
$script |
}
|
</script> |
|
ENDDOCUMENT |
|
if ($allowed) { |
sub devalidateversioncache {
|
$r->print(<<ENDNEWSCRIPT); |
my $src=shift;
|
<script> |
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
|
function makenewfolder(targetform,folderseq) { |
&Apache::lonnet::clutter($src));
|
var foldername=prompt('Name of New Folder','New Folder'); |
}
|
if (foldername) { |
|
targetform.importdetail.value=foldername+"="+folderseq; |
sub checkversions {
|
targetform.submit(); |
my ($r) = @_;
|
} |
my $type = &Apache::loncommon::course_type();
|
} |
$r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
|
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
|
function makenewpage(targetform,folderseq) { |
my $header='';
|
var pagename=prompt('Name of New Page','New Page'); |
my $startsel='';
|
if (pagename) { |
my $monthsel='';
|
targetform.importdetail.value=pagename+"="+folderseq; |
my $weeksel='';
|
targetform.submit(); |
my $daysel='';
|
} |
my $allsel='';
|
} |
my %changes=();
|
|
my $starttime=0;
|
function makenewext(targetname) { |
my $haschanged=0;
|
this.document.forms.extimport.useform.value=targetname; |
my %setversions=&Apache::lonnet::dump('resourceversions',
|
window.open('/adm/rat/extpickframe.html'); |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
} |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
|
|
function makeexamupload() { |
$hashtied=0;
|
var title=prompt('Listed Title for the Uploaded Score'); |
&tiehash();
|
if (title) { |
my %newsetversions=();
|
this.document.forms.newexamupload.importdetail.value= |
if ($env{'form.setmostrecent'}) {
|
title+'=/res/lib/templates/examupload.problem'; |
$haschanged=1;
|
this.document.forms.newexamupload.submit(); |
foreach my $key (keys(%hash)) {
|
} |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
} |
$newsetversions{$1}='mostrecent';
|
|
&devalidateversioncache($1);
|
function makesmppage() { |
}
|
var title=prompt('Listed Title for the Page'); |
}
|
if (title) { |
} elsif ($env{'form.setcurrent'}) {
|
this.document.forms.newsmppg.importdetail.value= |
$haschanged=1;
|
title+'=/adm/$udom/$uname/$now/smppg'; |
foreach my $key (keys(%hash)) {
|
this.document.forms.newsmppg.submit(); |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
} |
my $getvers=&Apache::lonnet::getversion($1);
|
} |
if ($getvers>0) {
|
|
$newsetversions{$1}=$getvers;
|
function makesmpproblem() { |
&devalidateversioncache($1);
|
var title=prompt('Listed Title for the Problem'); |
}
|
if (title) { |
}
|
this.document.forms.newsmpproblem.importdetail.value= |
}
|
title+'=/res/lib/templates/simpleproblem.problem'; |
} elsif ($env{'form.setversions'}) {
|
this.document.forms.newsmpproblem.submit(); |
$haschanged=1;
|
} |
foreach my $key (keys(%env)) {
|
} |
if ($key=~/^form\.set_version_(.+)$/) {
|
|
my $src=$1;
|
function makebulboard() { |
if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
|
var title=prompt('Listed Title for the Bulletin Board'); |
$newsetversions{$src}=$env{$key};
|
if (title) { |
&devalidateversioncache($src);
|
this.document.forms.newbul.importdetail.value= |
}
|
title+'=/adm/$udom/$uname/$now/bulletinboard'; |
}
|
this.document.forms.newbul.submit(); |
}
|
} |
}
|
} |
if ($haschanged) {
|
|
if (&Apache::lonnet::put('resourceversions',\%newsetversions,
|
function makeabout() { |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
var user=prompt("Enter user\@domain for User's 'About Me' Page"); |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
|
if (user) { |
$r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>');
|
var comp=new Array(); |
} else {
|
comp=user.split('\@'); |
$r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>');
|
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) { |
}
|
if ((comp[0]) && (comp[1])) { |
&mark_hash_old();
|
this.document.forms.newaboutsomeone.importdetail.value= |
}
|
'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; |
&changewarning($r,'');
|
this.document.forms.newaboutsomeone.submit(); |
if ($env{'form.timerange'} eq 'all') {
|
} else { |
# show all documents
|
alert("Not a valid user\@domain"); |
$header=&mt('All Documents in '.$type);
|
} |
$allsel=1;
|
} else { |
foreach my $key (keys(%hash)) {
|
alert("Please enter both user and domain in the format user\@domain"); |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
} |
my $src=$1;
|
} |
$changes{$src}=1;
|
} |
}
|
|
}
|
function makeims() { |
} else {
|
var caller = document.forms.ims.folder.value; |
# show documents which changed
|
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"; |
%changes=&Apache::lonnet::dump
|
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes"); |
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
|
newWindow.location.href = newlocation; |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
} |
my $firstkey=(keys(%changes))[0];
|
|
unless ($firstkey=~/^error\:/) {
|
|
unless ($env{'form.timerange'}) {
|
function finishpick() { |
$env{'form.timerange'}=604800;
|
var title=this.document.forms.extimport.title.value; |
}
|
var url=this.document.forms.extimport.url.value; |
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
|
var form=this.document.forms.extimport.useform.value; |
.&mt('seconds');
|
eval |
if ($env{'form.timerange'}==-1) {
|
('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+ |
$seltext='since start of course';
|
'";this.document.forms.'+form+'.submit();'); |
$startsel='selected';
|
} |
$env{'form.timerange'}=time;
|
|
}
|
function changename(folderpath,index,oldtitle,container,pagesymb) { |
$starttime=time-$env{'form.timerange'};
|
var title=prompt('New Title',oldtitle); |
if ($env{'form.timerange'}==2592000) {
|
if (title) { |
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
this.document.forms.renameform.title.value=title; |
$monthsel='selected';
|
this.document.forms.renameform.cmd.value='rename_'+index; |
} elsif ($env{'form.timerange'}==604800) {
|
if (container == 'sequence') { |
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
this.document.forms.renameform.folderpath.value=folderpath; |
$weeksel='selected';
|
} |
} elsif ($env{'form.timerange'}==86400) {
|
if (container == 'page') { |
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
this.document.forms.renameform.pagepath.value=folderpath; |
$daysel='selected';
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
}
|
} |
$header=&mt('Content changed').' '.$seltext;
|
this.document.forms.renameform.submit(); |
} else {
|
} |
$header=&mt('No content modifications yet.');
|
} |
}
|
|
}
|
function removeres(folderpath,index,oldtitle,container,pagesymb) { |
%setversions=&Apache::lonnet::dump('resourceversions',
|
if (confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) { |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
this.document.forms.renameform.cmd.value='del_'+index; |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
if (container == 'sequence') { |
my %lt=&Apache::lonlocal::texthash
|
this.document.forms.renameform.folderpath.value=folderpath; |
('st' => 'Version changes since start of '.$type,
|
} |
'lm' => 'Version changes since last Month',
|
if (container == 'page') { |
'lw' => 'Version changes since last Week',
|
this.document.forms.renameform.pagepath.value=folderpath; |
'sy' => 'Version changes since Yesterday',
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
'al' => 'All Resources (possibly large output)',
|
} |
'sd' => 'Display',
|
this.document.forms.renameform.submit(); |
'fi' => 'File',
|
} |
'md' => 'Modification Date',
|
} |
'mr' => 'Most recently published Version',
|
|
've' => 'Version used in '.$type,
|
function cutres(folderpath,index,oldtitle,container,pagesymb) { |
'vu' => 'Set Version to be used in '.$type,
|
if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) { |
'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
|
this.document.forms.renameform.cmd.value='cut_'+index; |
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
|
this.document.forms.renameform.markcopy.value=index; |
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
|
if (container == 'sequence') { |
'di' => 'Differences');
|
this.document.forms.renameform.folderpath.value=folderpath; |
$r->print(<<ENDHEADERS);
|
} |
<form action="/adm/coursedocs" method="post">
|
if (container == 'page') { |
<input type="hidden" name="versions" value="1" />
|
this.document.forms.renameform.pagepath.value=folderpath; |
<input type="submit" name="setmostrecent" value="$lt{'sm'}" />
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
|
} |
<select name="timerange">
|
this.document.forms.renameform.submit(); |
<option value='all' $allsel>$lt{'al'}</option>
|
} |
<option value="-1" $startsel>$lt{'st'}</option>
|
} |
<option value="2592000" $monthsel>$lt{'lm'}</option>
|
|
<option value="604800" $weeksel>$lt{'lw'}</option>
|
function markcopy(folderpath,index,oldtitle,container,pagesymb) { |
<option value="86400" $daysel>$lt{'sy'}</option>
|
this.document.forms.renameform.markcopy.value=index; |
</select>
|
if (container == 'sequence') { |
<input type="submit" name="display" value="$lt{'sd'}" />
|
this.document.forms.renameform.folderpath.value=folderpath; |
<h3>$header</h3>
|
} |
<input type="submit" name="setversions" value="$lt{'sv'}" />
|
if (container == 'page') { |
<table border="0">
|
this.document.forms.renameform.pagepath.value=folderpath; |
ENDHEADERS
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
foreach my $key (sort(keys(%changes))) {
|
} |
if ($changes{$key}>$starttime) {
|
this.document.forms.renameform.submit(); |
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
|
} |
my $currentversion=&Apache::lonnet::getversion($key);
|
|
if ($currentversion<0) {
|
</script> |
$currentversion=&mt('Could not be determined.');
|
|
}
|
ENDNEWSCRIPT |
my $linkurl=&Apache::lonnet::clutter($key);
|
} |
$r->print(
|
# -------------------------------------------------------------------- Body tag |
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
|
$r->print('</head>'. |
&Apache::lonnet::gettitle($linkurl).
|
&Apache::loncommon::bodytag('Course Documents','',$events, |
'</b></font></td></tr>'.
|
'','',$showdoc). |
'<tr><td> </td>'.
|
&Apache::loncommon::help_open_menu('','','','',273,'RAT')); |
'<td colspan="4">'.
|
my %allfiles = (); |
'<a href="'.$linkurl.'" target="cat">'.$linkurl.
|
my %codebase = (); |
'</a></td></tr>'.
|
my ($upload_result,$upload_output); |
'<tr><td></td>'.
|
if ($allowed) { |
'<td title="'.$lt{'md'}.'">'.
|
if (($env{'form.uploaddoc.filename'}) && ($env{'form.cmd'}=~/^upload_(\w+)/)) { |
&Apache::lonlocal::locallocaltime(
|
# Process file upload - phase one - upload and parse primary file. |
&Apache::lonnet::metadata($root.'.'.$extension,
|
$upload_result = &process_file_upload(\$upload_output,$coursenum, |
'lastrevisiondate')
|
$coursedom,\%allfiles, |
).
|
\%codebase,$1); |
'</td>'.
|
if ($upload_result eq 'phasetwo') { |
'<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '.
|
$r->print($upload_output); |
'<font size="+1">'.$currentversion.'</font>'.
|
} |
'</span></td>'.
|
} elsif ($env{'form.phasetwo'}) { |
'<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$type.': '.
|
my %newname = (); |
'<font size="+1">');
|
my %origname = (); |
# Used in course
|
my %attribs = (); |
my $usedversion=$hash{'version_'.$linkurl};
|
my $updateflag = 0; |
if (($usedversion) && ($usedversion ne 'mostrecent')) {
|
my $residx = $env{'form.newidx'}; |
$r->print($usedversion);
|
my $primary_url = &Apache::lonnet::unescape($env{'form.primaryurl'}); |
} else {
|
# Process file upload - phase two - gather secondary files. |
$r->print($currentversion);
|
for (my $i=0; $i<$env{'form.phasetwo'}; $i++) { |
}
|
if ($env{'form.embedded_item_'.$i.'.filename'}) { |
$r->print('</font></span></td><td title="'.$lt{'vu'}.'">'.
|
my $javacodebase; |
'<span class="LC_nobreak">Use: ');
|
$newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx); |
# Set version
|
$origname{$i} = &Apache::lonnet::unescape($env{'form.embedded_orig_'.$i}); |
$r->print(&Apache::loncommon::select_form($setversions{$linkurl},
|
if (exists($env{'form.embedded_codebase_'.$i})) { |
'set_version_'.$linkurl,
|
$javacodebase = &Apache::lonnet::unescape($env{'form.embedded_codebase_'.$i}); |
('select_form_order' =>
|
$origname{$i} =~ s#^\Q$javacodebase\E/##; |
['',1..$currentversion,'mostrecent'],
|
} |
'' => '',
|
my @attributes = (); |
'mostrecent' => 'most recent',
|
if ($env{'form.embedded_attrib_'.$i} =~ /:/) { |
map {$_,$_} (1..$currentversion))));
|
@attributes = split/:/,$env{'form.embedded_attrib_'.$i}; |
$r->print('</span></td></tr><tr><td></td>');
|
} else { |
my $lastold=1;
|
@attributes = ($env{'form.embedded_attrib_'.$i}); |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
|
} |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
foreach (@attributes) { |
if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
|
push(@{$attribs{$i}},&Apache::lonnet::unescape($_)); |
$starttime) {
|
} |
$lastold=$prevvers;
|
if ($javacodebase) { |
}
|
$codebase{$i} = $javacodebase; |
}
|
$codebase{$i} =~ s#/$##; |
#
|
$updateflag = 1; |
# Code to figure out how many version entries should go in
|
} |
# each of the four columns
|
} |
my $entries_per_col = 0;
|
unless ($newname{$i} eq $origname{$i}) { |
my $num_entries = ($currentversion-$lastold);
|
$updateflag = 1; |
if ($num_entries % 4 == 0) {
|
} |
$entries_per_col = $num_entries/4;
|
} |
} else {
|
# Process file upload - phase three - modify primary file |
$entries_per_col = $num_entries/4 + 1;
|
if ($updateflag) { |
}
|
my ($content,$rtncode); |
my $entries_count = 0;
|
my $updateflag = 0; |
$r->print('<td valign="top"><font size="-2">');
|
my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode); |
my $cols_output = 1;
|
if ($getstatus eq 'ok') { |
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
|
foreach my $item (keys %newname) { |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
if ($newname{$item} ne $origname{$item}) { |
$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
|
my $attrib_regexp = ''; |
'">'.&mt('Version').' '.$prevvers.'</a> ('.
|
if (@{$attribs{$item}} > 1) { |
&Apache::lonlocal::locallocaltime(
|
$attrib_regexp = join('|',@{$attribs{$item}}); |
&Apache::lonnet::metadata($url,
|
} else { |
'lastrevisiondate')
|
$attrib_regexp = $attribs{$item}[0]; |
).
|
} |
')');
|
if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) { |
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
|
} |
$r->print(' <a href="/adm/diff?filename='.
|
$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi; |
&Apache::lonnet::clutter($root.'.'.$extension).
|
} |
'&versionone='.$prevvers.
|
if (exists($codebase{$item})) { |
'">'.&mt('Diffs').'</a>');
|
$content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; |
}
|
} |
$r->print('</span><br />');
|
} |
if (++$entries_count % $entries_per_col == 0) {
|
# Save edited file. |
$r->print('</font></td>');
|
my $saveresult; |
if ($cols_output != 4) {
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
$r->print('<td valign="top"><font size="-2">');
|
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cols_output++;
|
my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult); |
}
|
} else { |
}
|
&Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus); |
}
|
} |
while($cols_output++ < 4) {
|
} |
$r->print('</font></td><td><font>')
|
} |
}
|
} |
$r->print('</font></td></tr>'."\n");
|
|
}
|
unless ($showdoc || $upload_result eq 'phasetwo') { |
}
|
# ----------------------------------------------------------------------------- |
$r->print('</table></form>');
|
my %lt=&Apache::lonlocal::texthash( |
$r->print('<h1>'.&mt('Done').'.</h1>');
|
'uplm' => 'Upload a new main course document', |
|
'upls' => 'Upload a new supplemental course document', |
&untiehash();
|
'impp' => 'Import a document', |
}
|
'pubd' => 'Published documents', |
|
'copm' => 'All documents out of a published map into this folder', |
sub mark_hash_old {
|
'spec' => 'Special documents', |
my $retie_hash=0;
|
'upld' => 'Upload Document', |
if ($hashtied) {
|
'srch' => 'Search', |
$retie_hash=1;
|
'impo' => 'Import', |
&untiehash();
|
'selm' => 'Select Map', |
}
|
'load' => 'Load Map', |
&tiehash('write');
|
'reco' => 'Recover Deleted Resources', |
$hash{'old'}=1;
|
'newf' => 'New Folder', |
&untiehash();
|
'newp' => 'New Composite Page', |
if ($retie_hash) { &tiehash(); }
|
'extr' => 'External Resource', |
}
|
'syll' => 'Syllabus', |
|
'navc' => 'Navigate Contents', |
sub is_hash_old {
|
'sipa' => 'Simple Page', |
my $untie_hash=0;
|
'sipr' => 'Simple Problem', |
if (!$hashtied) {
|
'scuf' => 'Score Upload Form', |
$untie_hash=1;
|
'bull' => 'Bulletin Board', |
&tiehash();
|
'mypi' => 'My Personal Info', |
}
|
'abou' => 'About User', |
my $return=$hash{'old'};
|
'imsf' => 'Import IMS package', |
if ($untie_hash) { &untiehash(); }
|
'file' => 'File', |
return $return;
|
'title' => 'Title', |
}
|
'comment' => 'Comment', |
|
'parse' => 'If HTML file, upload embedded images/multimedia files' |
sub changewarning {
|
); |
my ($r,$postexec,$message,$url)=@_;
|
# ----------------------------------------------------------------------------- |
if (!&is_hash_old()) { return; }
|
if ($allowed) { |
my $pathvar='folderpath';
|
my $dumpbut=&dumpbutton(); |
my $path=&escape($env{'form.folderpath'});
|
my $exportbut=&exportbutton(); |
if (!defined($url)) {
|
my %lt=&Apache::lonlocal::texthash( |
if (defined($env{'form.pagepath'})) {
|
'vc' => 'Verify Content', |
$pathvar='pagepath';
|
'cv' => 'Check/Set Resource Versions', |
$path=&escape($env{'form.pagepath'});
|
'ls' => 'List Symbs', |
$path.='&pagesymb='.&escape($env{'form.pagesymb'});
|
); |
}
|
|
$url='/adm/coursedocs?'.$pathvar.'='.$path;
|
my $folderpath=$env{'form.folderpath'}; |
}
|
if (!$folderpath) { |
my $course_type = &Apache::loncommon::course_type();
|
if ($env{'form.folder'} eq '' || |
if (!defined($message)) {
|
$env{'form.folder'} eq 'supplemental') { |
$message='Changes will become active for your current session after [_1], or the next time you log in.';
|
$folderpath='default&'. |
}
|
&Apache::lonnet::escape(&mt('Main Course Documents')); |
$r->print("\n\n".
|
} |
'<script type="text/javascript">function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n".
|
} |
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
|
unless ($env{'form.pagepath'}) { |
'<input type="hidden" name="orgurl" value="'.$url.
|
$containertag = '<input type="hidden" name="folderpath" value="" />'; |
'" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
|
$uploadtag = '<input type="hidden" name="folderpath" value="'.$folderpath.'" />'; |
&mt($message,' <input type="hidden" name="'.
|
} |
$env{'request.role'}.'" value="1" /><input type="button" value="'.
|
|
&mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />').
|
$r->print(<<ENDCOURSEVERIFY); |
$help{'Caching'}.'</span></h3></form>'."\n\n");
|
<form name="renameform" method="post" action="/adm/coursedocs"> |
}
|
<input type="hidden" name="title" /> |
|
<input type="hidden" name="cmd" /> |
|
<input type="hidden" name="markcopy" /> |
sub init_breadcrumbs {
|
$containertag |
my ($form,$text)=@_;
|
</form> |
&Apache::lonhtmlcommon::clear_breadcrumbs();
|
<form name="simpleedit" method="post" action="/adm/coursedocs"> |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
|
<input type=hidden name="importdetail" value=""> |
text=>"Edit ".&Apache::loncommon::course_type(),
|
$uploadtag |
faq=>273,
|
</form> |
bug=>'Instructor Interface',
|
<form action="/adm/coursedocs" method="post" name="courseverify"> |
help => 'Docs_Adding_Course_Doc'});
|
<table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4"> |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
|
<tr><td bgcolor="#DDDDCC"> |
text=>$text,
|
<input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'} |
faq=>273,
|
</td><td bgcolor="#DDDDCC"> |
bug=>'Instructor Interface'});
|
<input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'} |
}
|
$dumpbut |
|
$exportbut |
|
</td><!-- <td bgcolor="#DDDDCC"> |
|
<input type="submit" name="listsymbs" value="$lt{'ls'}" /> |
|
</td>--></tr></table> |
sub handler {
|
</form> |
my $r = shift;
|
ENDCOURSEVERIFY |
&Apache::loncommon::content_type($r,'text/html');
|
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', |
$r->send_http_header;
|
&mt('Editing the Table of Contents for your Course'))); |
return OK if $r->header_only;
|
} |
my $type = &Apache::loncommon::course_type();
|
# --------------------------------------------------------- Standard documents |
|
$r->print('<table border=2 cellspacing=4 cellpadding=4>'); |
|
if (($standard) && ($allowed) && (!$forcesupplement)) { |
# --------------------------------------------- Initialize help topics for this
|
$r->print('<tr><td bgcolor="#BBBBBB">'); |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
|
# '<h2>'.&mt('Main Course Documents'). |
'Adding_External_Resource','Navigate_Content',
|
# ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>'); |
'Adding_Folders','Docs_Overview', 'Load_Map',
|
my $folder=$env{'form.folder'}; |
'Supplemental','Score_Upload_Form','Adding_Pages',
|
if ($folder eq '' || $folder eq 'supplemental') { |
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
|
$folder='default'; |
'Check_Resource_Versions','Verify_Content') {
|
$env{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents')); |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
|
} |
}
|
my $postexec=''; |
# Composite help files
|
if ($folder eq 'default') { |
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
|
$r->print('<script>this.window.name="loncapaclient";</script>'); |
'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
|
} else { |
$help{'Simple Page'} = &Apache::loncommon::help_open_topic(
|
#$postexec='self.close();'; |
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
|
} |
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
|
$hadchanges=0; |
'Option_Response_Simple');
|
&editor($r,$coursenum,$coursedom,$folder,$allowed,$upload_output); |
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
|
if ($hadchanges) { |
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
|
&mark_hash_old() |
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
|
} |
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
|
&changewarning($r,$postexec); |
$help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
|
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
|
'.sequence'; |
|
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
# does this user have privileges to modify docs
|
'.page'; |
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
|
my $container='sequence'; |
if ($allowed && $env{'form.verify'}) {
|
if ($env{'form.pagepath'}) { |
&init_breadcrumbs('verify','Verify Content');
|
$container='page'; |
&verifycontent($r);
|
} |
} elsif ($allowed && $env{'form.listsymbs'}) {
|
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; |
&init_breadcrumbs('listsymbs','List Symbs');
|
$r->print(<<ENDFORM); |
&list_symbs($r);
|
<table cellspacing=4 cellpadding=4><tr> |
} elsif ($allowed && $env{'form.docslog'}) {
|
<th bgcolor="#DDDDDD">$lt{'uplm'}</th> |
&init_breadcrumbs('docslog','Show Log');
|
<th bgcolor="#DDDDDD">$lt{'impp'}</th> |
&docs_change_log($r);
|
<th bgcolor="#DDDDDD">$lt{'spec'}</th> |
} elsif ($allowed && $env{'form.versions'}) {
|
</tr> |
&init_breadcrumbs('versions','Check/Set Resource Versions');
|
<tr><td bgcolor="#DDDDDD"> |
&checkversions($r);
|
$lt{'file'}:<br /> |
} elsif ($allowed && $env{'form.dumpcourse'}) {
|
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
|
<input type="file" name="uploaddoc" size="40"> |
&dumpcourse($r);
|
<br /> |
} elsif ($allowed && $env{'form.exportcourse'}) {
|
$lt{'title'}:<br /> |
&init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
|
<input type="text" size="50" name="comment"> |
&exportcourse($r);
|
$uploadtag |
} else {
|
<input type="hidden" name="cmd" value="upload_default"> |
# is this a standard course?
|
<br /> |
|
<nobr> |
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
|
<label>$lt{'parse'}? |
my $forcestandard = 0;
|
<input type="checkbox" name="parserflag" /> |
my $forcesupplement;
|
</label> |
my $script='';
|
</nobr> |
my $showdoc=0;
|
<br /> |
my $containertag;
|
<br /> |
my $uploadtag;
|
<nobr> |
|
<input type="submit" value="$lt{'upld'}"> |
|
$help{'Uploading_From_Harddrive'} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
</nobr> |
['folderpath','pagepath',
|
</form> |
'pagesymb']);
|
</td> |
# No folderpath, no pagepath, see if we have something stored
|
<td bgcolor="#DDDDDD"> |
if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
|
<form action="/adm/coursedocs" method="post" name="simpleeditdefault"> |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
$lt{'pubd'}<br /> |
{'folderpath' => 'scalar'});
|
$uploadtag |
}
|
<input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}"> |
if (!$env{'form.folderpath'}) {
|
<nobr> |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
<input type=button onClick="javascript:groupimport();" value="$lt{'impo'}"> |
{'pagepath' => 'scalar'});
|
$help{'Importing_LON-CAPA_Resource'} |
}
|
</nobr> |
if ($env{'form.pagepath'}) {
|
<p> |
$env{'form.folderpath'}='';
|
<hr /> |
}
|
$lt{'copm'}<br /> |
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
|
<input type="text" size="40" name="importmap"><br /> |
$env{'form.folderpath'} = 'supplemental&'.
|
<nobr><input type=button |
&escape(&mt('Supplemental '.$type.' Documents')).'&'.
|
onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')" |
$env{'form.folderpath'};
|
value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}"> |
}
|
$help{'Load_Map'}</nobr> |
&Apache::loncommon::store_course_settings('docs_folderpath',
|
</p> |
{'pagepath' => 'scalar',
|
</form> |
'folderpath' => 'scalar'});
|
<hr /> |
if ($env{'form.folderpath'}) {
|
<form action="/adm/groupsort" method="post" name="recover"> |
my (@folderpath)=split('&',$env{'form.folderpath'});
|
<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1)" value="$lt{'reco'}" /> |
$env{'form.foldername'}=&unescape(pop(@folderpath));
|
</form> |
$env{'form.folder'}=pop(@folderpath);
|
ENDFORM |
}
|
unless ($env{'form.pagepath'}) { |
if ($env{'form.pagepath'}) {
|
$r->print(<<ENDFORM); |
my (@pagepath)=split('&',$env{'form.pagepath'});
|
<hr /> |
$env{'form.pagename'}=&unescape(pop(@pagepath));
|
<form action="/adm/coursedocs" method="post" name="newext"> |
$env{'form.folder'}=pop(@pagepath);
|
$uploadtag |
$containertag = '<input type="hidden" name="pagepath" value="" />'.
|
<input type=hidden name="importdetail" value=""> |
'<input type="hidden" name="pagesymb" value="" />';
|
<nobr> |
$uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
|
<input name="newext" type="button" onClick="javascript:makenewext('newext');" |
'<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
|
value="$lt{'extr'}" /> $help{'Adding_External_Resource'} |
}
|
</nobr> |
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
|
</form> |
$showdoc='/'.$1;
|
<form action="/adm/imsimportdocs" method="post" name="ims"> |
}
|
<input type="hidden" name="folder" value="$folder" /> |
unless ($showdoc) { # got called from remote
|
<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" /> |
if (($env{'form.folder'}=~/^(?:group|default)_/) ||
|
</nobr> |
($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
|
</form> |
$forcestandard = 1;
|
ENDFORM |
}
|
} |
$forcesupplement=($env{'form.folder'}=~/^supplemental_/);
|
$r->print('</td><td bgcolor="#DDDDDD">'); |
|
unless ($env{'form.pagepath'}) { |
if ($allowed) {
|
$r->print(<<ENDFORM); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
|
<form action="/adm/coursedocs" method="post" name="newfolder"> |
$script=&Apache::lonratedt::editscript('simple');
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
}
|
<input type=hidden name="importdetail" value=""> |
} else { # got called in sequence from course
|
<nobr> |
$allowed=0;
|
<input name="newfolder" type="button" |
}
|
onClick="javascript:makenewfolder(this.form,'$folderseq');" |
|
value="$lt{'newf'}" />$help{'Adding_Folders'} |
# get course data
|
</nobr> |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
|
</form> |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
<form action="/adm/coursedocs" method="post" name="newpage"> |
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
# get personal data
|
<input type=hidden name="importdetail" value=""> |
my $uname=$env{'user.name'};
|
<nobr> |
my $udom=$env{'user.domain'};
|
<input name="newpage" type="button" |
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
|
onClick="javascript:makenewpage(this.form,'$pageseq');" |
|
value="$lt{'newp'}" />$help{'Adding_Pages'} |
# graphics settings
|
</nobr> |
|
</form> |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
|
<form action="/adm/coursedocs" method="post" name="newsyl"> |
|
$uploadtag |
if ($allowed) {
|
<input type=hidden name="importdetail" |
$script .= &editing_js($udom,$uname);
|
value="Syllabus=/public/$coursedom/$coursenum/syllabus"> |
}
|
<nobr> |
# -------------------------------------------------------------------- Body tag
|
<input name="newsyl" type="submit" value="$lt{'syll'}" /> |
$script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
|
$help{'Syllabus'} |
my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}];
|
</nobr> |
$r->print(&Apache::loncommon::start_page("$type Documents", $script,
|
</form> |
{'force_register' => $showdoc,
|
<form action="/adm/coursedocs" method="post" name="newnav"> |
'bread_crumbs' => $brcrum}).
|
$uploadtag |
&Apache::loncommon::help_open_menu('','',273,'RAT'));
|
<input type=hidden name="importdetail" |
|
value="Navigate Content=/adm/navmaps"> |
my %allfiles = ();
|
<nobr> |
my %codebase = ();
|
<input name="newnav" type="submit" value="$lt{'navc'}" /> |
my ($upload_result,$upload_output);
|
$help{'Navigate_Content'} |
if ($allowed) {
|
</nobr> |
if (($env{'form.uploaddoc.filename'}) &&
|
</form> |
($env{'form.cmd'}=~/^upload_(\w+)/)) {
|
<form action="/adm/coursedocs" method="post" name="newsmppg"> |
# Process file upload - phase one - upload and parse primary file.
|
$uploadtag |
undef($hadchanges);
|
<input type=hidden name="importdetail" value=""> |
$upload_result = &process_file_upload(\$upload_output,$coursenum,
|
<nobr> |
$coursedom,\%allfiles,
|
<input name="newsmppg" type="button" value="$lt{'sipa'}" |
\%codebase,$1);
|
onClick="javascript:makesmppage();" /> $help{'Simple Page'} |
if ($hadchanges) {
|
</nobr> |
&mark_hash_old();
|
</form> |
}
|
<form action="/adm/coursedocs" method="post" name="newsmpproblem"> |
if ($upload_result eq 'phasetwo') {
|
$uploadtag |
$r->print($upload_output);
|
<input type=hidden name="importdetail" value=""> |
}
|
<nobr> |
} elsif ($env{'form.phasetwo'}) {
|
<input name="newsmpproblem" type="button" value="$lt{'sipr'}" |
my %newname = ();
|
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'} |
my %origname = ();
|
</nobr> |
my %attribs = ();
|
</form> |
my $updateflag = 0;
|
<form action="/adm/coursedocs" method="post" name="newexamupload"> |
my $residx = $env{'form.newidx'};
|
$uploadtag |
my $primary_url = &unescape($env{'form.primaryurl'});
|
<input type=hidden name="importdetail" value=""> |
# Process file upload - phase two - gather secondary files.
|
<nobr> |
for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
|
<input name="newexamupload" type="button" value="$lt{'scuf'}" |
if ($env{'form.embedded_item_'.$i.'.filename'}) {
|
onClick="javascript:makeexamupload();" /> |
my $javacodebase;
|
$help{'Score_Upload_Form'} |
$newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
|
</nobr> |
$origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
|
</form> |
if (exists($env{'form.embedded_codebase_'.$i})) {
|
<form action="/adm/coursedocs" method="post" name="newbul"> |
$javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
|
$uploadtag |
$origname{$i} =~ s#^\Q$javacodebase\E/##;
|
<input type=hidden name="importdetail" value=""> |
}
|
<nobr> |
my @attributes = ();
|
<input name="newbulletin" type="button" value="$lt{'bull'}" |
if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
|
onClick="javascript:makebulboard();" /> |
@attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
|
$help{'Bulletin Board'} |
} else {
|
</nobr> |
@attributes = ($env{'form.embedded_attrib_'.$i});
|
</form> |
}
|
<form action="/adm/coursedocs" method="post" name="newaboutme"> |
foreach my $attr (@attributes) {
|
$uploadtag |
push(@{$attribs{$i}},&unescape($attr));
|
<input type=hidden name="importdetail" |
}
|
value="$plainname=/adm/$udom/$uname/aboutme"> |
if ($javacodebase) {
|
<nobr> |
$codebase{$i} = $javacodebase;
|
<input name="newaboutme" type="submit" value="$lt{'mypi'}" /> |
$codebase{$i} =~ s#/$##;
|
$help{'My Personal Info'} |
$updateflag = 1;
|
</nobr> |
}
|
</form> |
}
|
<form action="/adm/coursedocs" method="post" name="newaboutsomeone"> |
unless ($newname{$i} eq $origname{$i}) {
|
$uploadtag |
$updateflag = 1;
|
<input type=hidden name="importdetail" value=""> |
}
|
<nobr> |
}
|
<input name="newaboutsomeone" type="button" value="$lt{'abou'}" |
# Process file upload - phase three - modify primary file
|
onClick="javascript:makeabout();" /> |
if ($updateflag) {
|
</nobr> |
my ($content,$rtncode);
|
</form> |
my $updateflag = 0;
|
ENDFORM |
my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
|
} |
if ($getstatus eq 'ok') {
|
if ($env{'form.pagepath'}) { |
foreach my $item (keys(%newname)) {
|
$r->print(<<ENDBLOCK); |
if ($newname{$item} ne $origname{$item}) {
|
<form action="/adm/coursedocs" method="post" name="newsmpproblem"> |
my $attrib_regexp = '';
|
$uploadtag |
if (@{$attribs{$item}} > 1) {
|
<input type=hidden name="importdetail" value=""> |
$attrib_regexp = join('|',@{$attribs{$item}});
|
<nobr> |
} else {
|
<input name="newsmpproblem" type="button" value="$lt{'sipr'}" |
$attrib_regexp = $attribs{$item}[0];
|
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'} |
}
|
</nobr> |
if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
|
</form> |
}
|
<form action="/adm/coursedocs" method="post" name="newexamupload"> |
$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
|
$uploadtag |
}
|
<input type=hidden name="importdetail" value=""> |
if (exists($codebase{$item})) {
|
<nobr> |
$content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
|
<input name="newexamupload" type="button" value="$lt{'scuf'}" |
}
|
onClick="javascript:makeexamupload();" /> |
}
|
$help{'Score_Upload_Form'} |
# Save edited file.
|
</nobr> |
my $saveresult;
|
</form> |
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
|
ENDBLOCK |
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
} |
my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
|
$r->print('</td></tr>'."\n". |
} else {
|
'</table>'); |
&Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);
|
$r->print('</td></tr>'); |
}
|
} |
}
|
# ----------------------------------------------------- Supplemental documents |
}
|
if (!$forcestandard) { |
}
|
$r->print('<tr><td bgcolor="#BBBBBB">'); |
|
# '<h2>'.&mt('Supplemental Course Documents'). |
unless ($showdoc || $upload_result eq 'phasetwo') {
|
# ($allowed?' '.$help{'Supplemental'}:'').'</h2>'); |
# -----------------------------------------------------------------------------
|
my $folder=$env{'form.folder'}; |
my %lt=&Apache::lonlocal::texthash(
|
unless ($folder=~/^supplemental/) { |
'uplm' => 'Upload a new main '.lc($type).' document',
|
$folder='supplemental'; |
'upls' => 'Upload a new supplemental '.lc($type).' document',
|
} |
'impp' => 'Import a document',
|
if ($folder =~ /^supplemental$/ && |
'pubd' => 'Published Documents',
|
$env{'form.folderpath'} =~ /^default\&/) { |
'copm' => 'All documents out of a published map into this folder',
|
$env{'form.folderpath'}='supplemental&'. |
'upld' => 'Upload Document',
|
&Apache::lonnet::escape(&mt('Supplemental Course Documents')); |
'srch' => 'Search',
|
} |
'impo' => 'Import',
|
&editor($r,$coursenum,$coursedom,$folder,$allowed); |
'book' => 'Import Bookmarks',
|
if ($allowed) { |
'selm' => 'Select Map',
|
my $folderseq= |
'load' => 'Load Map',
|
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. |
'reco' => 'Recover Deleted Resources',
|
'.sequence'; |
'newf' => 'New Folder',
|
|
'newp' => 'New Composite Page',
|
$r->print(<<ENDSUPFORM); |
'extr' => 'External Resource',
|
<table cellspacing=4 cellpadding=4><tr> |
'syll' => 'Syllabus',
|
<th bgcolor="#DDDDDD">$lt{'upls'}</th> |
'navc' => 'Navigate Contents',
|
<th bgcolor="#DDDDDD">$lt{'spec'}</th> |
'sipa' => 'Simple Page',
|
</tr> |
'sipr' => 'Simple Problem',
|
<tr><td bgcolor="#DDDDDD"> |
'drbx' => 'Drop Box',
|
<form action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
'scuf' => 'Score Upload Form',
|
<input type="file" name="uploaddoc" size="40"> |
'bull' => 'Bulletin Board',
|
<br /> |
'mypi' => 'My Personal Info',
|
<br /> |
'grpo' => 'Group Files',
|
<nobr> |
'rost' => 'Course Roster',
|
<label>$lt{'parse'}? |
'abou' => 'About User',
|
<input type="checkbox" name="parserflag" /> |
'imsf' => 'Import IMS package',
|
</label> |
'file' => 'File',
|
</nobr> |
'title' => 'Title',
|
<br /><br /> |
'comment' => 'Comment',
|
$lt{'comment'}:<br /> |
'parse' => 'Upload embedded images/multimedia files if HTML file!',
|
<textarea cols=50 rows=4 name='comment'> |
'nd' => 'New Document',
|
</textarea> |
'pm' => 'Published Map',
|
<br /> |
'sd' => 'Special Document',
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
'mo' => 'More Options',
|
<input type="hidden" name="cmd" value="upload_supplemental"> |
'hao' => 'Hide all Options'
|
<nobr> |
);
|
<input type="submit" value="$lt{'upld'}"> |
# -----------------------------------------------------------------------------
|
$help{'Uploading_From_Harddrive'} |
my $fileupload=(<<FIUP);
|
</nobr> |
$lt{'file'}:<br />
|
</form> |
<input type="file" name="uploaddoc" size="40" />
|
</td> |
FIUP
|
<td bgcolor="#DDDDDD"> |
|
<form action="/adm/coursedocs" method="post" name="supnewfolder"> |
my $checkbox=(<<CHBO);
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
<!-- <label>$lt{'parse'}?
|
<input type=hidden name="importdetail" value=""> |
<input type="checkbox" name="parserflag" />
|
<nobr> |
</label> -->
|
<input name="newfolder" type="button" |
<label>
|
onClick="javascript:makenewfolder(this.form,'$folderseq');" |
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
|
value="$lt{'newf'}" /> $help{'Adding_Folders'} |
</label>
|
</nobr> |
CHBO
|
</form> |
|
<form action="/adm/coursedocs" method="post" name="supnewext"> |
my $fileuploadform=(<<FUFORM);
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
<input type=hidden name="importdetail" value=""> |
$fileupload
|
<nobr> |
<br />
|
<input name="newext" type="button" |
$lt{'title'}:<br />
|
onClick="javascript:makenewext('supnewext');" |
<input type="text" size="50" name="comment" />
|
value="$lt{'extr'}" /> $help{'Adding_External_Resource'} |
$uploadtag
|
</nobr> |
<input type="hidden" name="cmd" value="upload_default" />
|
</form> |
<br />
|
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
<span class="LC_nobreak">
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
$checkbox
|
<input type=hidden name="importdetail" |
</span>
|
value="Syllabus=/public/$coursedom/$coursenum/syllabus"> |
<br />
|
<nobr> |
<br />
|
<input name="newsyl" type="submit" value="$lt{'syll'}" /> |
<span class="LC_nobreak">
|
$help{'Syllabus'} |
<input type="submit" value="$lt{'upld'}" />
|
</nobr> |
$help{'Uploading_From_Harddrive'}
|
</form> |
</span>
|
<form action="/adm/coursedocs" method="post" name="subnewaboutme"> |
</form>
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
FUFORM
|
<input type=hidden name="importdetail" |
|
value="$plainname=/adm/$udom/$uname/aboutme"> |
my $simpleeditdefaultform=(<<SEDFFORM);
|
<nobr> |
<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
|
<input name="newaboutme" type="submit" value="$lt{'mypi'}" /> |
$lt{'pubd'}<br />
|
$help{'My Personal Info'} |
$uploadtag
|
</nobr> |
<input type="button" onClick="javascript:groupsearch()" value="$lt{'srch'}" />
|
</form> |
<br />
|
</td></tr> |
<span class="LC_nobreak">
|
</table></td></tr> |
<input type="button" onClick="javascript:groupimport();" value="$lt{'impo'}" />
|
ENDSUPFORM |
$help{'Importing_LON-CAPA_Resource'}
|
} |
</span>
|
} |
<br />
|
if ($allowed) { |
<input type="button" onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
|
$r->print('<form method="POST" name="extimport" action="/adm/coursedocs"><input type="hidden" name="title" /><input type="hidden" name="url" /><input type="hidden" name="useform" /></form>'); |
<hr />
|
} |
<p>
|
$r->print('</table>'); |
$lt{'copm'}<br />
|
} else { |
<input type="text" size="40" name="importmap" /><br />
|
unless ($upload_result eq 'phasetwo') { |
<span class="LC_nobreak"><input type="button"
|
# -------------------------------------------------------- This is showdoc mode |
onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
|
$r->print("<h1>".&mt('Uploaded Document').' - '. |
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
|
&Apache::lonnet::gettitle($r->uri).'</h1><p>'. |
$help{'Load_Map'}</span>
|
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>". |
</p>
|
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>'); |
</form>
|
} |
SEDFFORM
|
} |
|
} |
my $extresourcesform=(<<ERFORM);
|
$r->print('</body></html>'); |
<form action="/adm/coursedocs" method="post" name="newext">
|
return OK; |
$uploadtag
|
} |
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
1; |
<input name="newext" type="button" onClick="javascript:makenewext('newext');"
|
__END__ |
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
|
</span>
|
|
</form>
|
|
ERFORM
|
|
|
|
if ($allowed) {
|
|
&update_paste_buffer($coursenum,$coursedom);
|
|
my %lt=&Apache::lonlocal::texthash(
|
|
'vc' => 'Verify Content',
|
|
'cv' => 'Check/Set Resource Versions',
|
|
'ls' => 'List Symbs',
|
|
'sl' => 'Show Log'
|
|
);
|
|
|
|
my $folderpath=$env{'form.folderpath'};
|
|
if (!$folderpath) {
|
|
if ($env{'form.folder'} eq '' ||
|
|
$env{'form.folder'} eq 'supplemental') {
|
|
$folderpath='default&'.
|
|
&escape(&mt('Main '.$type.' Documents'));
|
|
}
|
|
}
|
|
unless ($env{'form.pagepath'}) {
|
|
$containertag = '<input type="hidden" name="folderpath" value="" />';
|
|
$uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
|
|
}
|
|
$r->print(&generate_admin_options($containertag,$uploadtag,\%lt,\%help,\%env));
|
|
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
|
|
&mt('Editing the Table of Contents for your '.$type)));
|
|
}
|
|
# --------------------------------------------------------- Standard documents
|
|
$r->print('<table class="LC_docs_documents">');
|
|
|
|
if (($standard) && ($allowed) && (!$forcesupplement)) {
|
|
$r->print('<tr><td class="LC_docs_document">');
|
|
# '<h2>'.&mt('Main Course Documents').
|
|
# ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
|
|
my $folder=$env{'form.folder'};
|
|
if ($folder eq '' || $folder eq 'supplemental') {
|
|
$folder='default';
|
|
$env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
|
|
$uploadtag = '<input type="hidden" name="folderpath" value="'.
|
|
&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
|
|
}
|
|
my $postexec='';
|
|
if ($folder eq 'default') {
|
|
$r->print('<script type="text/javascript">this.window.name="loncapaclient";</script>');
|
|
} else {
|
|
#$postexec='self.close();';
|
|
}
|
|
$hadchanges=0;
|
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
|
|
$upload_output,$type);
|
|
if ($error) {
|
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
|
}
|
|
if ($hadchanges) {
|
|
&mark_hash_old();
|
|
}
|
|
&changewarning($r,$postexec);
|
|
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
|
'.sequence';
|
|
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
|
'.page';
|
|
my $container='sequence';
|
|
if ($env{'form.pagepath'}) {
|
|
$container='page';
|
|
}
|
|
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
|
|
|
|
|
|
|
|
my $recoverform=(<<RFORM);
|
|
<form action="/adm/groupsort" method="post" name="recover">
|
|
<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
|
|
</form>
|
|
RFORM
|
|
|
|
my $imspform=(<<IMSPFORM);
|
|
<form action="/adm/imsimportdocs" method="post" name="ims">
|
|
<input type="hidden" name="folder" value="$folder" />
|
|
<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
|
|
</form>
|
|
IMSPFORM
|
|
|
|
my $newnavform=(<<NNFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newnav">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail"
|
|
value="$lt{'navc'}=/adm/navmaps" />
|
|
<span class="LC_nobreak">
|
|
<input name="newnav" type="submit" value="$lt{'navc'}" />
|
|
$help{'Navigate_Content'}
|
|
</span>
|
|
</form>
|
|
NNFORM
|
|
my $newsmppageform=(<<NSPFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newsmppg">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newsmppg" type="button" value="$lt{'sipa'}"
|
|
onClick="javascript:makesmppage();" /> $help{'Simple Page'}
|
|
</span>
|
|
</form>
|
|
NSPFORM
|
|
|
|
my $newsmpproblemform=(<<NSPROBFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newsmpproblem">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newsmpproblem" type="button" value="$lt{'sipr'}"
|
|
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
|
|
</span>
|
|
</form>
|
|
|
|
NSPROBFORM
|
|
|
|
my $newdropboxform=(<<NDBFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newdropbox">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newdropbox" type="button" value="$lt{'drbx'}"
|
|
onClick="javascript:makedropbox();" />
|
|
</span>
|
|
</form>
|
|
NDBFORM
|
|
|
|
my $newexuploadform=(<<NEXUFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newexamupload">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newexamupload" type="button" value="$lt{'scuf'}"
|
|
onClick="javascript:makeexamupload();" />
|
|
$help{'Score_Upload_Form'}
|
|
</span>
|
|
</form>
|
|
NEXUFORM
|
|
|
|
my $newbulform=(<<NBFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newbul">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newbulletin" type="button" value="$lt{'bull'}"
|
|
onClick="javascript:makebulboard();" />
|
|
$help{'Bulletin Board'}
|
|
</span>
|
|
</form>
|
|
NBFORM
|
|
|
|
my $newaboutmeform=(<<NAMFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newaboutme">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail"
|
|
value="$plainname=/adm/$udom/$uname/aboutme" />
|
|
<span class="LC_nobreak">
|
|
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
|
$help{'My Personal Info'}
|
|
</span>
|
|
</form>
|
|
NAMFORM
|
|
|
|
my $newaboutsomeoneform=(<<NASOFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newaboutsomeone">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newaboutsomeone" type="button" value="$lt{'abou'}"
|
|
onClick="javascript:makeabout();" />
|
|
</span>
|
|
</form>
|
|
NASOFORM
|
|
|
|
|
|
my $newrosterform=(<<NROSTFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newroster">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail"
|
|
value="$lt{'rost'}=/adm/viewclasslist" />
|
|
<span class="LC_nobreak">
|
|
<input name="newroster" type="submit" value="$lt{'rost'}" />
|
|
$help{'Course Roster'}
|
|
</span>
|
|
</form>
|
|
NROSTFORM
|
|
|
|
$r->print(<<ENDFORM);
|
|
|
|
<ul class="LC_TabContent">
|
|
<li>$lt{'nd'}</li>
|
|
<li>$lt{'pm'}</li>
|
|
<li>$lt{'pubd'}</li>
|
|
<li>$lt{'sd'}</li>
|
|
<li>$lt{'mo'}</li>
|
|
<li>$lt{'hao'}</li>
|
|
</ul>
|
|
|
|
<table class="LC_docs_adddocs">
|
|
<!-- <tr>
|
|
<th>$lt{'uplm'}</th>
|
|
<th>$lt{'impp'}</th>
|
|
<th>$lt{'spec'}</th>
|
|
</tr> -->
|
|
<tr>
|
|
<td>
|
|
$fileuploadform
|
|
</td>
|
|
<td>
|
|
$simpleeditdefaultform
|
|
<hr />
|
|
$recoverform
|
|
ENDFORM
|
|
unless ($env{'form.pagepath'}) {
|
|
$r->print(<<ENDFORM);
|
|
<hr />
|
|
$extresourcesform
|
|
<br />
|
|
$imspform
|
|
ENDFORM
|
|
}
|
|
$r->print('</td><td>');
|
|
unless ($env{'form.pagepath'}) {
|
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
|
|
|
|
|
|
|
my $newpageform=(<<NPFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newpage">
|
|
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newpage" type="button"
|
|
onClick="javascript:makenewpage(this.form,'$pageseq');"
|
|
value="$lt{'newp'}" />$help{'Adding_Pages'}
|
|
</span>
|
|
</form>
|
|
NPFORM
|
|
|
|
my $newfolderform=(<<NFFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newfolder">
|
|
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newfolder" type="button"
|
|
onClick="javascript:makenewfolder(this.form,'$folderseq');"
|
|
value="$lt{'newf'}" />$help{'Adding_Folders'}
|
|
</span>
|
|
</form>
|
|
NFFORM
|
|
|
|
my $newsylform=(<<NSYLFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newsyl">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail"
|
|
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
|
|
<span class="LC_nobreak">
|
|
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
|
$help{'Syllabus'}
|
|
</span>
|
|
</form>
|
|
NSYLFORM
|
|
|
|
my $newgroupfileform=(<<NGFFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newgroupfiles">
|
|
$uploadtag
|
|
<input type="hidden" name="importdetail"
|
|
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
|
|
<span class="LC_nobreak">
|
|
<input name="newgroupfiles" type="submit" value="$lt{'grpo'}" />
|
|
$help{'Group Files'}
|
|
</span>
|
|
</form>
|
|
NGFFORM
|
|
|
|
|
|
$r->print(<<ENDFORM);
|
|
<br />
|
|
$newfolderform
|
|
<br />
|
|
$newpageform
|
|
<br />
|
|
$newsylform
|
|
<br />
|
|
$newnavform
|
|
<br />
|
|
$newsmppageform
|
|
<br />
|
|
$newsmpproblemform
|
|
<br />
|
|
$newdropboxform
|
|
<br />
|
|
$newexuploadform
|
|
<br />
|
|
$newbulform
|
|
<br />
|
|
$newaboutmeform
|
|
<br />
|
|
$newaboutsomeoneform
|
|
<br />
|
|
$newgroupfileform
|
|
<br />
|
|
$newrosterform
|
|
ENDFORM
|
|
}
|
|
if ($env{'form.pagepath'}) {
|
|
$r->print(<<ENDBLOCK);
|
|
$newsmpproblemform
|
|
<br />
|
|
$newexuploadform
|
|
ENDBLOCK
|
|
}
|
|
$r->print('</td></tr>'."\n".
|
|
'</table>');
|
|
$r->print('</td></tr>');
|
|
}
|
|
# ----------------------------------------------------- Supplemental documents
|
|
if (!$forcestandard) {
|
|
$r->print('<tr><td class="LC_docs_document">');
|
|
# '<h2>'.&mt('Supplemental Course Documents').
|
|
# ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
|
|
my $folder=$env{'form.folder'};
|
|
unless ($folder=~/^supplemental/) {
|
|
$folder='supplemental';
|
|
}
|
|
if ($folder =~ /^supplemental$/ &&
|
|
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
|
|
$env{'form.folderpath'} = 'supplemental&'.
|
|
&escape(&mt('Supplemental '.$type.' Documents'));
|
|
}
|
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
|
|
if ($error) {
|
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
|
}
|
|
if ($allowed) {
|
|
my $folderseq=
|
|
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
|
|
'.sequence';
|
|
|
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
|
|
|
my $supupdocform=(<<SUPDOCFORM);
|
|
<form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
|
$fileupload
|
|
<br />
|
|
<br />
|
|
<span class="LC_nobreak">
|
|
$checkbox
|
|
</span>
|
|
<br /><br />
|
|
$lt{'comment'}:<br />
|
|
<textarea cols=50 rows=4 name='comment'>
|
|
</textarea>
|
|
<br />
|
|
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="cmd" value="upload_supplemental" />
|
|
<span class="LC_nobreak">
|
|
<input type="submit" value="$lt{'upld'}" />
|
|
$help{'Uploading_From_Harddrive'}
|
|
</span>
|
|
</form>
|
|
SUPDOCFORM
|
|
|
|
my $supnewfolderform=(<<SNFFORM);
|
|
<form action="/adm/coursedocs" method="post" name="supnewfolder">
|
|
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newfolder" type="button"
|
|
onClick="javascript:makenewfolder(this.form,'$folderseq');"
|
|
value="$lt{'newf'}" /> $help{'Adding_Folders'}
|
|
</span>
|
|
</form>
|
|
SNFFORM
|
|
|
|
|
|
my $supnewextform=(<<SNEFORM);
|
|
<form action="/adm/coursedocs" method="post" name="supnewext">
|
|
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newext" type="button"
|
|
onClick="javascript:makenewext('supnewext');"
|
|
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
|
</span>
|
|
</form>
|
|
SNEFORM
|
|
|
|
my $supnewsylform=(<<SNSFORM);
|
|
<form action="/adm/coursedocs" method="post" name="supnewsyl">
|
|
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="importdetail"
|
|
value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
|
|
<span class="LC_nobreak">
|
|
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
|
$help{'Syllabus'}
|
|
</span>
|
|
</form>
|
|
SNSFORM
|
|
|
|
my $supnewaboutmeform=(<<SNAMFORM);
|
|
<form action="/adm/coursedocs" method="post" name="subnewaboutme">
|
|
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="importdetail"
|
|
value="$plainname=/adm/$udom/$uname/aboutme" />
|
|
<span class="LC_nobreak">
|
|
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
|
$help{'My Personal Info'}
|
|
</span>
|
|
</form>
|
|
SNAMFORM
|
|
|
|
$r->print(<<ENDSUPFORM);
|
|
<ul class="LC_TabContent">
|
|
<li>$lt{'nd'}</li>
|
|
<li>$lt{'sd'}</li>
|
|
<li>$lt{'hao'}</li>
|
|
</ul>
|
|
<table class="LC_docs_adddocs">
|
|
<tr><td>
|
|
$supupdocform
|
|
</td>
|
|
<td>
|
|
$supnewfolderform
|
|
<br />
|
|
$supnewextform
|
|
<br />
|
|
$supnewsylform
|
|
<br />
|
|
$supnewaboutmeform
|
|
</td></tr>
|
|
</table></td></tr>
|
|
ENDSUPFORM
|
|
}
|
|
}
|
|
$r->print('</table>');
|
|
if ($allowed) {
|
|
$r->print('
|
|
<form method="post" name="extimport" action="/adm/coursedocs">
|
|
<input type="hidden" name="title" />
|
|
<input type="hidden" name="url" />
|
|
<input type="hidden" name="useform" />
|
|
<input type="hidden" name="residx" />
|
|
</form>');
|
|
}
|
|
} else {
|
|
unless ($upload_result eq 'phasetwo') {
|
|
# -------------------------------------------------------- This is showdoc mode
|
|
$r->print("<h1>".&mt('Uploaded Document').' - '.
|
|
&Apache::lonnet::gettitle($r->uri).'</h1><p>'.
|
|
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
|
|
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
|
|
}
|
|
}
|
|
}
|
|
$r->print(&Apache::loncommon::end_page());
|
|
return OK;
|
|
}
|
|
|
|
sub generate_admin_options {
|
|
my ($containertag,$uploadtag,$lt_ref,$help_ref,$env_ref) = @_;
|
|
my %lt = %{$lt_ref};
|
|
my %help = %{$help_ref};
|
|
my %env = %{$env_ref};
|
|
my $dumpbut=&dumpbutton();
|
|
my $exportbut=&exportbutton();
|
|
return (<<ENDOPTIONFORM);
|
|
<form name="renameform" method="post" action="/adm/coursedocs">
|
|
<input type="hidden" name="title" />
|
|
<input type="hidden" name="cmd" />
|
|
<input type="hidden" name="markcopy" />
|
|
<input type="hidden" name="copyfolder" />
|
|
$containertag
|
|
</form>
|
|
<form name="simpleedit" method="post" action="/adm/coursedocs">
|
|
<input type="hidden" name="importdetail" value="" />
|
|
$uploadtag
|
|
</form>
|
|
<form action="/adm/coursedocs" method="post" name="courseverify">
|
|
<ul style="list-style-type:none">
|
|
<li>
|
|
<input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
|
|
</li>
|
|
<li>
|
|
<input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
|
|
</li>
|
|
<li>
|
|
$dumpbut
|
|
</li>
|
|
<li>
|
|
$exportbut
|
|
</li>
|
|
<li>
|
|
<input type="submit" name="listsymbs" value="$lt{'ls'}" />
|
|
</li>
|
|
<li>
|
|
<input type="hidden" name="folder" value="$env{'form.folder'}" />
|
|
<input type="submit" name="docslog" value="$lt{'sl'}" />
|
|
</li>
|
|
</ul>
|
|
</form>
|
|
<div style="clear: both; height: 0px;"> </div>
|
|
ENDOPTIONFORM
|
|
}
|
|
|
|
sub generate_edit_table {
|
|
my ($optionhash_ref,$namehash_ref,$orderhash_ref) = @_;
|
|
my %optionhash = %{$optionhash_ref}; #id verlinkt mit inhalt
|
|
my %namehash = %{$namehash_ref}; #name verlinkt mit id
|
|
my %orderhash = %{$orderhash_ref}; #name mit kürzel verlinkt mit name
|
|
my $form;
|
|
$form = '<div class="LC_ContentBoxSpecial"><h4 class="LC_hcell">'.&mt('Upload Course Documents').'<h4>';
|
|
$form .= '<ul class="LC_TabContent">';
|
|
foreach my $name (sort(keys(%orderhash))){
|
|
if($name eq 'zz_hide'){
|
|
$form .= '<li><a onclick="hideAllSection();" href="#">'.&mt($orderhash{$name}).'</a></li>';
|
|
}else{
|
|
$form .= '<li><a onclick="popUpSection(\''.$namehash{$orderhash{$name}}.'\');" href="#">'.&mt($orderhash{$name}).'</a></li>';
|
|
}
|
|
}
|
|
foreach my $field (keys(%optionhash)){
|
|
$form .= '<div id="'.$field.'" class="LC_ContentBox LC_hideThis">'.$optionhash{$field}.'</div>';
|
|
}
|
|
$form .= '</div>';
|
|
return $form;
|
|
}
|
|
|
|
sub editing_js {
|
|
my ($udom,$uname) = @_;
|
|
my $now = time();
|
|
my %lt = &Apache::lonlocal::texthash(
|
|
p_mnf => 'Name of New Folder',
|
|
t_mnf => 'New Folder',
|
|
p_mnp => 'Name of New Page',
|
|
t_mnp => 'New Page',
|
|
p_mxu => 'Title for the Uploaded Score',
|
|
p_msp => 'Title for the Page',
|
|
p_msb => 'Title for the Problem',
|
|
p_mdb => 'Title for the Drop Box',
|
|
p_mbb => 'Title for the Bulletin Board',
|
|
p_mab => "Enter user:domain for User's 'About Me' Page",
|
|
p_mab2 => "About [_99]",
|
|
p_mab_alrt1 => 'Not a valid user:domain',
|
|
p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
|
|
p_chn => 'New Title',
|
|
p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
|
|
p_rmr2a => 'Remove[_99]',
|
|
p_rmr2b => '?[_99]',
|
|
p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
|
|
p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
|
|
p_ctr2a => 'Cut[_98]',
|
|
p_ctr2b => '?[_98]'
|
|
);
|
|
|
|
return <<ENDNEWSCRIPT;
|
|
function makenewfolder(targetform,folderseq) {
|
|
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
|
|
if (foldername) {
|
|
targetform.importdetail.value=escape(foldername)+"="+folderseq;
|
|
targetform.submit();
|
|
}
|
|
}
|
|
|
|
function makenewpage(targetform,folderseq) {
|
|
var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
|
|
if (pagename) {
|
|
targetform.importdetail.value=escape(pagename)+"="+folderseq;
|
|
targetform.submit();
|
|
}
|
|
}
|
|
|
|
function makenewext(targetname) {
|
|
this.document.forms.extimport.useform.value=targetname;
|
|
this.document.forms.extimport.title.value='';
|
|
this.document.forms.extimport.url.value='';
|
|
this.document.forms.extimport.residx.value='';
|
|
window.open('/adm/rat/extpickframe.html');
|
|
}
|
|
|
|
function edittext(targetname,residx,title,url) {
|
|
this.document.forms.extimport.useform.value=targetname;
|
|
this.document.forms.extimport.residx.value=residx;
|
|
this.document.forms.extimport.url.value=url;
|
|
this.document.forms.extimport.title.value=title;
|
|
window.open('/adm/rat/extpickframe.html');
|
|
}
|
|
|
|
function makeexamupload() {
|
|
var title=prompt('$lt{"p_mxu"}');
|
|
if (title) {
|
|
this.document.forms.newexamupload.importdetail.value=
|
|
escape(title)+'=/res/lib/templates/examupload.problem';
|
|
this.document.forms.newexamupload.submit();
|
|
}
|
|
}
|
|
|
|
function makesmppage() {
|
|
var title=prompt('$lt{"p_msp"}');
|
|
if (title) {
|
|
this.document.forms.newsmppg.importdetail.value=
|
|
escape(title)+'=/adm/$udom/$uname/$now/smppg';
|
|
this.document.forms.newsmppg.submit();
|
|
}
|
|
}
|
|
|
|
function makesmpproblem() {
|
|
var title=prompt('$lt{"p_msb"}');
|
|
if (title) {
|
|
this.document.forms.newsmpproblem.importdetail.value=
|
|
escape(title)+'=/res/lib/templates/simpleproblem.problem';
|
|
this.document.forms.newsmpproblem.submit();
|
|
}
|
|
}
|
|
|
|
function makedropbox() {
|
|
var title=prompt('$lt{"p_mdb"}');
|
|
if (title) {
|
|
this.document.forms.newdropbox.importdetail.value=
|
|
escape(title)+'=/res/lib/templates/DropBox.problem';
|
|
this.document.forms.newdropbox.submit();
|
|
}
|
|
}
|
|
|
|
function makebulboard() {
|
|
var title=prompt('$lt{"p_mbb"}');
|
|
if (title) {
|
|
this.document.forms.newbul.importdetail.value=
|
|
escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
|
|
this.document.forms.newbul.submit();
|
|
}
|
|
}
|
|
|
|
function makeabout() {
|
|
var user=prompt("$lt{'p_mab'}");
|
|
if (user) {
|
|
var comp=new Array();
|
|
comp=user.split(':');
|
|
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
|
|
if ((comp[0]) && (comp[1])) {
|
|
this.document.forms.newaboutsomeone.importdetail.value=
|
|
'$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
|
|
this.document.forms.newaboutsomeone.submit();
|
|
} else {
|
|
alert("$lt{'p_mab_alrt1'}");
|
|
}
|
|
} else {
|
|
alert("$lt{'p_mab_alrt2'}");
|
|
}
|
|
}
|
|
}
|
|
|
|
function makeims() {
|
|
var caller = document.forms.ims.folder.value;
|
|
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
|
|
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
|
|
newWindow.location.href = newlocation;
|
|
}
|
|
|
|
|
|
function finishpick() {
|
|
var title=this.document.forms.extimport.title.value;
|
|
var url=this.document.forms.extimport.url.value;
|
|
var form=this.document.forms.extimport.useform.value;
|
|
var residx=this.document.forms.extimport.residx.value;
|
|
eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
|
|
}
|
|
|
|
function changename(folderpath,index,oldtitle,container,pagesymb) {
|
|
var title=prompt('$lt{"p_chn"}',oldtitle);
|
|
if (title) {
|
|
this.document.forms.renameform.markcopy.value=-1;
|
|
this.document.forms.renameform.title.value=title;
|
|
this.document.forms.renameform.cmd.value='rename_'+index;
|
|
if (container == 'sequence') {
|
|
this.document.forms.renameform.folderpath.value=folderpath;
|
|
}
|
|
if (container == 'page') {
|
|
this.document.forms.renameform.pagepath.value=folderpath;
|
|
this.document.forms.renameform.pagesymb.value=pagesymb;
|
|
}
|
|
this.document.forms.renameform.submit();
|
|
}
|
|
}
|
|
|
|
function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
|
|
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
|
|
this.document.forms.renameform.markcopy.value=-1;
|
|
this.document.forms.renameform.cmd.value='del_'+index;
|
|
if (container == 'sequence') {
|
|
this.document.forms.renameform.folderpath.value=folderpath;
|
|
}
|
|
if (container == 'page') {
|
|
this.document.forms.renameform.pagepath.value=folderpath;
|
|
this.document.forms.renameform.pagesymb.value=pagesymb;
|
|
}
|
|
this.document.forms.renameform.submit();
|
|
}
|
|
}
|
|
|
|
function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
|
|
if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
|
|
this.document.forms.renameform.cmd.value='cut_'+index;
|
|
this.document.forms.renameform.markcopy.value=index;
|
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container;
|
|
if (container == 'sequence') {
|
|
this.document.forms.renameform.folderpath.value=folderpath;
|
|
}
|
|
if (container == 'page') {
|
|
this.document.forms.renameform.pagepath.value=folderpath;
|
|
this.document.forms.renameform.pagesymb.value=pagesymb;
|
|
}
|
|
this.document.forms.renameform.submit();
|
|
}
|
|
}
|
|
|
|
function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
|
|
this.document.forms.renameform.markcopy.value=index;
|
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container;
|
|
if (container == 'sequence') {
|
|
this.document.forms.renameform.folderpath.value=folderpath;
|
|
}
|
|
if (container == 'page') {
|
|
this.document.forms.renameform.pagepath.value=folderpath;
|
|
this.document.forms.renameform.pagesymb.value=pagesymb;
|
|
}
|
|
this.document.forms.renameform.submit();
|
|
}
|
|
|
|
|
|
ENDNEWSCRIPT
|
|
}
|
|
1;
|
|
__END__
|
|
|
|
|
|
=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
|
|
|
|
=item %help=()
|
|
|
|
Available help topics
|
|
|
|
=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
|
|
|
|
=item authorhosts()
|
|
|
|
Return hash with valid author names
|
|
|
|
=item dumpbutton()
|
|
|
|
Generate "dump" button
|
|
|
|
=item clean()
|
|
|
|
=item dumpcourse()
|
|
|
|
Actually dump course
|
|
|
|
|
|
=item exportbutton()
|
|
|
|
Generate "export" button
|
|
|
|
=item exportcourse()
|
|
|
|
=item create_ims_store()
|
|
|
|
=item build_package()
|
|
|
|
=item get_dependencies()
|
|
|
|
=item process_content()
|
|
|
|
=item replicate_content()
|
|
|
|
=item extract_media()
|
|
|
|
=item store_template()
|
|
|
|
=item group_import()
|
|
|
|
Imports the given (name, url) resources into the course
|
|
coursenum, coursedom, and folder must precede the list
|
|
|
|
=item breadcrumbs()
|
|
|
|
=item log_docs()
|
|
|
|
=item docs_change_log()
|
|
|
|
=item update_paste_buffer()
|
|
|
|
=item print_paste_buffer()
|
|
|
|
=item do_paste_from_buffer()
|
|
|
|
=item update_parameter()
|
|
|
|
=item handle_edit_cmd()
|
|
|
|
=item editor()
|
|
|
|
=item process_file_upload()
|
|
|
|
=item process_secondary_uploads()
|
|
|
|
=item is_supplemental_title()
|
|
|
|
=item parse_supplemental_title()
|
|
|
|
=item entryline()
|
|
|
|
=item tiehash()
|
|
|
|
=item untiehash()
|
|
|
|
=item checkonthis()
|
|
|
|
check on this
|
|
|
|
=item verifycontent()
|
|
|
|
Verify Content
|
|
|
|
=item devalidateversioncache() & checkversions()
|
|
|
|
Check Versions
|
|
|
|
=item mark_hash_old()
|
|
|
|
=item is_hash_old()
|
|
|
|
=item changewarning()
|
|
|
|
=item init_breadcrumbs()
|
|
|
|
Breadcrumbs for special functions
|
|
|
|
=back
|
|
|
|
=cut
|