--- loncom/interface/londocs.pm 2023/01/19 03:27:48 1.484.2.93.2.6 +++ loncom/interface/londocs.pm 2023/03/12 02:22:09 1.484.2.93.2.11 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.93.2.6 2023/01/19 03:27:48 raeburn Exp $ +# $Id: londocs.pm,v 1.484.2.93.2.11 2023/03/12 02:22:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -86,7 +86,7 @@ sub storemap { if ($map =~ /^default/) { $hadchanges=1; - } else { + } elsif ($contentchg) { $suppchanges=1; } return ($errtext,0); @@ -178,43 +178,62 @@ sub default_folderpath { } } -sub validate_folderpath { - my ($supplementalflag) = @_; - if ($env{'form.folderpath'} ne '') { - my @items = split(/\&/,$env{'form.folderpath'}); - my $badpath; - for (my $i=0; $i<@items; $i++) { - my $odd = $i%2; - if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) { - $badpath = 1; - } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) { - $badpath = 1; - } - last if ($badpath); - } - if ($badpath) { - delete($env{'form.folderpath'}); - } - } - return; -} - -sub validate_suppath { +sub validate_supppath { + my ($coursenum,$coursedom) = @_; + my $backto; if ($env{'form.supppath'} ne '') { my @items = split(/\&/,$env{'form.supppath'}); - my $badpath; + my ($badpath,$got_supp,$supppath,%supphidden,%suppids); for (my $i=0; $i<@items; $i++) { my $odd = $i%2; if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) { $badpath = 1; + last; + } elsif ($odd) { + my $suffix; + my $idx = $i-1; + if ($items[$i] =~ /^([^:]*)::(|1):::$/) { + $backto .= '&'.$1; + } elsif ($items[$idx] eq 'supplemental') { + $backto .= '&'.$items[$i]; + } else { + $backto .= '&'.$items[$i]; + my $is_hidden; + unless ($got_supp) { + my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom); + if (ref($supplemental) eq 'HASH') { + if (ref($supplemental->{'hidden'}) eq 'HASH') { + %supphidden = %{$supplemental->{'hidden'}}; + } + if (ref($supplemental->{'ids'}) eq 'HASH') { + %suppids = %{$supplemental->{'ids'}}; + } + } + $got_supp = 1; + } + if (ref($suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}) eq 'ARRAY') { + my $mapid = $suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}->[0]; + if ($supphidden{$mapid}) { + $is_hidden = 1; + } + } + $suffix = '::'.$is_hidden.':::'; + } + $supppath .= '&'.$items[$i].$suffix; + } else { + $supppath .= '&'.$items[$i]; + $backto .= '&'.$items[$i]; } - last if ($badpath); } if ($badpath) { delete($env{'form.supppath'}); + } else { + $supppath =~ s/^\&//; + $backto =~ s/^\&//; + $env{'form.supppath'} = $supppath; } } - return; + return $backto; } sub dumpcourse { @@ -907,7 +926,6 @@ END &storemap($coursenum, $coursedom, $folder.'.'.$container,1); unless ($fatal) { if ($folder =~ /^supplemental/) { - &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); my ($errtext,$fatal) = &mapread($coursenum,$coursedom, $folder.'.'.$container); } @@ -1140,7 +1158,13 @@ sub docs_change_log { } $r->print(''); if ($docslog{$id}{'logentry'}{'parameter_res'}) { - $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':