--- loncom/interface/londocs.pm 2006/11/11 18:36:43 1.246 +++ loncom/interface/londocs.pm 2006/11/12 02:13:05 1.247 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.246 2006/11/11 18:36:43 raeburn Exp $ +# $Id: londocs.pm,v 1.247 2006/11/12 02:13:05 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -991,6 +991,135 @@ sub breadcrumbs { 'LC_docs_path'),$randompick,$ishidden,$isencrypted); } +sub log_docs { + return &Apache::lonnet::instructor_log('docslog',@_); +} + +{ + my @oldresources=(); + my @oldorder=(); + my $parmidx; + my %parmaction=(); + my %parmvalue=(); + + sub snapshotbefore { + @oldresources=@Apache::lonratedt::resources; + @oldorder=@Apache::lonratedt::order; + $parmidx=undef; + %parmaction=(); + %parmvalue=(); + } + + sub remember_parms { + my ($idx,$parameter,$action,$value)=@_; + $parmidx=$idx; + $parmaction{$parameter}=$action; + $parmvalue{$parameter}=$value; + } + + sub log_differences { + my $r=shift; + my %storehash=('folder' => $env{'form.folder'}); + if ($parmidx) { + $storehash{'parameter_idx'}=$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 ($#Apache::lonratedt::resources>$#oldresources) { + $maxidx=$#Apache::lonratedt::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]; + } + if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) { + $storehash{'before_order_'.$idx}=$oldorder[$idx]; + $storehash{'after_order_'.$idx}=$LONCAPA::map::order[$idx]; + $storehash{'before_order_res_'.$idx}=$oldresources[$idx]; + $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$idx]; + } + } + &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('
'. + ''); + + my %saveable_parameters = ('show' => 'scalar',); + &Apache::loncommon::store_course_settings('docs_log', + \%saveable_parameters); + &Apache::loncommon::restore_course_settings('docs_log', + \%saveable_parameters); + if (!$env{'form.show'}) { $env{'form.show'}=10; } + + my $countselect = + &Apache::lonmeta::selectbox('show',$env{'form.show'},undef, + (&mt('all'),10,20,50,100,1000,10000)); + + $r->print(''.&mt('[_1] Records',$countselect).''. + '
'); + $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row(). + ''.&mt('Time').''.&mt('User').''.&mt('Extent').''.&mt('Users').''. + &mt('Parameter').''.&mt('Part').''.&mt('New Value').''.&mt('Announce').''. + &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(''.$time.' + '.$about_me_link. + '
'.$docslog{$id}{'exe_uname'}. + ':'.$docslog{$id}{'exe_udom'}.''. + $send_msg_link.''); + + $r->print(&Apache::loncommon::end_data_table_row()); + $shown++; + if (!($env{'form.show'} eq &mt('all') + || $shown<=$env{'form.show'})) { last; } + } + $r->print(&Apache::loncommon::end_data_table()); + $r->print(&Apache::loncommon::end_page()); +} + sub editor { my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output)=@_; my $errtext=''; @@ -1023,68 +1152,73 @@ sub editor { # ---------------- if they are for this folder and user allowed to make changes if (($allowed) && ($env{'form.folder'} eq $folder)) { # set parameters and change order - if (defined($env{'form.setparms'})) { + &snapshotbefore(); + if ($env{'form.changeparms'}) { my $idx=$env{'form.setparms'}; # set parameters if ($env{'form.randpick_'.$idx}) { &LONCAPA::map::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); + &remember_parms($idx,'randompick','set',$env{'form.randpick_'.$idx}); } else { &LONCAPA::map::delparameter($idx,'parameter_randompick'); + &remember_parms($idx,'randompick','del'); } if ($env{'form.hidprs_'.$idx}) { &LONCAPA::map::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); - } else { + &remember_parms($idx,'hiddenresource','set',$env{'form.hidprs_'.$idx}); + } else { &LONCAPA::map::delparameter($idx,'parameter_hiddenresource'); - } + &remember_parms($idx,'hiddenresource','del'); + } if ($env{'form.encprs_'.$idx}) { &LONCAPA::map::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); - } else { + &remember_parms($idx,'encrypturl','set',$env{'form.encprs_'.$idx}); + } else { &LONCAPA::map::delparameter($idx,'parameter_encrypturl'); - } + &remember_parms($idx,'encrypturl','del'); + } + } - if ($env{'form.newpos'}) { + if ($env{'form.newpos'}) { # change order - - my $newpos=$env{'form.newpos'}-1; - my $currentpos=$env{'form.currentpos'}-1; - my $i; - my @neworder=(); - if ($newpos>$currentpos) { + my $newpos=$env{'form.newpos'}-1; + my $currentpos=$env{'form.currentpos'}-1; + my $i; + my @neworder=(); + if ($newpos>$currentpos) { # moving stuff up - for ($i=0;$i<$currentpos;$i++) { - $neworder[$i]=$LONCAPA::map::order[$i]; - } - for ($i=$currentpos;$i<$newpos;$i++) { - $neworder[$i]=$LONCAPA::map::order[$i+1]; - } - $neworder[$newpos]=$LONCAPA::map::order[$currentpos]; - for ($i=$newpos+1;$i<=$#LONCAPA::map::order;$i++) { - $neworder[$i]=$LONCAPA::map::order[$i]; - } - } else { + for ($i=0;$i<$currentpos;$i++) { + $neworder[$i]=$LONCAPA::map::order[$i]; + } + for ($i=$currentpos;$i<$newpos;$i++) { + $neworder[$i]=$LONCAPA::map::order[$i+1]; + } + $neworder[$newpos]=$LONCAPA::map::order[$currentpos]; + for ($i=$newpos+1;$i<=$#LONCAPA::map::order;$i++) { + $neworder[$i]=$LONCAPA::map::order[$i]; + } + } else { # moving stuff down - for ($i=0;$i<$newpos;$i++) { - $neworder[$i]=$LONCAPA::map::order[$i]; - } - $neworder[$newpos]=$LONCAPA::map::order[$currentpos]; - for ($i=$newpos+1;$i<$currentpos+1;$i++) { - $neworder[$i]=$LONCAPA::map::order[$i-1]; - } - for ($i=$currentpos+1;$i<=$#LONCAPA::map::order;$i++) { - $neworder[$i]=$LONCAPA::map::order[$i]; - } + for ($i=0;$i<$newpos;$i++) { + $neworder[$i]=$LONCAPA::map::order[$i]; + } + $neworder[$newpos]=$LONCAPA::map::order[$currentpos]; + for ($i=$newpos+1;$i<$currentpos+1;$i++) { + $neworder[$i]=$LONCAPA::map::order[$i-1]; + } + for ($i=$currentpos+1;$i<=$#LONCAPA::map::order;$i++) { + $neworder[$i]=$LONCAPA::map::order[$i]; } - @LONCAPA::map::order=@neworder; } + @LONCAPA::map::order=@neworder; # store the changed version - ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); if ($fatal) { $r->print('

'.$errtext.'

'); return; } - } + if ($env{'form.pastemarked'}) { # paste resource to end of list my $url=$env{'form.markedcopy_url'}; @@ -1222,6 +1356,7 @@ sub editor { $r->print('

'.&mt('No map selected.').'

'); } } + &log_differences($r); } # ---------------------------------------------------------------- End commands # ---------------------------------------------------------------- Print screen @@ -1504,6 +1639,7 @@ ENDCOPY +
@@ -1535,6 +1671,7 @@ ENDCOPY + + + ENDPARMS } @@ -2169,6 +2306,8 @@ sub handler { &verifycontent($r); } elsif ($allowed && $env{'form.listsymbs'}) { &list_symbs($r); + } elsif ($allowed && $env{'form.docslog'}) { + &docs_change_log($r); } elsif ($allowed && $env{'form.versions'}) { &checkversions($r); } elsif ($allowed && $env{'form.dumpcourse'}) { @@ -2367,6 +2506,7 @@ sub handler { 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', 'ls' => 'List Symbs', + 'sl' => 'Show Log' ); my $folderpath=$env{'form.folderpath'}; @@ -2403,6 +2543,8 @@ $dumpbut $exportbut
@@ -1632,7 +1769,7 @@ END 'parameter_encrypturl'))[0]=~/^yes$/i); $url.='folderpath='.&escape($folderpath).$cpinfo; $parameterset=' - $parameterset + +
ENDCOURSEVERIFY