--- loncom/interface/londocs.pm 2009/06/05 10:51:13 1.369 +++ loncom/interface/londocs.pm 2009/11/02 12:10:34 1.410 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.369 2009/06/05 10:51:13 bisitz Exp $ +# $Id: londocs.pm,v 1.410 2009/11/02 12:10:34 wenzelju Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use Apache::Constants qw(:common :http); use Apache::imsexport; use Apache::lonnet; use Apache::loncommon; +use Apache::lonhtmlcommon; use LONCAPA::map(); use Apache::lonratedt(); use Apache::lonxml; @@ -116,15 +117,15 @@ sub authorhosts { sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); - my $type = &Apache::loncommon::course_type(); + my $crstype = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } if ($home) { - return ''. + my $link = "".&mt('Dump '.$crstype.' DOCS to Construction Space').""; + return $link.' '. &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').'
'; } else { return '
'. - &mt('Dump '.$type. + &mt('Dump '.$crstype. ' DOCS to Construction Space: available on other servers'). '
'; } @@ -140,10 +141,10 @@ sub clean { sub dumpcourse { my ($r) = @_; - my $type = &Apache::loncommon::course_type(); - $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space'). + my $crstype = &Apache::loncommon::course_type(); + $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' DOCS to Construction Space'). '
'); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' DOCS to Construction Space')); my ($home,$other,%outhash)=&authorhosts(); unless ($home) { return ''; } my $origcrsid=$env{'request.course.id'}; @@ -254,16 +255,15 @@ sub dumpcourse { $r->print(&Apache::loncommon::end_data_table()); &untiehash(); $r->print( - '

'); + '

'); } } sub exportbutton { - my $type = &Apache::loncommon::course_type(); - return ''. + my $crstype = &Apache::loncommon::course_type(); + return "".&mt('IMS Export')."". &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
'; } @@ -271,18 +271,28 @@ sub exportbutton { sub exportcourse { my $r=shift; - my $type = &Apache::loncommon::course_type(); + 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 '.lc($type).' to IMS content package'). - '

IMS Export Failed

'. - '
'. - &mt('Unable to retrieve information about course contents'). - '
'.&mt('Return to Course Editor').''); - &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'}); + $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); @@ -298,7 +308,17 @@ sub exportcourse { my @exportitems = &Apache::loncommon::get_env_multiple('form.archive'); my @discussions = &Apache::loncommon::get_env_multiple('form.discussion'); if (@exportitems == 0 && @discussions == 0) { - $outcome = '
As you did not select any content items or discussions for export, an IMS package has not been created. Please go back to select either content items or discussions for export'; + $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; @@ -321,29 +341,37 @@ sub exportcourse { open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); close(OUTPUT); chdir $cwd; - $outcome .= '

' - .&mt('Download the zip file from [_1]IMS '.lc($type).' archive[_2]' - ,'','') - .'

'; if ($copyresult) { $outcome .= '

' .&mt('The following errors occurred during export - [_1]' ,$copyresult) .'

'; } + $outcome .= '

' + .&mt('[_1]Your IMS package[_2] is ready for download.' + ,'','') + .'

'; } 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.').'
'; + $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.') + .'

' + .'

' + .&mt('Go Back') + .'

'; } } - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); + $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); $r->print($outcome); $r->print(&Apache::loncommon::end_page()); } else { my $display; $display = '
'."\n"; $display .= '

' - .&mt('Choose which items you wish to export from your '.$type.'.') + .&mt('Choose which items you wish to export from your '.$crstype.'.') .'

'; $display .= '
'. ''.&mt('Content items').''. @@ -489,13 +517,13 @@ function containerCheck(item) { // ]]> |; - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package', + $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package', $scripttag)); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); $r->print($display. '

'. '

'); + &mt('Export').'" />

'); } } @@ -980,7 +1008,7 @@ sub group_import { } sub breadcrumbs { - my ($where,$allowed,$type)=@_; + my ($allowed,$crstype)=@_; &Apache::lonhtmlcommon::clear_breadcrumbs(); my (@folders); if ($env{'form.pagepath'}) { @@ -995,6 +1023,15 @@ sub breadcrumbs { my $isencrypted=0; my $ishidden=0; my $is_random_order=0; + if (!$allowed) { + my $description = $env{'course.'.$env{'request.course.id'}.'.description'}; + &Apache::lonhtmlcommon::add_breadcrumb( + {'href' => '/adm/menu', + 'title'=> 'Go to main menu', + 'text' => $description, + }); + $plain .= $description.' >'; + } while (@folders) { my $folder=shift(@folders); my $foldername=shift(@folders); @@ -1014,11 +1051,7 @@ sub breadcrumbs { if ($3) { $isencrypted=1; } if ($4 ne '') { $is_random_order = 1; } if ($folder eq 'supplemental') { - if ($allowed) { - $name = &mt('Supplemental '.$type.' Documents'); - } else { - $name = &mt($type.' Documents'); - } + $name = &mt('Supplemental '.$crstype.' Documents'); } &Apache::lonhtmlcommon::add_breadcrumb( {'href'=>$url.$cpinfo, @@ -1030,7 +1063,7 @@ sub breadcrumbs { } $plain=~s/\>\;\s*$//; return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', - 'LC_docs_path', undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); + undef, undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); } sub log_docs { @@ -1254,10 +1287,11 @@ sub print_paste_buffer { my ($r,$container) = @_; return if (!defined($env{'docs.markedcopy_url'})); - $r->print(<

-ENDPASTE - $r->print(' '); + $r->print('

' + .''.&mt('Clipboard').'' + .'
' + .' ' + ); my $type; if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { @@ -1271,7 +1305,7 @@ ENDPASTE if ($extension eq 'sequence' && $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) { $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); - $icon .= '/folder_closed.gif'; + $icon .= '/navmap.folder.closed.gif'; } $icon = ''; $r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}))); @@ -1286,7 +1320,7 @@ ENDPASTE '); } - $r->print('

'); + $r->print('
'); } sub do_paste_from_buffer { @@ -1473,8 +1507,7 @@ sub handle_edit_cmd { } sub editor { - my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_; - + my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype)=@_; my $container= ($env{'form.pagepath'}) ? 'page' : 'sequence'; @@ -1489,9 +1522,14 @@ sub editor { $LONCAPA::map::resources[$idx]=''; } - my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)= - &breadcrumbs($folder,$allowed,$type); - $r->print($breadcrumbtrail); + my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order); + if ($allowed) { + ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = + &breadcrumbs($allowed,$crstype); + $r->print($breadcrumbtrail); + } else { + $randompick = -1; + } # ------------------------------------------------------------ Process commands @@ -1569,34 +1607,70 @@ sub editor { my $idx=0; my $shown=0; if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) { - $r->print('

'.&mt('Parameters').':

    '. - ($randompick>=0?'
  • '.&mt('randomly pick [_1] resources',$randompick).'
  • ':''). + $r->print('
    '. + '

    '.&mt('Parameters:'). + '

      '. + ($randompick>=0?'
    • '.&mt('randomly pick [quant,_1,resource]',$randompick).'
    • ':''). ($ishidden?'
    • '.&mt('contents hidden').'
    • ':''). ($isencrypted?'
    • '.&mt('URLs hidden').'
    • ':''). + ($is_random_order?'
    • '.&mt('random order').'
    • ':''). '

    '); + if ($randompick>=0) { + $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.') + .'

    ' + ); + } + $r->print('
    '); } - if ($randompick>=0) { - $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.').'

    '); - } - $r->print(''); + + my $output; foreach my $res (@LONCAPA::map::order) { - my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); - $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,$res, - $coursenum)); - $idx++; - $shown++; + my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); + $name=&LONCAPA::map::qtescape($name); + $url=&LONCAPA::map::qtescape($url); + unless ($name) { $name=(split(/\//,$url))[-1]; } + unless ($name) { $idx++; next; } + $output .= &entryline($idx,$name,$url,$folder,$allowed,$res, + $coursenum,$crstype); + $idx++; + $shown++; } - unless ($shown) { - $r->print(''); + if ($shown) { + $r->print(&Apache::loncommon::start_data_table()); + if ($allowed) { + $r->print(&Apache::loncommon::start_data_table_header_row() + .'' + .'' + .''); + if ($folder !~ /^supplemental/) { + $->print(''); + } + $r->print(&Apache::loncommon::end_data_table_header_row()); + } + $r->print($output + .&Apache::loncommon::end_data_table() + ); + } else { + $r->print('

    ' + .&mt('Currently no documents.') + .'

    ' + ); } - $r->print("\n
    '.&mt('Currently no documents.').'
    '.&mt('Move').''.&mt('Actions').''.&mt('Document').''.&mt('Settings').'
    \n"); if ($allowed) { &print_paste_buffer($r,$container); } @@ -1667,7 +1741,7 @@ sub process_file_upload { return 'failed'; } else { if ($parseaction eq 'parse') { - my $total_embedded = keys(%{$allfiles}); + my $total_embedded = scalar(keys(%{$allfiles})); if ($total_embedded > 0) { my $num = 0; my $state = ' @@ -1740,8 +1814,7 @@ sub parse_supplemental_title { # --------------------------------------------------------------- An entry line sub entryline { - my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_; - + 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); @@ -1759,7 +1832,7 @@ sub entryline { $renametitle=~s/\\/\\\\/g; $renametitle=~s/\"\;/\\\"/g; $renametitle=~s/ /%20/g; - my $line=''; + my $line=&Apache::loncommon::start_data_table_row(); my ($form_start,$form_end); # Edit commands my ($container, $type, $esc_path, $path, $symb); @@ -1790,7 +1863,7 @@ sub entryline { ne '')) { $selectbox= ''. - ''; for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) { if ($i==$incindex) { $selectbox.=''; @@ -1862,18 +1935,16 @@ END $form_end = ''; $line.=(< - - - - - - - -
    - $lt{ -
    - $lt{ -
    +
    + + $lt{ + +
    +
    + + $lt{ + +
    $form_start @@ -1900,7 +1971,7 @@ END my $pagefile; if ($uploaded) { if ($extension eq 'sequence') { - $icon=$iconpath.'/folder_closed.gif'; + $icon=$iconpath.'/navmap.folder.closed.gif'; $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/; $url='/adm/coursedocs?'; $folderarg=$1; @@ -1972,7 +2043,7 @@ END 'parameter_randomorder'))[0]=~/^yes$/i); $url.='folderpath='.&escape($folderpath).$cpinfo; $parameterset='
'); + + if ($allowed) { $r->print('
@@ -3328,40 +3472,59 @@ sub generate_admin_options { my %env = %{$env_ref}; my $dumpbut=&dumpbutton(); my $exportbut=&exportbutton(); - return (< - $help{'Verify_Content'}
- $help{'Check_Resource_Versions'}
- $dumpbut - $exportbut - -
- - -ENDOPTIONFORM + my @list = ( + {''.&mt('Verify Content').''=>"$lt{'vc'}$help{'Verify_Content'}"}, + {''.&mt('Check/Set Resource Versions').''=>"$lt{'cv'}$help{'Check_Resource_Versions'}"}, + ); + if($dumpbut ne ''){ + push @list, {''.&mt('Dump Course DOCS to Construction Space: available on other servers').''=>$dumpbut}; + } + push @list, ({''.&mt('IMS Export').''=>$exportbut}, + {''.&mt('List Symbs').''=>"$lt{'ls'}"}, + {''.&mt('Show Log').''=>"$lt{'sl'}"}, + ); + return '
'.create_form_ul(create_list_elements(@list)).'
'; } sub generate_edit_table { - my ($tid,$varcd,$orderhash_ref) = @_; + my ($tid,$orderhash_ref) = @_; + return unless(ref($orderhash_ref) eq 'HASH'); my %orderhash = %{$orderhash_ref}; my $form; - - $form = '

'.&mt($varcd).'

'; + my $activetab; + my $active; + if($env{'form.active'} ne ''){ + $activetab = $env{'form.active'}; + } + $form = '
'; $form .= ''; - $form .= '
'; + $form .= '
'; foreach my $field (keys(%orderhash)){ - if($field ne 'zz'){ - $form .= ''; + if($field ne '00'){ + if($activetab eq '' || $activetab ne $field){ + $active = 'style="display: none;"'; + }elsif($activetab eq $field){ + $active = 'style="display:block;"'; + } + $form .= '
'.${$orderhash{$field}}[1] + .'
'; } } $form .= '
'; @@ -3574,13 +3737,21 @@ function unselectInactive(nav) { currentNav = document.getElementById(nav); currentLis = currentNav.getElementsByTagName('LI'); for (i = 0; i < currentLis.length; i++) { - currentLis[i].className = 'i'; + if(currentLis[i].className == 'right active' || currentLis[i].className == 'right'){ + currentLis[i].className = 'right'; + }else{ + currentLis[i].className = 'i'; + } } } function hideAll(current, nav, data) { unselectInactive(nav); -current.className = 'active'; +if(current.className == 'right'){ + current.className = 'right active' + }else{ + current.className = 'active'; +} currentData = document.getElementById(data); currentDivs = currentData.getElementsByTagName('DIV'); for (i = 0; i < currentDivs.length; i++) { @@ -3590,8 +3761,25 @@ for (i = 0; i < currentDivs.length; i++) } } +function openTabs(pageId) { + tabnav = document.getElementById(pageId).getElementsByTagName('UL'); + if(tabnav.length > 2 ){ + currentNav = document.getElementById(tabnav[1].id); + currentLis = currentNav.getElementsByTagName('LI'); + for(i = 0; i< currentLis.length; i++){ + if(currentLis[i].className == 'active') { + funcString = currentLis[i].onclick.toString(); + tab = funcString.split('"'); + currentData = document.getElementById(tab[1]); + currentData.style.display = 'block'; + } + } + } +} + function showPage(current, pageId, nav, data) { hideAll(current, nav, data); + openTabs(pageId); unselectInactive(nav); current.className = 'active'; currentData = document.getElementById(pageId); @@ -3599,6 +3787,13 @@ function showPage(current, pageId, nav, return false; } +function injectData(current, hiddenField, name, value) { + currentElement = document.getElementById(hiddenField); + currentElement.name = name; + currentElement.value = value; + current.submit(); +} + ENDNEWSCRIPT } 1;