--- loncom/interface/londocs.pm 2006/05/30 12:46:09 1.228
+++ loncom/interface/londocs.pm 2006/11/22 03:56:36 1.255
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.228 2006/05/30 12:46:09 www Exp $
+# $Id: londocs.pm,v 1.255 2006/11/22 03:56:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,16 +33,15 @@ use Apache::Constants qw(:common :http);
use Apache::imsexport;
use Apache::lonnet;
use Apache::loncommon;
-use Apache::lonratedt;
-use Apache::lonratsrv;
+use LONCAPA::map();
+use Apache::lonratedt();
use Apache::lonxml;
-use Apache::loncreatecourse;
+use Apache::lonclonecourse;
use Apache::lonnavmaps;
use HTML::Entities;
use GDBM_File;
use Apache::lonlocal;
use Cwd;
-use lib '/home/httpd/lib/perl/';
use LONCAPA;
my $iconpath;
@@ -58,7 +57,7 @@ my $hadchanges;
my %help=();
-# Mapread read maps into lonratedt::global arrays
+# 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
@@ -67,15 +66,15 @@ my %help=();
sub mapread {
my ($coursenum,$coursedom,$map)=@_;
return
- &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
- $map);
+ &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map);
}
sub storemap {
my ($coursenum,$coursedom,$map)=@_;
my ($outtext,$errtext)=
- &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
- $map,1);
+ &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map,1);
if ($errtext) { return ($errtext,2); }
$hadchanges=1;
@@ -121,16 +120,18 @@ sub authorhosts {
sub dumpbutton {
my ($home,$other,%outhash)=&authorhosts();
+ my $type = &Apache::loncommon::course_type();
if ($home+$other==0) { return ''; }
my $output='
';
if ($home) {
return '
'.
''.
+ &mt('Dump '.$type.' DOCS to Construction Space').'" />'.
&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
} else {
return'
'.
- &mt('Dump Course DOCS to Construction Space: available on other servers');
+ &mt('Dump '.$type.
+ ' DOCS to Construction Space: available on other servers');
}
}
@@ -143,8 +144,8 @@ sub clean {
sub dumpcourse {
my ($r) = @_;
-
- $r->print(&Apache::loncommon::start_page('Dump Course DOCS to Construction Space').
+ my $type = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
'');
+ '');
}
}
# ------------------------------------------------------ Generate "export" button
sub exportbutton {
+ my $type = &Apache::loncommon::course_type();
return '
'.
''.
+ &mt('Export '.$type.' to IMS').'" />'.
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
}
sub exportcourse {
my $r=shift;
+ my $type = &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;
@@ -301,7 +306,7 @@ sub exportcourse {
open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
close(OUTPUT);
chdir $cwd;
- $outcome .= 'Download the zip file from IMS course archive ';
+ $outcome .= &mt('Download the zip file from IMS '.lc($type).' archive ',$imszipfile,);
if ($copyresult) {
$outcome .= 'The following errors occurred during export - '.$copyresult;
}
@@ -309,13 +314,13 @@ sub exportcourse {
$outcome = ' Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file. ';
}
}
- $r->print(&Apache::loncommon::start_page('Export course to IMS content package'));
+ $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
$r->print($outcome);
$r->print(&Apache::loncommon::end_page());
} else {
my $display;
$display = ''.
+ &mt('Export '.$type.' DOCS').'" />'.
&Apache::loncommon::end_page());
}
}
@@ -925,13 +930,13 @@ sub group_import {
}
}
if ($url) {
- my $idx = &Apache::lonratedt::getresidx($url);
- $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
+ my $idx = &LONCAPA::map::getresidx($url);
+ $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
my $ext = 'false';
if ($url=~/^http:\/\//) { $ext = 'true'; }
$url =~ s/:/\:/g;
$name =~ s/:/\:/g;
- $Apache::lonratedt::resources[$idx] =
+ $LONCAPA::map::resources[$idx] =
join ':', ($name, $url, $ext, 'normal', 'res');
}
}
@@ -949,13 +954,16 @@ sub breadcrumbs {
}
my $folderpath;
my $cpinfo='';
+ my $plain='';
if ($env{'form.markedcopy_url'}) {
- &Apache::lonnet::logthis('Found '.$env{'form.markedcopy_url'});
$cpinfo='&markedcopy_url='.
&escape($env{'form.markedcopy_url'}).
'&markedcopy_title='.
&escape($env{'form.markedcopy_title'});
}
+ my $randompick=-1;
+ my $isencrypted=0;
+ my $ishidden=0;
while (@folders) {
my $folder=shift(@folders);
my $foldername=shift(@folders);
@@ -963,16 +971,209 @@ sub breadcrumbs {
$folderpath.=$folder.'&'.$foldername;
my $url='/adm/coursedocs?folderpath='.
&escape($folderpath);
+ my $name=&unescape($foldername);
+# randompick number, hidden, encrypted is appended with ":"s to the foldername
+ $name=~s/\:(\d*)\:(\w*)\:(\w*)$//;
+ if ($1 ne '') {
+ $randompick=$1;
+ } else {
+ $randompick=-1;
+ }
+ if ($2) { $ishidden=1; }
+ if ($3) { $isencrypted=1; }
&Apache::lonhtmlcommon::add_breadcrumb(
{'href'=>$url.$cpinfo,
- 'title'=>&unescape($foldername),
+ 'title'=>$name,
'text'=>''.
- &unescape($foldername).''
+ $name.''
});
-
-
+ $plain.=$name.' > ';
+ }
+ $plain=~s/\>\;\s*$//;
+ return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
+ 'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain);
+}
+
+sub log_docs {
+ return &Apache::lonnet::instructor_log('docslog',@_);
+}
+
+{
+ my @oldresources=();
+ my @oldorder=();
+ my $parmidx;
+ my %parmaction=();
+ my %parmvalue=();
+ my $changedflag;
+
+ sub snapshotbefore {
+ @oldresources=@LONCAPA::map::resources;
+ @oldorder=@LONCAPA::map::order;
+ $parmidx=undef;
+ %parmaction=();
+ %parmvalue=();
+ $changedflag=0;
+ }
+
+ sub remember_parms {
+ my ($idx,$parameter,$action,$value)=@_;
+ $parmidx=$idx;
+ $parmaction{$parameter}=$action;
+ $parmvalue{$parameter}=$value;
+ $changedflag=1;
+ }
+
+ sub log_differences {
+ my ($plain)=@_;
+ my %storehash=('folder' => $plain);
+ if ($parmidx) {
+ $storehash{'parameter_res'}=$oldresources[$parmidx];
+ foreach my $parm (keys %parmaction) {
+ $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
+ $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
+ }
+ }
+ my $maxidx=$#oldresources;
+ if ($#LONCAPA::map::resources>$#oldresources) {
+ $maxidx=$#LONCAPA::map::resources;
+ }
+ for (my $idx=0; $idx<=$maxidx; $idx++) {
+ if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
+ $storehash{'before_resources_'.$idx}=$oldresources[$idx];
+ $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
+ $changedflag=1;
+ }
+ if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
+ $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
+ $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
+ $changedflag=1;
+ }
+ }
+ $storehash{'maxidx'}=$maxidx;
+ if ($changedflag) { &log_docs(\%storehash); }
+ }
+}
+
+
+#
+# Docs Change Log
+#
+sub docs_change_log {
+ my ($r)=@_;
+ $r->print(&Apache::loncommon::start_page('Course Document Change Log'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
+
+ my %docslog=&Apache::lonnet::dump('nohist_docslog',
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+
+ if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
+
+ $r->print('');
+ $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
+ '
'.&mt('Time').'
'.&mt('User').'
'.&mt('Folder').'
'.&mt('Before').'
'.
+ &mt('After').'
'.
+ &Apache::loncommon::end_data_table_header_row());
+ my $shown=0;
+ foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
+ my @changes=keys(%{$docslog{$id}{'logentry'}});
+ my $count = 0;
+ my $time =
+ &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
+ my $plainname =
+ &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
+ $docslog{$id}{'exe_udom'});
+ my $about_me_link =
+ &Apache::loncommon::aboutmewrapper($plainname,
+ $docslog{$id}{'exe_uname'},
+ $docslog{$id}{'exe_udom'});
+ my $send_msg_link='';
+ if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
+ || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
+ $send_msg_link =' '.
+ &Apache::loncommon::messagewrapper(&mt('Send message'),
+ $docslog{$id}{'exe_uname'},
+ $docslog{$id}{'exe_udom'});
+ }
+ $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print('
');
+# 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.').'
');
+ }
$r->print('
');
- foreach (@Apache::lonratedt::order) {
- my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
- $name=&Apache::lonratsrv::qtescape($name);
- $url=&Apache::lonratsrv::qtescape($url);
+ foreach (@LONCAPA::map::order) {
+ my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$_]);
+ $name=&LONCAPA::map::qtescape($name);
+ $url=&LONCAPA::map::qtescape($url);
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $idx++; next; }
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
@@ -1273,9 +1496,9 @@ sub process_file_upload {
}
($errtext,$fatal)=
&mapread($coursenum,$coursedom,$folder.'.'.$container);
- if ($#Apache::lonratedt::order<1) {
- $Apache::lonratedt::order[0]=1;
- $Apache::lonratedt::resources[1]='';
+ if ($#LONCAPA::map::order<1) {
+ $LONCAPA::map::order[0]=1;
+ $LONCAPA::map::resources[1]='';
}
if ($fatal) {
return 'failed';
@@ -1291,7 +1514,7 @@ sub process_file_upload {
}
# this is for a course, not a user, so set coursedoc flag
# probably the only place in the system where this should be "1"
- my $newidx=&Apache::lonratedt::getresidx();
+ my $newidx=&LONCAPA::map::getresidx();
$destination .= $newidx;
my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
$parseaction,$allfiles,
@@ -1308,9 +1531,9 @@ sub process_file_upload {
$env{'user.domain'}.'___&&&___'.$comment;
}
- $Apache::lonratedt::resources[$newidx]=
- $comment.':'.$url.':'.$ext.':normal:res';
- $Apache::lonratedt::order[$#Apache::lonratedt::order+1]= $newidx;
+ $LONCAPA::map::resources[$newidx]=
+ $comment.':'.$url.':'.$ext.':normal:res';
+ $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
($errtext,$fatal)=&storemap($coursenum,$coursedom,
$folder.'.'.$container);
if ($fatal) {
@@ -1391,7 +1614,7 @@ sub entryline {
my $renametitle=$title;
my $foldertitle=$title;
my $pagetitle=$title;
- my $orderidx=$Apache::lonratedt::order[$index];
+ my $orderidx=$LONCAPA::map::order[$index];
if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) {
$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
$renametitle=$4;
@@ -1427,17 +1650,17 @@ sub entryline {
my $incindex=$index+1;
my $selectbox='';
if (($folder!~/^supplemental/) &&
- ($#Apache::lonratedt::order>0) &&
+ ($#LONCAPA::map::order>0) &&
((split(/\:/,
- $Apache::lonratedt::resources[$Apache::lonratedt::order[0]]))[1]
+ $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
ne '') &&
((split(/\:/,
- $Apache::lonratedt::resources[$Apache::lonratedt::order[1]]))[1]
+ $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
ne '')) {
$selectbox=
''.
'