--- loncom/interface/londocs.pm 2013/11/12 14:36:07 1.567 +++ loncom/interface/londocs.pm 2013/12/30 21:10:36 1.574 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.567 2013/11/12 14:36:07 raeburn Exp $ +# $Id: londocs.pm,v 1.574 2013/12/30 21:10:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -163,8 +163,8 @@ ENDJS add_entries => {'onload' => "hide_searching();"}, }; } - $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Content to Authoring Space',$js,$starthash)."\n". - &Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Content to Authoring Space')."\n"); + $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n". + &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n"); $r->print(&startContentScreen('tools')); my ($home,$other,%outhash)=&authorhosts(); unless ($home) { @@ -492,6 +492,9 @@ $contents{webreferences}.' } } } + if ($home>1) { + $preamble .= ''; + } foreach my $user (@orderspaces) { if ($home==1) { $preamble .= ''; @@ -3140,6 +3143,8 @@ sub process_file_upload { $quotatype = 'community'; } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) { $quotatype = 'official'; + } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { + $quotatype = 'textbook'; } if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) { $filesize = int($filesize/1000); #expressed in kb @@ -4030,8 +4035,8 @@ sub devalidateversioncache { sub checkversions { my ($r) = @_; my $crstype = &Apache::loncommon::course_type(); - $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions")); - $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions")); + $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions")); + $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions")); $r->print(&startContentScreen('tools')); my $header=''; @@ -4187,10 +4192,30 @@ $lt{'sc'}:

$lt{'vers'}

- ENDHEADERS #number of columns for version history + my %changedbytime; + foreach my $key (keys(%changes)) { + #excludes not versionable problems from resource version history: + next if ($key =~ /^\/res\/lib\/templates/); + my $chg; + if ($env{'form.timerange'} eq 'all') { + my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); + $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate'); + } else { + $chg = $changes{$key}; + next if ($chg < $starttime); + } + push(@{$changedbytime{$chg}},$key); + } + if (keys(%changedbytime) == 0) { + &untiehash(); + $r->print(&mt('No content changes in imported content in specified time frame'). + &endContentScreen()); + return; + } $r->print( + ''. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). ''.&mt('Resources').''. @@ -4200,26 +4225,25 @@ ENDHEADERS ''.&mt('History').''. &Apache::loncommon::end_data_table_header_row() ); - foreach my $key (sort(keys(%changes))) { - #excludes not versionable problems from resource version history: - next unless ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/); - 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($key); - $r->print( - &Apache::loncommon::start_data_table_row(). - ''.&Apache::lonnet::gettitle($linkurl).'
'. - ''.$linkurl.''. - ''.$currentversion.'
('. - &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).')
'. - '' - ); - # Used in course - my $usedversion=$hash{'version_'.$linkurl}; - if (($usedversion) && ($usedversion ne 'mostrecent')) { + foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) { + foreach my $key (sort(@{$changedbytime{$chg}})) { + 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($key); + $r->print( + &Apache::loncommon::start_data_table_row(). + ''.&Apache::lonnet::gettitle($linkurl).'
'. + ''.$linkurl.''. + ''.$currentversion.'
('. + &Apache::lonlocal::locallocaltime($chg).')
'. + '' + ); + # Used in course + my $usedversion=$hash{'version_'.$linkurl}; + if (($usedversion) && ($usedversion ne 'mostrecent')) { if ($usedversion != $currentversion) { $r->print(''.$usedversion.''); } else { @@ -4228,44 +4252,45 @@ ENDHEADERS } else { $r->print($currentversion); } - $r->print(''); - # Set version - $r->print(&Apache::loncommon::select_form( - $setversions{$linkurl}, - 'set_version_'.$linkurl, - {'select_form_order' => ['',1..$currentversion,'mostrecent'], - '' => '', - 'mostrecent' => &mt('most recent'), - map {$_,$_} (1..$currentversion)})); - my $lastold=1; - for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { - my $url=$root.'.'.$prevvers.'.'.$extension; - if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) { - $lastold=$prevvers; - } - } - $r->print(''); - # List all available versions - $r->print(''); - for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { - my $url=$root.'.'.$prevvers.'.'.$extension; - $r->print( - '' - .'' - .&mt('Version [_1]',$prevvers).'' - .' ('.&Apache::lonlocal::locallocaltime( - &Apache::lonnet::metadata($url,'lastrevisiondate')) - .')'); - if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { + $r->print(''); + # Set version + $r->print(&Apache::loncommon::select_form( + $setversions{$linkurl}, + 'set_version_'.$linkurl, + {'select_form_order' => ['',1..$currentversion,'mostrecent'], + '' => '', + 'mostrecent' => &mt('most recent'), + map {$_,$_} (1..$currentversion)})); + my $lastold=1; + for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { + my $url=$root.'.'.$prevvers.'.'.$extension; + if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) { + $lastold=$prevvers; + } + } + $r->print(''); + # List all available versions + $r->print(''); + for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { + my $url=$root.'.'.$prevvers.'.'.$extension; $r->print( - ' &'). - '" target="diffs">'.&mt('Diffs').''); + '' + .'' + .&mt('Version [_1]',$prevvers).'' + .' ('.&Apache::lonlocal::locallocaltime( + &Apache::lonnet::metadata($url,'lastrevisiondate')) + .')'); + if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { + $r->print( + ' &'). + '" target="diffs">'.&mt('Diffs').''); + } + $r->print('
'); } - $r->print('

'); + $r->print('
'.&Apache::loncommon::end_data_table_row()); } - $r->print('
'.&Apache::loncommon::end_data_table_row()); } $r->print( &Apache::loncommon::end_data_table(). @@ -4275,6 +4300,7 @@ ENDHEADERS &untiehash(); $r->print(&endContentScreen()); + return; } sub mark_hash_old { @@ -4329,13 +4355,13 @@ $help{'Caching'}.'

'."\n\n"); sub init_breadcrumbs { - my ($form,$text)=@_; + my ($form,$text,$help)=@_; &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1", text=>&Apache::loncommon::course_type().' Editor', faq=>273, bug=>'Instructor Interface', - help => 'Docs_Adding_Course_Doc'}); + help => $help}); &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1', text=>$text, faq=>273, @@ -4419,9 +4445,8 @@ sub handler { 'Adding_Folders','Docs_Overview', 'Load_Map', 'Supplemental','Score_Upload_Form','Adding_Pages', 'Importing_LON-CAPA_Resource','Importing_IMS_Course', - 'Uploading_From_Harddrive', - 'Check_Resource_Versions','Verify_Content', - 'Course_Roster','Web_Page','Dropbox') { + 'Uploading_From_Harddrive','Course_Roster','Web_Page', + 'Dropbox','Simple_Problem') { $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); } # Composite help files @@ -4429,8 +4454,6 @@ sub handler { 'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); $help{'Simple Page'} = &Apache::loncommon::help_open_topic( 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages'); - $help{'Simple Problem'} = &Apache::loncommon::help_open_topic( - 'Option_Response_Simple'); $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic( @@ -4451,7 +4474,7 @@ sub handler { &choose_dump_server($r); return OK; } elsif ($allowed && $env{'form.verify'}) { - &init_breadcrumbs('verify','Verify Content'); + &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content'); &verifycontent($r); } elsif ($allowed && $env{'form.listsymbs'}) { &init_breadcrumbs('listsymbs','List Content IDs'); @@ -4464,10 +4487,10 @@ sub handler { } &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath); } elsif ($allowed && $env{'form.versions'}) { - &init_breadcrumbs('versions','Check/Set Resource Versions'); + &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions'); &checkversions($r); } elsif ($allowed && $env{'form.dumpcourse'}) { - &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Content to Authoring Space'); + &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space'); &dumpcourse($r); } elsif ($allowed && $env{'form.exportcourse'}) { &init_breadcrumbs('exportcourse','IMS Export'); @@ -4635,9 +4658,11 @@ sub handler { $script .= &dump_switchserver_js(@hosts); } } else { + my $tid = 1; my @tabids; if ($supplementalflag) { @tabids = ('002','ee2','ff2'); + $tid = 2; } else { @tabids = ('aa1','bb1','cc1','ff1'); unless ($env{'form.folderpath'} =~ /\:1$/) { @@ -4649,7 +4674,7 @@ sub handler { $script .= &editing_js($udom,$uname,$supplementalflag). &history_tab_js(). &inject_data_js(). - &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr). + &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid). &Apache::lonextresedit::extedit_javascript(); $addentries = { onload => "javascript:resize_scrollbox('contentscroll','1','1');", @@ -4674,6 +4699,14 @@ sub handler { if ($showdoc) { $r->print(&Apache::loncommon::start_page("$crstype documents",undef, {'force_register' => $showdoc,})); + } elsif ($toolsflag) { + &Apache::lonhtmlcommon::add_breadcrumb({ + href=>"/adm/coursedocs",text=>"$crstype Contents"}); + $r->print(&Apache::loncommon::start_page("$crstype Contents", $script) + .&Apache::loncommon::help_open_menu('','',273,'RAT') + .&Apache::lonhtmlcommon::breadcrumbs( + 'Editing Course Contents') + ); } elsif ($r->uri eq '/adm/supplemental') { my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype); $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef, @@ -4944,7 +4977,7 @@ HIDDENFORM my $newnavform=(< - + $pathitem @@ -4954,7 +4987,7 @@ HIDDENFORM NNFORM my $newsmppageform=(< - + $pathitem $lt{'sipa'} @@ -4968,7 +5001,7 @@ NSPFORM $pathitem $lt{'sipr'} - $help{'Simple Problem'} + $help{'Simple_Problem'} NSPROBFORM @@ -4995,7 +5028,7 @@ NEXUFORM my $newbulform=(< - + $pathitem $lt{'bull'} @@ -5005,7 +5038,7 @@ NBFORM my $newaboutmeform=(< - + $pathitem @@ -5016,7 +5049,7 @@ NAMFORM my $newaboutsomeoneform=(< - + $pathitem $lt{'abou'} @@ -5025,7 +5058,7 @@ NASOFORM my $newrosterform=(< - + $pathitem @@ -5046,7 +5079,7 @@ NROSTFORM } my $newwebpageform =(< - + $pathitem $lt{'webp'} @@ -5070,7 +5103,7 @@ my $newfolderb;
- + $lt{'newp'} $help{'Adding_Pages'}
@@ -5081,14 +5114,14 @@ NPFORM
$pathitem - + $lt{'newf'}$help{'Adding_Folders'}
NFFORM my $newsylform=(< - + $pathitem @@ -5100,7 +5133,7 @@ NSYLFORM my $newgroupfileform=(< - + $pathitem @@ -5217,7 +5250,7 @@ SUPDOCFORM my $supnewfolderform=(< - + $pathitem $lt{'newf'} @@ -5499,7 +5532,7 @@ sub generate_admin_menu { 'cv' => 'Check/Set Resource Versions', 'ls' => 'List Resource Identifiers', 'imse' => 'Export contents to IMS Archive', - 'dcd' => "Dump $crstype Content to Authoring Space", + 'dcd' => "Copy $crstype Content to Authoring Space", ); my ($candump,$dumpurl); if ($home + $other > 0) { @@ -5530,14 +5563,14 @@ sub generate_admin_menu { { linktext => $lt{'vc'}, url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')", permission => 'F', - help => 'Verify_Content', + help => 'Docs_Verify_Content', icon => 'verify.png', linktitle => 'Verify contents can be retrieved/rendered', }, { linktext => $lt{'cv'}, url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')", permission => 'F', - help => 'Check_Resource_Versions', + help => 'Docs_Check_Resource_Versions', icon => 'resversion.png', linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions", }, @@ -5562,7 +5595,7 @@ sub generate_admin_menu { { linktext => $lt{'dcd'}, url => $dumpurl, permission => $candump, - #help => '', + help => 'Docs_Dump_Course_Docs', icon => 'dump.png', linktitle => $lt{'dcd'}, }, @@ -5582,7 +5615,7 @@ sub generate_edit_table { my $form; my $activetab; my $active; - if (($env{'form.active'} ne '') && ($env{'form.active'} ne 'aa')) { + if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) { $activetab = $env{'form.active'}; } my $backicon = $iconpath.'clickhere.gif'; @@ -5617,7 +5650,7 @@ sub generate_edit_table { $form .= '
  • '.&mt(${$orderhash{$name}}[0]).'
  • '."\n"; } else { - $form .= '
  • '.${$orderhash{$name}}[1].'
  • '."\n"; + $form .= '
  • '.${$orderhash{$name}}[1].'
  • '."\n"; } } @@ -6180,10 +6213,12 @@ for (i = 0; i < currentLis.length; i++) function hideAll(current, nav, data) { unselectInactive(nav); -if(current.className == 'right'){ - current.className = 'right active' - }else{ - current.className = 'active'; +if (current) { + if (current.className == 'right'){ + current.className = 'right active' + } else { + current.className = 'active'; + } } currentData = document.getElementById(data); currentDivs = currentData.getElementsByTagName('DIV'); @@ -6214,10 +6249,24 @@ function openTabs(pageId) { } function showPage(current, pageId, nav, data) { + currstate = current.className; hideAll(current, nav, data); openTabs(pageId); unselectInactive(nav); - current.className = 'active'; + if ((currstate == 'active') || (currstate == 'right active')) { + if (currstate == 'active') { + current.className = ''; + } else { + current.className = 'right'; + } + activeTab = ''; + toggleUpload(); + toggleMap(); + resize_scrollbox('contentscroll','1','0'); + return; + } else { + current.className = 'active'; + } currentData = document.getElementById(pageId); currentData.style.display = 'block'; activeTab = pageId; @@ -6605,9 +6654,9 @@ ENDINJECT sub dump_switchserver_js { my @hosts = @_; my %lt = &Apache::lonlocal::texthash( - dump => 'Dumping to Authoring Space requires switching server.', + dump => 'Copying content to Authoring Space requires switching server.', swit => 'Switch server?', - duco => 'Dump content to Authoring Space', + duco => 'Copying Content to Authoring Space', yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.', chos => 'Choose server', );