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