';
+}
+
+
+
+sub exportcourse {
+ my $r=shift;
+ my $crstype = &Apache::loncommon::course_type();
+ 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();
+ if (!defined($navmap)) {
+ $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package').
+ '
'.&mt('IMS Export Failed').'
'.
+ '
');
+ if ($crstype eq 'Community') {
+ $r->print(&mt('Unable to retrieve information about community contents'));
+ } else {
+ $r->print(&mt('Unable to retrieve information about course contents'));
+ }
+ $r->print('
');
+ if ($crstype eq 'Community') {
+ $r->print(&mt('Return to Community Editor'));
+ } else {
+ $r->print(&mt('Return to Course Editor'));
+ }
+ $r->print('');
+ &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
+ return;
+ }
+ my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
+ my $curRes;
+ my $outcome;
+
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['finishexport']);
+ if ($env{'form.finishexport'}) {
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['archive','discussion']);
+
+ my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
+ my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
+ if (@exportitems == 0 && @discussions == 0) {
+ $outcome =
+ '
'
+ .&mt('As you did not select any content items or discussions'
+ .' for export, an IMS package has not been created.')
+ .'
'
+ .'
'
+ .&mt('Please [_1]go back[_2] to select either content items'
+ .' or discussions for export.'
+ ,''
+ ,'')
+ .'
';
+ } else {
+ my $now = time;
+ my %symbs;
+ my $manifestok = 0;
+ my $imsresources;
+ my $tempexport;
+ my $copyresult;
+ my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
+ if ($manifestok) {
+ &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest);
+ close($ims_manifest);
+
+#Create zip file in prtspool
+ my $imszipfile = '/prtspool/'.
+ $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
+ time.'_'.rand(1000000000).'.zip';
+ my $cwd = &Cwd::getcwd();
+ my $imszip = '/home/httpd/'.$imszipfile;
+ chdir $tempexport;
+ open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
+ close(OUTPUT);
+ chdir $cwd;
+ $outcome .= '
'
+ .&mt('[_1]Your IMS package[_2] is ready for download.'
+ ,'','')
+ .'
';
+ if ($copyresult) {
+ $outcome .= '
'
+ .&mt('The following errors occurred during export - [_1]'
+ ,$copyresult)
+ .'
';
+ }
+ } else {
+ $outcome = '
'
+ .&mt('Unfortunately you will not be able to retrieve'
+ .' an IMS archive of this posts at this time,'
+ .' because there was a problem creating a'
+ .' manifest file.')
+ .'
');
+# Before
+ for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
+ my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
+ my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
+ if ($oldname ne $newname) {
+ $r->print(&LONCAPA::map::qtescape($oldname));
+ }
+ }
+ $r->print('
');
+ for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
+ if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
+ $r->print('
'.&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.').'
');
+ }
+ if ($is_random_order) {
+ $r->print('
'.&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.').'
');
}
+ return $phase_status;
+}
+
+sub process_secondary_uploads {
+ my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
+ my $folder=$env{'form.folder'};
+ my $destination = 'docs/';
+ if ($folder =~ /^supplemental/) {
+ $destination = 'supplemental/';
+ }
+ if (($folder eq 'default') || ($folder eq 'supplemental')) {
+ $destination .= 'default/';
+ } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
+ $destination .= $2.'/';
+ }
+ $destination .= $newidx;
+ my ($url,$filename);
+ $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
+ ($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$});
+ return $filename;
+}
+
+sub is_supplemental_title {
+ my ($title) = @_;
+ return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
+}
+
+sub parse_supplemental_title {
+ my ($title) = @_;
+
+ my ($foldertitle,$renametitle);
+ if ($title =~ /&&&/) {
+ $title = &HTML::Entites::decode($title);
+ }
+ if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
+ $renametitle=$4;
+ my ($time,$uname,$udom) = ($1,$2,$3);
+ $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
+ my $name = &Apache::loncommon::plainname($uname,$udom);
+ $name = &HTML::Entities::encode($name,'"<>&\'');
+ $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
+ $title=''.&Apache::lonlocal::locallocaltime($time).' '.
+ $name.': '.$foldertitle;
+ }
+ if (wantarray) {
+ return ($title,$foldertitle,$renametitle);
+ }
+ return $title;
}
# --------------------------------------------------------------- An entry line
sub entryline {
- my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
- $title=~s/\&colon\;/\:/g;
- $title=&HTML::Entities::encode(&HTML::Entities::decode(
- &Apache::lonnet::unescape($title)),'"<>&\'');
- my $renametitle=$title;
- my $foldertitle=$title;
- my $orderidx=$Apache::lonratedt::order[$index];
- if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) {
- $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
- $renametitle=$4;
- $title=''.&Apache::lonlocal::locallocaltime($1).' '.
- &Apache::loncommon::plainname($2,$3).': '.
- $foldertitle;
+ my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
+
+ my ($foldertitle,$pagetitle,$renametitle);
+ if (&is_supplemental_title($title)) {
+ ($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
+ $pagetitle = $foldertitle;
+ } else {
+ $title=&HTML::Entities::encode($title,'"<>&\'');
+ $renametitle=$title;
+ $foldertitle=$title;
+ $pagetitle=$title;
}
+
+ my $orderidx=$LONCAPA::map::order[$index];
+
+
+ $renametitle=~s/\\/\\\\/g;
$renametitle=~s/\"\;/\\\"/g;
+ $renametitle=~s/ /%20/g;
my $line='
';
+ my ($form_start,$form_end);
# Edit commands
- my $folderpath;
- if ($ENV{'form.folderpath'}) {
- $folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
- # $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
+ my ($container, $type, $esc_path, $path, $symb);
+ if ($env{'form.folderpath'}) {
+ $type = 'folder';
+ $container = 'sequence';
+ $esc_path=&escape($env{'form.folderpath'});
+ $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
+ # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
+ }
+ if ($env{'form.pagepath'}) {
+ $type = $container = 'page';
+ $esc_path=&escape($path = $env{'form.pagepath'});
+ $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
+ $symb=&escape($env{'form.pagesymb'});
}
+ my $cpinfo='';
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
- if ($folder!~/^supplemental/) {
+ if (($folder!~/^supplemental/) &&
+ ($#LONCAPA::map::order>0) &&
+ ((split(/\:/,
+ $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
+ ne '') &&
+ ((split(/\:/,
+ $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
+ ne '')) {
$selectbox=
''.
'
";
+ $line.="";
return $line;
}
-# ---------------------------------------------------------------- tie the hash
+=pod
+
+=item tiehash()
+
+tie the hash
+
+=cut
sub tiehash {
my ($mode)=@_;
$hashtied=0;
- if ($ENV{'request.course.fn'}) {
+ if ($env{'request.course.fn'}) {
if ($mode eq 'write') {
- if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
+ if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
&GDBM_WRCREAT(),0640)) {
$hashtied=2;
}
} else {
- if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
+ if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
&GDBM_READER(),0640)) {
$hashtied=1;
}
@@ -671,16 +2106,22 @@ sub tiehash {
sub untiehash {
if ($hashtied) { untie %hash; }
$hashtied=0;
+ return OK;
}
-# --------------------------------------------------------------- check on this
+
+
sub checkonthis {
my ($r,$url,$level,$title)=@_;
+ $url=&unescape($url);
$alreadyseen{$url}=1;
$r->rflush();
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
$r->print("\n ");
+ if ($level==0) {
+ $r->print(" ");
+ }
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
@@ -689,8 +2130,8 @@ sub checkonthis {
if ($url=~/^\/res\//) {
my $result=&Apache::lonnet::repcopy(
&Apache::lonnet::filelocation('',$url));
- if ($result==OK) {
- $r->print(''.&mt('ok').'');
+ if ($result eq 'ok') {
+ $r->print(''.&mt('ok').'');
$r->rflush();
&Apache::lonnet::countacc($url);
$url=~/\.(\w+)$/;
@@ -700,71 +2141,104 @@ sub checkonthis {
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
- $r->print('- '.&mt('Rendering').': ');
- my $oldpath=$ENV{'request.filename'};
- $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
- &Apache::lonxml::xmlparse($r,'web',
- &Apache::lonnet::getfile(
- &Apache::lonnet::filelocation('',$url)));
- undef($Apache::lonhomework::parsing_a_problem);
- $ENV{'request.filename'}=$oldpath;
- if (($Apache::lonxml::errorcount) ||
- ($Apache::lonxml::warningcount)) {
- if ($Apache::lonxml::errorcount) {
- $r->print(''.
- $Apache::lonxml::errorcount.' '.
- &mt('error(s)').' ');
+ $r->print('- '.&mt('Rendering:').' ');
+ my ($errorcount,$warningcount)=split(/:/,
+ &Apache::lonnet::ssi_body($url,
+ ('grade_target'=>'web',
+ 'return_only_error_and_warning_counts' => 1)));
+ if (($errorcount) ||
+ ($warningcount)) {
+ if ($errorcount) {
+ $r->print(''.
+ &mt('[quant,_1,error]',$errorcount).'');
}
- if ($Apache::lonxml::warningcount) {
- $r->print(''.
- $Apache::lonxml::warningcount.' '.
- &mt('warning(s)').'');
+ if ($warningcount) {
+ $r->print(''.
+ &mt('[quant,_1,warning]',$warningcount).'');
}
} else {
- $r->print(''.&mt('ok').'');
+ $r->print(''.&mt('ok').'');
}
$r->rflush();
}
my $dependencies=
&Apache::lonnet::metadata($url,'dependencies');
- foreach (split(/\,/,$dependencies)) {
- if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
- &checkonthis($r,$_,$level+1);
+ foreach my $dep (split(/\,/,$dependencies)) {
+ if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
+ &checkonthis($r,$dep,$level+1);
}
}
- } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
- $r->print(''.&mt('connection down').'');
- } elsif ($result==HTTP_NOT_FOUND) {
+ } elsif ($result eq 'unavailable') {
+ $r->print(''.&mt('connection down').'');
+ } elsif ($result eq 'not_found') {
unless ($url=~/\$/) {
- $r->print(''.&mt('not found').'');
+ $r->print(''.&mt('not found').'');
} else {
- $r->print(''.&mt('unable to verify variable URL').'');
+ $r->print(''.&mt('unable to verify variable URL').'');
}
} else {
- $r->print(''.&mt('access denied').'');
+ $r->print(''.&mt('access denied').'');
}
- }
- }
+ }
+ }
+}
+
+
+
+=pod
+
+=item list_symbs()
+
+List Symbs
+
+=cut
+
+sub list_symbs {
+ my ($r) = @_;
+
+ my $crstype = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page('Symb List'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (!defined($navmap)) {
+ $r->print('
'.&mt('Retrieval of List Failed').'
'.
+ '
'.
+ &mt('Unable to retrieve information about course contents').
+ '
');
+ &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
+ } else {
+ $r->print("
'.&mt('An Error Occured while Attempting to Store your Version Settings').'
');
+ $r->print('
'.&mt('An Error Occured while Attempting to Save your Version Settings').'
');
}
&mark_hash_old();
}
&changewarning($r,'');
- if ($ENV{'form.timerange'} eq 'all') {
+ if ($env{'form.timerange'} eq 'all') {
# show all documents
- $header=&mt('All Documents in Course');
+ $header=&mt('All Documents in '.$crstype);
$allsel=1;
- foreach (keys %hash) {
- if ($_=~/^ids\_(\/res\/.+)$/) {
+ foreach my $key (keys(%hash)) {
+ if ($key=~/^ids\_(\/res\/.+)$/) {
my $src=$1;
$changes{$src}=1;
}
@@ -846,28 +2329,28 @@ sub checkversions {
} else {
# show documents which changed
%changes=&Apache::lonnet::dump
- ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
- my $firstkey=(keys %changes)[0];
+ ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ my $firstkey=(keys(%changes))[0];
unless ($firstkey=~/^error\:/) {
- unless ($ENV{'form.timerange'}) {
- $ENV{'form.timerange'}=604800;
+ unless ($env{'form.timerange'}) {
+ $env{'form.timerange'}=604800;
}
- my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
+ my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
.&mt('seconds');
- if ($ENV{'form.timerange'}==-1) {
+ if ($env{'form.timerange'}==-1) {
$seltext='since start of course';
$startsel='selected';
- $ENV{'form.timerange'}=time;
+ $env{'form.timerange'}=time;
}
- $starttime=time-$ENV{'form.timerange'};
- if ($ENV{'form.timerange'}==2592000) {
+ $starttime=time-$env{'form.timerange'};
+ if ($env{'form.timerange'}==2592000) {
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
$monthsel='selected';
- } elsif ($ENV{'form.timerange'}==604800) {
+ } elsif ($env{'form.timerange'}==604800) {
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
$weeksel='selected';
- } elsif ($ENV{'form.timerange'}==86400) {
+ } elsif ($env{'form.timerange'}==86400) {
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
$daysel='selected';
}
@@ -877,10 +2360,10 @@ sub checkversions {
}
}
%setversions=&Apache::lonnet::dump('resourceversions',
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
my %lt=&Apache::lonlocal::texthash
- ('st' => 'Version changes since start of Course',
+ ('st' => 'Version changes since start of '.$crstype,
'lm' => 'Version changes since last Month',
'lw' => 'Version changes since last Week',
'sy' => 'Version changes since Yesterday',
@@ -889,9 +2372,9 @@ sub checkversions {
'fi' => 'File',
'md' => 'Modification Date',
'mr' => 'Most recently published Version',
- 've' => 'Version used in Course',
- 'vu' => 'Set Version to be used in Course',
-'sv' => 'Set Versions to be used in Course according to Selections below',
+ 've' => 'Version used in '.$crstype,
+ 'vu' => 'Set Version to be used in '.$crstype,
+'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
'di' => 'Differences');
@@ -912,14 +2395,14 @@ sub checkversions {
ENDHEADERS
- foreach (sort keys %changes) {
- if ($changes{$_}>$starttime) {
- my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
- my $currentversion=&Apache::lonnet::getversion($_);
+ foreach my $key (sort(keys(%changes))) {
+ if ($changes{$key}>$starttime) {
+ my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
+ my $currentversion=&Apache::lonnet::getversion($key);
if ($currentversion<0) {
$currentversion=&mt('Could not be determined.');
}
- my $linkurl=&Apache::lonnet::clutter($_);
+ my $linkurl=&Apache::lonnet::clutter($key);
$r->print(
'
');
my $lastold=1;
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
my $url=$root.'.'.$prevvers.'.'.$extension;
@@ -981,7 +2464,7 @@ ENDHEADERS
my $cols_output = 1;
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
my $url=$root.'.'.$prevvers.'.'.$extension;
- $r->print(''.&mt('Version').' '.$prevvers.' ('.
&Apache::lonlocal::locallocaltime(
&Apache::lonnet::metadata($url,
@@ -994,7 +2477,7 @@ ENDHEADERS
'&versionone='.$prevvers.
'">'.&mt('Diffs').'');
}
- $r->print(' ');
+ $r->print(' ');
if (++$entries_count % $entries_per_col == 0) {
$r->print('');
if ($cols_output != 4) {
@@ -1039,37 +2522,72 @@ sub is_hash_old {
}
sub changewarning {
- my ($r,$postexec)=@_;
+ my ($r,$postexec,$message,$url)=@_;
if (!&is_hash_old()) { return; }
- $r->print(
-''.
-'');
+ my $pathvar='folderpath';
+ my $path=&escape($env{'form.folderpath'});
+ if (!defined($url)) {
+ if (defined($env{'form.pagepath'})) {
+ $pathvar='pagepath';
+ $path=&escape($env{'form.pagepath'});
+ $path.='&pagesymb='.&escape($env{'form.pagesymb'});
+ }
+ $url='/adm/coursedocs?'.$pathvar.'='.$path;
+ }
+ my $course_type = &Apache::loncommon::course_type();
+ if (!defined($message)) {
+ $message='Changes will become active for your current session after [_1], or the next time you log in.';
+ }
+ $r->print("\n\n".
+''."\n".
+''."\n\n");
+
+}
+
+
+sub init_breadcrumbs {
+ my ($form,$text)=@_;
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
+ text=>&Apache::loncommon::course_type().' Editor',
+ faq=>273,
+ bug=>'Instructor Interface',
+ help => 'Docs_Adding_Course_Doc'});
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
+ text=>$text,
+ faq=>273,
+ bug=>'Instructor Interface'});
}
-# ================================================================ Main Handler
+
+
+
sub handler {
my $r = shift;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
+ my $crstype = &Apache::loncommon::course_type();
# --------------------------------------------- Initialize help topics for this
- foreach ('Adding_Course_Doc','Main_Course_Documents',
- 'Adding_External_Resource','Navigate_Content',
- 'Adding_Folders','Docs_Overview', 'Load_Map',
- 'Supplemental', 'Score_Upload_Form',
- 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
- 'Check_Resource_Versions','Verify_Content') {
- $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
- }
+ foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
+ 'Adding_External_Resource','Navigate_Content',
+ 'Adding_Folders','Docs_Overview', 'Load_Map',
+ 'Supplemental','Score_Upload_Form','Adding_Pages',
+ 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
+ 'Check_Resource_Versions','Verify_Content') {
+ $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
+ }
# Composite help files
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
@@ -1081,510 +2599,1024 @@ sub handler {
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
+ $help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
-
- if ($ENV{'form.verify'}) {
+
+# does this user have privileges to modify docs
+ my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+ if ($allowed && $env{'form.verify'}) {
+ &init_breadcrumbs('verify','Verify Content');
&verifycontent($r);
- } elsif ($ENV{'form.versions'}) {
+ } elsif ($allowed && $env{'form.listsymbs'}) {
+ &init_breadcrumbs('listsymbs','List Symbs');
+ &list_symbs($r);
+ } elsif ($allowed && $env{'form.docslog'}) {
+ &init_breadcrumbs('docslog','Show Log');
+ &docs_change_log($r);
+ } elsif ($allowed && $env{'form.versions'}) {
+ &init_breadcrumbs('versions','Check/Set Resource Versions');
&checkversions($r);
- } elsif ($ENV{'form.dumpcourse'}) {
+ } elsif ($allowed && $env{'form.dumpcourse'}) {
+ &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
&dumpcourse($r);
+ } elsif ($allowed && $env{'form.exportcourse'}) {
+ &init_breadcrumbs('exportcourse','IMS Export');
+ &exportcourse($r);
} else {
# is this a standard course?
- my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
- my $forcestandard;
+ my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
+ my $forcestandard = 0;
my $forcesupplement;
my $script='';
- my $allowed;
- my $events='';
my $showdoc=0;
+ my $containertag;
+ my $uploadtag;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['folderpath']);
- if ($ENV{'form.folderpath'}) {
- my (@folderpath)=split('&',$ENV{'form.folderpath'});
- $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
- $ENV{'form.folder'}=pop(@folderpath);
- }
+ ['folderpath','pagepath',
+ 'pagesymb']);
+# No folderpath, no pagepath, see if we have something stored
+ if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
+ &Apache::loncommon::restore_course_settings('docs_folderpath',
+ {'folderpath' => 'scalar'});
+ }
+ if (!$env{'form.folderpath'}) {
+ &Apache::loncommon::restore_course_settings('docs_folderpath',
+ {'pagepath' => 'scalar'});
+ }
+ if ($env{'form.pagepath'}) {
+ $env{'form.folderpath'}='';
+ }
+ if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
+ $env{'form.folderpath'} = 'supplemental&'.
+ &escape(&mt('Supplemental '.$crstype.' Documents')).'&'.
+ $env{'form.folderpath'};
+ }
+ &Apache::loncommon::store_course_settings('docs_folderpath',
+ {'pagepath' => 'scalar',
+ 'folderpath' => 'scalar'});
+ if ($env{'form.folderpath'}) {
+ my (@folderpath)=split('&',$env{'form.folderpath'});
+ $env{'form.foldername'}=&unescape(pop(@folderpath));
+ $env{'form.folder'}=pop(@folderpath);
+ }
+ if ($env{'form.pagepath'}) {
+ my (@pagepath)=split('&',$env{'form.pagepath'});
+ $env{'form.pagename'}=&unescape(pop(@pagepath));
+ $env{'form.folder'}=pop(@pagepath);
+ $containertag = ''.
+ '';
+ $uploadtag = ''.
+ '';
+ }
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc='/'.$1;
}
unless ($showdoc) { # got called from remote
- $forcestandard=($ENV{'form.folder'}=~/^default_/);
- $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
+ if (($env{'form.folder'}=~/^(?:group|default)_/) ||
+ ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
+ $forcestandard = 1;
+ }
+ $forcesupplement=($env{'form.folder'}=~/^supplemental_/);
-# 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');
}
} else { # got called in sequence from course
$allowed=0;
- $script=''.&Apache::lonmenu::registerurl(1,undef).'
-ENDDOCUMENT
- if ($allowed) {
- $r->print(<
-function makenewfolder(targetform,folderseq) {
- var foldername=prompt('Name of New Folder','New Folder');
- if (foldername) {
- targetform.importdetail.value=foldername+"="+folderseq;
- targetform.submit();
- }
-}
-
-function makenewext(targetname) {
- this.document.forms.extimport.useform.value=targetname;
- window.open('/adm/rat/extpickframe.html');
-}
+ $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
-function makeexamupload() {
- var title=prompt('Listed Title for the Uploaded Score');
- if (title) {
- this.document.forms.newexamupload.importdetail.value=
- title+'=/res/lib/templates/examupload.problem';
- this.document.forms.newexamupload.submit();
- }
-}
-
-function makesmppage() {
- var title=prompt('Listed Title for the Page');
- if (title) {
- this.document.forms.newsmppg.importdetail.value=
- title+'=/adm/$udom/$uname/$now/smppg';
- this.document.forms.newsmppg.submit();
- }
-}
-
-function makesmpproblem() {
- var title=prompt('Listed Title for the Problem');
- if (title) {
- this.document.forms.newsmpproblem.importdetail.value=
- title+'=/res/lib/templates/simpleproblem.problem';
- this.document.forms.newsmpproblem.submit();
- }
-}
-
-function makebulboard() {
- var title=prompt('Listed Title for the Bulletin Board');
- if (title) {
- this.document.forms.newbul.importdetail.value=
- title+'=/adm/$udom/$uname/$now/bulletinboard';
- this.document.forms.newbul.submit();
- }
-}
-
-function makeabout() {
- var user=prompt("Enter user\@domain for User's 'About Me' Page");
- 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=
- 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
- this.document.forms.newaboutsomeone.submit();
- }
- }
- }
-}
-
-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;
- eval
- ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
- '";this.document.forms.'+form+'.submit();');
-}
-
-function changename(folderpath,index,oldtitle) {
- var title=prompt('New Title',oldtitle);
- if (title) {
- this.document.forms.renameform.title.value=title;
- this.document.forms.renameform.cmd.value='rename_'+index;
- this.document.forms.renameform.folderpath.value=folderpath;
- this.document.forms.renameform.submit();
- }
-}
-
-function removeres(folderpath,index,oldtitle) {
- if (confirm('Remove "'+oldtitle+'"?')) {
- this.document.forms.renameform.cmd.value='del_'+index;
- this.document.forms.renameform.folderpath.value=folderpath;
- this.document.forms.renameform.submit();
+ if ($allowed) {
+ $script .= &editing_js($udom,$uname);
}
-}
-
-
-
-ENDNEWSCRIPT
- }
# -------------------------------------------------------------------- Body tag
- $r->print(''.
- &Apache::loncommon::bodytag('Course Documents','',$events,
- '','',$showdoc).
- &Apache::loncommon::help_open_menu('','','','',273,'RAT'));
- unless ($showdoc) {
+ $script = ''."\n";
+ my $brcrum = [{href=>"/adm/createuser",text=>"$crstype Editor"}];
+ $r->print(&Apache::loncommon::start_page("$crstype Editor", $script,
+ {'force_register' => $showdoc,
+ 'bread_crumbs' => $brcrum}).
+ &Apache::loncommon::help_open_menu('','',273,'RAT'));
+
+ my %allfiles = ();
+ my %codebase = ();
+ my ($upload_result,$upload_output);
+ if ($allowed) {
+ if (($env{'form.uploaddoc.filename'}) &&
+ ($env{'form.cmd'}=~/^upload_(\w+)/)) {
+# Process file upload - phase one - upload and parse primary file.
+ undef($hadchanges);
+ $upload_result = &process_file_upload(\$upload_output,$coursenum,
+ $coursedom,\%allfiles,
+ \%codebase,$1);
+ if ($hadchanges) {
+ &mark_hash_old();
+ }
+ if ($upload_result eq 'phasetwo') {
+ $r->print($upload_output);
+ }
+ } elsif ($env{'form.phasetwo'}) {
+ my %newname = ();
+ my %origname = ();
+ my %attribs = ();
+ my $updateflag = 0;
+ my $residx = $env{'form.newidx'};
+ my $primary_url = &unescape($env{'form.primaryurl'});
+# Process file upload - phase two - gather secondary files.
+ for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
+ if ($env{'form.embedded_item_'.$i.'.filename'}) {
+ my $javacodebase;
+ $newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
+ $origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
+ if (exists($env{'form.embedded_codebase_'.$i})) {
+ $javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
+ $origname{$i} =~ s#^\Q$javacodebase\E/##;
+ }
+ my @attributes = ();
+ if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
+ @attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
+ } else {
+ @attributes = ($env{'form.embedded_attrib_'.$i});
+ }
+ foreach my $attr (@attributes) {
+ push(@{$attribs{$i}},&unescape($attr));
+ }
+ if ($javacodebase) {
+ $codebase{$i} = $javacodebase;
+ $codebase{$i} =~ s#/$##;
+ $updateflag = 1;
+ }
+ }
+ unless ($newname{$i} eq $origname{$i}) {
+ $updateflag = 1;
+ }
+ }
+# Process file upload - phase three - modify primary file
+ if ($updateflag) {
+ my ($content,$rtncode);
+ my $updateflag = 0;
+ my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
+ if ($getstatus eq 'ok') {
+ foreach my $item (keys(%newname)) {
+ if ($newname{$item} ne $origname{$item}) {
+ my $attrib_regexp = '';
+ if (@{$attribs{$item}} > 1) {
+ $attrib_regexp = join('|',@{$attribs{$item}});
+ } else {
+ $attrib_regexp = $attribs{$item}[0];
+ }
+ if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
+ }
+ $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
+ }
+ if (exists($codebase{$item})) {
+ $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
+ }
+ }
+# 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 course document',
- 'upls' => 'Upload a new supplemental course document',
- 'impp' => 'Import a published document',
+ 'uplm' => 'Upload a new main '.lc($crstype).' document',
+ 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
+ 'impp' => 'Import a document',
+ 'pubd' => 'Published documents',
+ 'copm' => 'All documents out of a published map into this folder',
'spec' => 'Special documents',
'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',
+ 'sipa' => 'Simple Course Page',
'sipr' => 'Simple Problem',
+ 'drbx' => 'Drop Box',
'scuf' => 'Score Upload Form',
- 'bull' => 'Bulletin Board',
- 'mypi' => 'My Personal Info',
+ 'bull' => 'Discussion Board',
+ 'mypi' => 'My Personal Information Page',
+ 'grpo' => 'Group Portfolios',
+ 'rost' => 'Course Roster',
'abou' => 'About User',
- 'imsf' => 'Import IMS package',
+ 'imsf' => 'IMS Import',
+ 'imsl' => 'Import IMS package',
'file' => 'File',
'title' => 'Title',
- 'comment' => 'Comment'
+ 'comment' => 'Comment',
+ 'parse' => 'If HTML file, upload embedded images/multimedia files'
);
# -----------------------------------------------------------------------------
+ my %tabtitles = (
+ main => {
+ Course => &mt('Main Course Documents'),
+ Community => &mt('Main Community Documents'),
+ },
+ supplemental => {
+ Course => &mt('Supplemental Course Documents'),
+ Community => &mt('Supplemental Community Documents'),
+ },
+ );
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'};
+ my $folderpath=$env{'form.folderpath'};
if (!$folderpath) {
- if ($ENV{'form.folder'} eq '' ||
- $ENV{'form.folder'} eq 'supplemental') {
- $folderpath='default&'.
- &Apache::lonnet::escape(&mt('Main Course Documents'));
+ if ($env{'form.folder'} eq '' ||
+ $env{'form.folder'} eq 'supplemental') {
+ $folderpath='default&'.&escape($tabtitles{'main'}{$crstype});
}
}
+ unless ($env{'form.pagepath'}) {
+ $containertag = '';
+ $uploadtag = '';
+ }
+
$r->print(<
-
-
-
+
+
+
+
+ $containertag
+
ENDCOURSEVERIFY
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
- &mt('Editing the Table of Contents for your Course')));
+ &mt('Editing the Table of Contents for your '.$crstype)));
}
# --------------------------------------------------------- Standard documents
- $r->print('