--- loncom/interface/loncommon.pm 2013/03/19 00:49:27 1.1075.2.32 +++ loncom/interface/loncommon.pm 2013/05/10 23:18:42 1.1075.2.35 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.32 2013/03/19 00:49:27 raeburn Exp $ +# $Id: loncommon.pm,v 1.1075.2.35 2013/05/10 23:18:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6445,6 +6445,11 @@ div.LC_edit_problem_saves { padding-bottom: 5px; } +.LC_edit_opt { + padding-left: 1em; + white-space: nowrap; +} + img.stift { border-width: 0; vertical-align: middle; @@ -6701,7 +6706,7 @@ ul#LC_secondary_menu li ul li { vertical-align: top; border-left: 1px solid black; border-right: 1px solid black; - background-color: $data_table_light + background-color: $data_table_light; list-style:none; float: none; } @@ -7786,11 +7791,9 @@ sub LCprogressbar { $LCcurrentid=$$.'_'.$LCidcnt; my $starting=&mt('Starting'); my $content=(<
$starting
-

ENDPROGBAR &r_print($r,$content.&LCprogressbar_script($LCcurrentid)); } @@ -8204,7 +8207,19 @@ sub get_sections { my %sectioncount; my $now = time; - if (!defined($possible_roles) || (grep(/^st$/,@$possible_roles))) { + my $check_students = 1; + my $only_students = 0; + if (ref($possible_roles) eq 'ARRAY') { + if (grep(/^st$/,@{$possible_roles})) { + if (@{$possible_roles} == 1) { + $only_students = 1; + } + } else { + $check_students = 0; + } + } + + if ($check_students) { my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum); my $sec_index = &Apache::loncoursedata::CL_SECTION(); my $status_index = &Apache::loncoursedata::CL_STATUS(); @@ -8231,6 +8246,9 @@ sub get_sections { } } } + if ($only_students) { + return %sectioncount; + } my %courseroles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); foreach my $user (sort(keys(%courseroles))) { if ($user !~ /^(\w{2})/) { next; } @@ -9514,18 +9532,23 @@ sub ask_for_embedded_content { my $heading = &mt('Upload embedded files'); my $buttontext = &mt('Upload'); - my $navmap; + my ($navmap,$cdom,$cnum); if ($env{'request.course.id'}) { - $navmap = Apache::lonnavmaps::navmap->new(); + if ($actionurl eq '/adm/dependencies') { + $navmap = Apache::lonnavmaps::navmap->new(); + } + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; } - if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { + if (($actionurl eq '/adm/portfolio') || + ($actionurl eq '/adm/coursegrp_portfolio')) { my $current_path='/'; if ($env{'form.currentpath'}) { $current_path = $env{'form.currentpath'}; } if ($actionurl eq '/adm/coursegrp_portfolio') { - $udom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $uname = $env{'course.'.$env{'request.course.id'}.'.num'}; + $udom = $cdom; + $uname = $cnum; $url = '/userfiles/groups/'.$env{'form.group'}.'/portfolio'; } else { $udom = $env{'user.domain'}; @@ -9557,24 +9580,43 @@ sub ask_for_embedded_content { } } elsif ($actionurl eq '/adm/dependencies') { if ($env{'request.course.id'} ne '') { - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; if (ref($args) eq 'HASH') { $url = $args->{'docs_url'}; $title = $args->{'docs_title'}; - $toplevel = "/$url"; + $toplevel = $url; + unless ($toplevel =~ m{^/}) { + $toplevel = "/$url"; + } ($rem) = ($toplevel =~ m{^(.+/)[^/]+$}); - ($path) = - ($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); + if ($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/portfolio/syllabus\E)}) { + $path = $1; + } else { + ($path) = + ($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); + } $fileloc = &Apache::lonnet::filelocation('',$toplevel); $fileloc =~ s{^/}{}; ($filename) = ($fileloc =~ m{.+/([^/]+)$}); $heading = &mt('Status of dependencies in [_1]',"$title ($filename)"); } } + } elsif ($actionurl eq "/public/$cdom/$cnum/syllabus") { + $udom = $cdom; + $uname = $cnum; + $url = "/uploaded/$cdom/$cnum/portfolio/syllabus"; + $toplevel = $url; + $path = $url; + $fileloc = &Apache::lonnet::filelocation('',$toplevel).'/'; + $fileloc =~ s{^/}{}; + } } - my $now = time(); - foreach my $embed_file (keys(%{$allfiles})) { + foreach my $file (keys(%{$allfiles})) { + my $embed_file; + if (($path eq "/uploaded/$cdom/$cnum/portfolio/syllabus") && ($file =~ m{^\Q$path/\E(.+)$})) { + $embed_file = $1; + } else { + $embed_file = $file; + } my $absolutepath; if ($embed_file =~ m{^\w+://}) { $newfiles{$embed_file} = 1; @@ -9612,7 +9654,8 @@ sub ask_for_embedded_content { my $dirptr = 16384; foreach my $path (keys(%subdependencies)) { $currsubfile{$path} = {}; - if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { + if (($actionurl eq '/adm/portfolio') || + ($actionurl eq '/adm/coursegrp_portfolio')) { my ($sublistref,$listerror) = &Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath); if (ref($sublistref) eq 'ARRAY') { @@ -9628,9 +9671,15 @@ sub ask_for_embedded_content { } } elsif (($actionurl eq '/adm/dependencies') || (($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && - ($args->{'context'} eq 'paste'))) { + ($args->{'context'} eq 'paste')) || + ($actionurl eq "/public/$cdom/$cnum/syllabus")) { if ($env{'request.course.id'} ne '') { - my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); + my $dir; + if ($actionurl eq "/public/$cdom/$cnum/syllabus") { + $dir = $fileloc; + } else { + ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); + } if ($dir ne '') { my ($sublistref,$listerror) = &Apache::lonnet::dirlist($dir.$path,$cdom,$cnum,$getpropath,undef,'/'); @@ -9678,7 +9727,8 @@ sub ask_for_embedded_content { } } my %currfile; - if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { + if (($actionurl eq '/adm/portfolio') || + ($actionurl eq '/adm/coursegrp_portfolio')) { my ($dirlistref,$listerror) = &Apache::lonnet::dirlist($url,$udom,$uname,$getpropath); if (ref($dirlistref) eq 'ARRAY') { @@ -9694,7 +9744,8 @@ sub ask_for_embedded_content { } } elsif (($actionurl eq '/adm/dependencies') || (($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && - ($args->{'context'} eq 'paste'))) { + ($args->{'context'} eq 'paste')) || + ($actionurl eq "/public/$cdom/$cnum/syllabus")) { if ($env{'request.course.id'} ne '') { my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); if ($dir ne '') { @@ -9729,12 +9780,14 @@ sub ask_for_embedded_content { ($file eq $filename.'.bak') || ($dependencies{$file})) { if ($actionurl eq '/adm/dependencies') { - next if (($rem ne '') && - (($env{"httpref.$rem".$file} ne '') || - (ref($navmap) && - (($navmap->getResourceByUrl($rem.$file) ne '') || - (($file =~ /^(.*\.s?html?)\.bak$/i) && - ($navmap->getResourceByUrl($rem.$1))))))); + unless ($toplevel =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus\E}) { + next if (($rem ne '') && + (($env{"httpref.$rem".$file} ne '') || + (ref($navmap) && + (($navmap->getResourceByUrl($rem.$file) ne '') || + (($file =~ /^(.*\.s?html?)\.bak$/i) && + ($navmap->getResourceByUrl($rem.$1))))))); + } } $unused{$file} = 1; } @@ -9744,27 +9797,37 @@ sub ask_for_embedded_content { $counter = scalar(keys(%existing)); $numpathchg = scalar(keys(%pathchanges)); return ($output,$counter,$numpathchg,\%existing); + } elsif (($actionurl eq "/public/$cdom/$cnum/syllabus") && + (ref($args) eq 'HASH') && ($args->{'context'} eq 'rewrites')) { + $counter = scalar(keys(%existing)); + $numpathchg = scalar(keys(%pathchanges)); + return ($output,$counter,$numpathchg,\%existing,\%mapping); } foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%newfiles)) { if ($actionurl eq '/adm/dependencies') { next if ($embed_file =~ m{^\w+://}); } $upload_output .= &start_data_table_row(). - ' '. + ' '. ''.$embed_file.''; unless ($mapping{$embed_file} eq $embed_file) { - $upload_output .= '
'.&mt('changed from: [_1]',$mapping{$embed_file}).''; + $upload_output .= '
'. + &mt('changed from: [_1]',$mapping{$embed_file}).''; } - $upload_output .= ''; + $upload_output .= ''; if ($args->{'ignore_remote_references'} && $embed_file =~ m{^\w+://}) { - $upload_output.=''.&mt("URL points to other server.").''; + $upload_output.=''. + ''. + &mt("URL points to web address").''; $numremref++; } elsif ($args->{'error_on_invalid_names'} && $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) { - $upload_output.=''.&mt('Invalid characters').''; + $upload_output.=''. + &mt('Invalid characters').''; $numinvalid++; } else { - $upload_output .= &embedded_file_element('upload_embedded',$counter, + $upload_output .= ''. + &embedded_file_element('upload_embedded',$counter, $embed_file,\%mapping, $allfiles,$codebase,'upload'); $counter ++; @@ -9793,8 +9856,9 @@ sub ask_for_embedded_content { $counter ++; } else { $upload_output .= &start_data_table_row(). - ''.$embed_file.''; - ''.&mt('Already exists').''. + ' '. + ''.$embed_file.''. + ''.&mt('Already exists').''. &Apache::loncommon::end_data_table_row()."\n"; } } @@ -9889,7 +9953,7 @@ sub ask_for_embedded_content { $output = ''.&mt('Referenced files').':
'; if ($applies > 1) { $output .= - &mt('No files need to be uploaded, as one of the following applies to each reference:').'