version 1.484.2.79, 2019/04/11 16:32:33
|
version 1.650, 2018/01/12 01:54:56
|
Line 43 use Apache::lonnavdisplay();
|
Line 43 use Apache::lonnavdisplay();
|
use Apache::lonextresedit(); |
use Apache::lonextresedit(); |
use Apache::lontemplate(); |
use Apache::lontemplate(); |
use Apache::lonsimplepage(); |
use Apache::lonsimplepage(); |
|
use Apache::lonhomework(); |
|
use Apache::lonpublisher(); |
|
use Apache::lonparmset(); |
use HTML::Entities; |
use HTML::Entities; |
use HTML::TokeParser; |
use HTML::TokeParser; |
use GDBM_File; |
use GDBM_File; |
use File::MMagic; |
use File::MMagic; |
|
use File::Copy; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Cwd; |
use Cwd; |
|
use UUID::Tiny ':std'; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
my $iconpath; |
my $iconpath; |
Line 232 ENDJS
|
Line 237 ENDJS
|
} else { |
} else { |
&Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles, |
&Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles, |
'dumpdocs',$cdom,$cnum); |
'dumpdocs',$cdom,$cnum); |
} |
} |
my @todump = &Apache::loncommon::get_env_multiple('form.archive'); |
my @todump = &Apache::loncommon::get_env_multiple('form.archive'); |
my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages, |
my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages, |
%newcontent,%has_simpleprobs); |
%newcontent,%has_simpleprobs); |
Line 243 ENDJS
|
Line 248 ENDJS
|
if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) { |
if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) { |
$tocopy{$1} = $name; |
$tocopy{$1} = $name; |
$display{$item} = $1; |
$display{$item} = $1; |
$lookup{$1} = $item; |
$lookup{$1} = $item; |
} elsif ($res eq 'lib/templates/simpleproblem.problem') { |
} elsif ($res eq 'lib/templates/simpleproblem.problem') { |
$simpleproblems{$item} = { |
$simpleproblems{$item} = { |
symb => $resources{$item}, |
symb => $resources{$item}, |
Line 343 $contents{content}.'
|
Line 348 $contents{content}.'
|
</div>'; |
</div>'; |
} |
} |
if ($contents{webreferences}) { |
if ($contents{webreferences}) { |
$content .= ' |
$content .= ' |
<div class="LC_Box"> |
<div class="LC_Box"> |
<h4 class="LC_hcell">'.&mt('Web References').'</h4>'. |
<h4 class="LC_hcell">'.&mt('Web References').'</h4>'. |
$contents{webreferences}.' |
$contents{webreferences}.' |
Line 353 $contents{webreferences}.'
|
Line 358 $contents{webreferences}.'
|
</body> |
</body> |
</html> |
</html> |
'; |
'; |
$newcontent{'/'.$simplepages{$item}{res}} = $content; |
$newcontent{'/'.$simplepages{$item}{res}} = $content; |
} |
} |
} |
} |
foreach my $item (keys(%tocopy)) { |
foreach my $item (keys(%tocopy)) { |
unless ($item=~/\.(sequence|page)$/) { |
unless ($item=~/\.(sequence|page)$/) { |
my $currurlpath = $prefix.$item; |
my $currurlpath = $prefix.$item; |
my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath); |
my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath); |
Line 387 $contents{webreferences}.'
|
Line 392 $contents{webreferences}.'
|
if ($simpleproblems{$num}) { |
if ($simpleproblems{$num}) { |
$newfilename=$title.'/'.$simpleproblems{$num}{'name'}; |
$newfilename=$title.'/'.$simpleproblems{$num}{'name'}; |
} else { |
} else { |
$newfilename=$title.'/'.$replacehash{$item}; |
$newfilename=$title.'/'.$replacehash{$item}; |
} |
} |
$newfilename=~s/\.(\w+)$//; |
$newfilename=~s/\.(\w+)$//; |
my $ext=$1; |
my $ext=$1; |
$newfilename=&clean($newfilename); |
$newfilename=&clean($newfilename); |
$newfilename.='.'.$ext; |
$newfilename.='.'.$ext; |
my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); |
my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); |
if ($newrelpath ne $replacehash{$item}) { |
if ($newrelpath ne $replacehash{$item}) { |
$replacehash{$item} = $newrelpath; |
$replacehash{$item} = $newrelpath; |
} |
} |
my @dirs=split(/\//,$newfilename); |
my @dirs=split(/\//,$newfilename); |
my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; |
my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; |
my $makepath=$path; |
my $makepath=$path; |
my $fail; |
my $fail; |
my $origin; |
my $origin; |
for (my $i=0;$i<$#dirs;$i++) { |
for (my $i=0;$i<$#dirs;$i++) { |
$makepath.='/'.$dirs[$i]; |
$makepath.='/'.$dirs[$i]; |
unless (-e $makepath) { |
unless (-e $makepath) { |
unless(mkdir($makepath,0755)) { |
unless(mkdir($makepath,0755)) { |
$fail = &mt('Directory creation failed.'); |
$fail = &mt('Directory creation failed.'); |
} |
} |
} |
} |
} |
} |
if ($i == 0) { |
if ($i == 0) { |
$result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: '; |
$result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: '; |
} else { |
} else { |
$depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '. |
$depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '. |
'<span class="LC_fontsize_small" style="font-weight: bold;">'. |
'<span class="LC_fontsize_small" style="font-weight: bold;">'. |
&mt('(dependency)').'</span>: '; |
&mt('(dependency)').'</span>: '; |
} |
} |
if (-e $path.'/'.$newfilename) { |
if (-e $path.'/'.$newfilename) { |
$fail = &mt('Destination already exists -- not overwriting.'); |
$fail = &mt('Destination already exists -- not overwriting.'); |
} else { |
} else { |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) || |
if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) || |
($item =~ /^simpleproblem_/)) { |
($item =~ /^simpleproblem_/)) { |
Line 441 $contents{webreferences}.'
|
Line 446 $contents{webreferences}.'
|
while (my $token = $parser->get_token) { |
while (my $token = $parser->get_token) { |
if ($token->[0] eq 'S') { |
if ($token->[0] eq 'S') { |
if (($token->[1] eq 'resource') && |
if (($token->[1] eq 'resource') && |
($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && |
($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && |
($changes{$token->[2]->{'id'}})) { |
($changes{$token->[2]->{'id'}})) { |
my $id = $token->[2]->{'id'}; |
my $id = $token->[2]->{'id'}; |
$updatedcontent .= '<'.$token->[1]; |
$updatedcontent .= '<'.$token->[1]; |
foreach my $attrib (@{$token->[3]}) { |
foreach my $attrib (@{$token->[3]}) { |
next unless ($attrib =~ /^(src|type|title|id)$/); |
next unless ($attrib =~ /^(src|type|title|id)$/); |
if ($attrib eq 'src') { |
if ($attrib eq 'src') { |
my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); |
my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); |
if ($file) { |
if ($file) { |
$updatedcontent .= ' '.$attrib.'="'.$file.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$file.'"'; |
} else { |
} else { |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
} |
} |
} else { |
} else { |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
Line 467 $contents{webreferences}.'
|
Line 472 $contents{webreferences}.'
|
} |
} |
} |
} |
print $fh $updatedcontent; |
print $fh $updatedcontent; |
} else { |
} else { |
print $fh &Apache::lonclonecourse::rewritefile( |
print $fh &Apache::lonclonecourse::rewritefile( |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item), |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item), |
(%replacehash,$crs => '') |
(%replacehash,$crs => '') |
); |
); |
} |
} |
} else { |
} else { |
print $fh |
print $fh |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item); |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item); |
} |
} |
} else { |
} else { |
$fail = &mt('Source does not exist.'); |
$fail = &mt('Source does not exist.'); |
} |
} |
} |
} |
$fh->close(); |
$fh->close(); |
} else { |
} else { |
$fail = &mt('Could not write to destination.'); |
$fail = &mt('Could not write to destination.'); |
} |
} |
} |
} |
my $text; |
my $text; |
if ($fail) { |
if ($fail) { |
$text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>'; |
$text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>'; |
} else { |
} else { |
$text = '<span class="LC_success">'.&mt('ok').'</span>'; |
$text = '<span class="LC_success">'.&mt('ok').'</span>'; |
} |
} |
if ($i == 0) { |
if ($i == 0) { |
$result .= $text; |
$result .= $text; |
} else { |
} else { |
$depresult .= $text.'</li>'; |
$depresult .= $text.'</li>'; |
} |
} |
} |
} |
$r->print($result); |
$r->print($result); |
if ($depresult) { |
if ($depresult) { |
Line 513 $contents{webreferences}.'
|
Line 518 $contents{webreferences}.'
|
$r->rflush(); |
$r->rflush(); |
my ($preamble,$formname); |
my ($preamble,$formname); |
$formname = 'dumpdoc'; |
$formname = 'dumpdoc'; |
unless ($home==1) { |
unless ($home==1) { |
$preamble = '<div class="LC_left_float">'. |
$preamble = '<div class="LC_left_float">'. |
'<fieldset><legend>'. |
'<fieldset><legend>'. |
&mt('Select the Authoring Space'). |
&mt('Select the Authoring Space'). |
'</legend><select name="authorspace">'; |
'</legend><select name="authorspace">'; |
} |
} |
my @orderspaces = (); |
my @orderspaces = (); |
foreach my $key (sort(keys(%outhash))) { |
foreach my $key (sort(keys(%outhash))) { |
if ($key=~/^home_(.+)$/) { |
if ($key=~/^home_(.+)$/) { |
if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) { |
if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) { |
unshift(@orderspaces,$1); |
unshift(@orderspaces,$1); |
} else { |
} else { |
push(@orderspaces,$1); |
push(@orderspaces,$1); |
} |
} |
} |
} |
} |
} |
if ($home>1) { |
if ($home>1) { |
$preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>'; |
$preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>'; |
} |
} |
foreach my $user (@orderspaces) { |
foreach my $user (@orderspaces) { |
if ($home==1) { |
if ($home==1) { |
$preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />'; |
$preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />'; |
} else { |
} else { |
$preamble .= '<option value="'.$user.'">'.$user.' - '. |
$preamble .= '<option value="'.$user.'">'.$user.' - '. |
&Apache::loncommon::plainname(split(/\:/,$user)).'</option>'; |
&Apache::loncommon::plainname(split(/\:/,$user)).'</option>'; |
} |
} |
} |
} |
unless ($home==1) { |
unless ($home==1) { |
$preamble .= '</select></fieldset></div>'."\n"; |
$preamble .= '</select></fieldset></div>'."\n"; |
} |
} |
my $title=$origcrsdata{'description'}; |
my $title=$origcrsdata{'description'}; |
$title=~s/[\/\s]+/\_/gs; |
$title=~s/[\/\s]+/\_/gs; |
$title=&clean($title); |
$title=&clean($title); |
$preamble .= '<div class="LC_left_float">'. |
$preamble .= '<div class="LC_left_float">'. |
'<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'. |
'<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'. |
'<input type="text" size="50" name="authorfolder" value="'. |
'<input type="text" size="50" name="authorfolder" value="'. |
$title.'" />'. |
$title.'" />'. |
'</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n"; |
'</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n"; |
my %uploadedfiles; |
my %uploadedfiles; |
&tiehash(); |
&tiehash(); |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { |
my ($ext)=($file=~/\.(\w+)$/); |
my ($ext)=($file=~/\.(\w+)$/); |
# FIXME Check supplemental here |
# FIXME Check supplemental here |
my $title=$hash{'title_'.$hash{ |
my $title=$hash{'title_'.$hash{ |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; |
if (!$title) { |
if (!$title) { |
$title=$file; |
$title=$file; |
} else { |
} else { |
$title=~s|/|_|g; |
$title=~s|/|_|g; |
} |
} |
$title=~s/\.(\w+)$//; |
$title=~s/\.(\w+)$//; |
$title=&clean($title); |
$title=&clean($title); |
$title.='.'.$ext; |
$title.='.'.$ext; |
# $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>" |
# $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>" |
$uploadedfiles{$file} = $title; |
$uploadedfiles{$file} = $title; |
} |
} |
&untiehash(); |
&untiehash(); |
$r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef, |
$r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef, |
undef,undef,$preamble,$home,\%uploadedfiles)); |
undef,undef,$preamble,$home,\%uploadedfiles)); |
} |
} |
Line 600 sub recurse_html {
|
Line 605 sub recurse_html {
|
} else { |
} else { |
$relfile = $dependency; |
$relfile = $dependency; |
$depurl = $currurlpath; |
$depurl = $currurlpath; |
$depurl =~ s{[^/]+$}{}; |
$depurl =~ s{[^/]+$}{}; |
$depurl .= $dependency; |
$depurl .= $dependency; |
($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); |
($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); |
} |
} |
Line 609 sub recurse_html {
|
Line 614 sub recurse_html {
|
$newname =~ s{[^/]+$}{}; |
$newname =~ s{[^/]+$}{}; |
$replacehash->{$newcontainer} = $newname.$relfile; |
$replacehash->{$newcontainer} = $newname.$relfile; |
$deps->{$item}{$newcontainer} = 1; |
$deps->{$item}{$newcontainer} = 1; |
my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$}); |
my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$}); |
my $depfile = &Apache::lonnet::filelocation('',$depurl); |
my $depfile = &Apache::lonnet::filelocation('',$depurl); |
my $type = $mm->checktype_filename($depfile); |
my $type = $mm->checktype_filename($depfile); |
if ($type eq 'text/html') { |
if ($type eq 'text/html') { |
Line 622 sub recurse_html {
|
Line 627 sub recurse_html {
|
} |
} |
|
|
sub group_import { |
sub group_import { |
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; |
my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_; |
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap, |
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap, |
%removeparam,$importuploaded,$fixuperrors); |
%removeparam,$importuploaded,$fixuperrors); |
$allmaps = {}; |
$allmaps = {}; |
Line 651 sub group_import {
|
Line 656 sub group_import {
|
} |
} |
} |
} |
if ($url) { |
if ($url) { |
|
if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) { |
|
$url = $1; |
|
my $marker = $2; |
|
my $info = $3; |
|
my ($toolid,%toolhash,%toolsettings); |
|
my @extras = ('linktext','explanation','crslabel','crstitle','crsappend'); |
|
my @toolinfo = split(/:/,$info); |
|
if ($residx) { |
|
%toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); |
|
$toolid = $toolsettings{'id'}; |
|
} else { |
|
$toolid = shift(@toolinfo); |
|
} |
|
$toolid =~ s/\D//g; |
|
($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}, |
|
$toolhash{'linktext'},$toolhash{'explanation'},$toolhash{'crslabel'}, |
|
$toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}) = @toolinfo; |
|
foreach my $item (@extras) { |
|
$toolhash{$item} = &unescape($toolhash{$item}); |
|
} |
|
if ($folder =~ /^supplemental/) { |
|
delete($toolhash{'gradable'}); |
|
} else { |
|
$toolhash{'gradable'} =~ s/\D+//g; |
|
} |
|
if (ref($ltitoolsref) eq 'HASH') { |
|
if (ref($ltitoolsref->{$toolid}) eq 'HASH') { |
|
my @deleted; |
|
$toolhash{'id'} = $toolid; |
|
if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') || |
|
($toolhash{'target'} eq 'window')) { |
|
if ($toolhash{'target'} eq 'window') { |
|
foreach my $item ('width','height') { |
|
$toolhash{$item} =~ s/^\s+//; |
|
$toolhash{$item} =~ s/\s+$//; |
|
if ($toolhash{$item} =~ /\D/) { |
|
delete($toolhash{$item}); |
|
if ($residx) { |
|
if ($toolsettings{$item}) { |
|
push(@deleted,$item); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($residx) { |
|
$toolhash{'target'} = $toolsettings{'target'}; |
|
if ($toolhash{'target'} eq 'window') { |
|
foreach my $item ('width','height') { |
|
$toolhash{$item} = $toolsettings{$item}; |
|
} |
|
} |
|
} elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') { |
|
$toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'}; |
|
if ($toolhash{'target'} eq 'window') { |
|
$toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'}; |
|
$toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'}; |
|
} |
|
} |
|
if ($toolhash{'target'} eq 'iframe') { |
|
foreach my $item ('width','height','linktext','explanation') { |
|
delete($toolhash{$item}); |
|
if ($residx) { |
|
if ($toolsettings{$item}) { |
|
push(@deleted,$item); |
|
} |
|
} |
|
} |
|
} elsif ($toolhash{'target'} eq 'tab') { |
|
foreach my $item ('width','height') { |
|
delete($toolhash{$item}); |
|
if ($residx) { |
|
if ($toolsettings{$item}) { |
|
push(@deleted,$item); |
|
} |
|
} |
|
} |
|
} |
|
if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') { |
|
foreach my $item ('label','title','linktext','explanation') { |
|
my $crsitem; |
|
if (($item eq 'label') || ($item eq 'title')) { |
|
$crsitem = 'crs'.$item; |
|
} else { |
|
$crsitem = $item; |
|
} |
|
if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) { |
|
$toolhash{$crsitem} =~ s/^\s+//; |
|
$toolhash{$crsitem} =~ s/\s+$//; |
|
if ($toolhash{$crsitem} eq '') { |
|
delete($toolhash{$crsitem}); |
|
} |
|
} else { |
|
delete($toolhash{$crsitem}); |
|
} |
|
if (($residx) && (exists($toolsettings{$crsitem}))) { |
|
unless (exists($toolhash{$crsitem})) { |
|
push(@deleted,$crsitem); |
|
} |
|
} |
|
} |
|
} |
|
if ($toolhash{'passback'}) { |
|
my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4); |
|
$toolhash{'gradesecret'} = $gradesecret; |
|
$toolhash{'gradesecretdate'} = time; |
|
} |
|
if ($toolhash{'roster'}) { |
|
my $rostersecret = UUID::Tiny::create_uuid_as_string(UUID_V4); |
|
$toolhash{'rostersecret'} = $rostersecret; |
|
$toolhash{'rostersecretdate'} = time; |
|
} |
|
my $changegradable; |
|
if (($residx) && ($folder =~ /^default/)) { |
|
if ($toolsettings{'gradable'}) { |
|
unless (($toolhash{'gradable'}) || (defined($LONCAPA::map::zombies[$residx]))) { |
|
push(@deleted,'gradable'); |
|
$changegradable = 1; |
|
} |
|
} elsif ($toolhash{'gradable'}) { |
|
$changegradable = 1; |
|
} |
|
if (($caller eq 'londocs') && (defined($LONCAPA::map::zombies[$residx]))) { |
|
$changegradable = 1; |
|
if ($toolsettings{'gradable'}) { |
|
$toolhash{'gradable'} = 1; |
|
} |
|
} |
|
} |
|
my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum); |
|
if ($putres eq 'ok') { |
|
if (@deleted) { |
|
&Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum); |
|
} |
|
if (($changegradable) && ($folder =~ /^default/)) { |
|
my $val; |
|
if ($toolhash{'gradable'}) { |
|
$val = 'yes'; |
|
} else { |
|
$val = 'no'; |
|
} |
|
&LONCAPA::map::storeparameter($residx,'parameter_0_gradable',$val, |
|
'string_yesno'); |
|
&remember_parms($residx,'gradable','set',$val); |
|
} |
|
} else { |
|
return (&mt('Failed to save update to external tool.'),1); |
|
} |
|
} |
|
} |
|
} |
if (($caller eq 'londocs') && |
if (($caller eq 'londocs') && |
($folder =~ /^default/)) { |
($folder =~ /^default/)) { |
if (($url =~ /\.(page|sequence)$/) && (!$donechk)) { |
if (($url =~ /\.(page|sequence)$/) && (!$donechk)) { |
Line 662 sub group_import {
|
Line 818 sub group_import {
|
$donechk = 1; |
$donechk = 1; |
} |
} |
if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) { |
if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) { |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam, |
&contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap, |
\%addedmaps,\%hierarchy,\%titles,$allmaps); |
\%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps); |
$importuploaded = 1; |
$importuploaded = 1; |
} elsif ($url =~ m{^/res/.+\.(page|sequence)$}) { |
} elsif ($url =~ m{^/res/.+\.(page|sequence)$}) { |
next if ($allmaps->{$url}); |
next if ($allmaps->{$url}); |
Line 728 END
|
Line 884 END
|
removefrommap => \%removefrommap, |
removefrommap => \%removefrommap, |
removeparam => \%removeparam, |
removeparam => \%removeparam, |
); |
); |
my ($result,$msgsarray,$lockerror) = |
my ($result,$msgsarray,$lockerror) = |
&apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); |
&apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); |
if (keys(%import_errors) > 0) { |
if (keys(%import_errors) > 0) { |
$fixuperrors = |
$fixuperrors = |
Line 829 sub log_docs {
|
Line 985 sub log_docs {
|
sub docs_change_log { |
sub docs_change_log { |
my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_; |
my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_; |
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
my $navmap; |
my $navmap; |
my $js = '<script type="text/javascript">'."\n". |
my $js = '<script type="text/javascript">'."\n". |
'// <![CDATA['."\n". |
'// <![CDATA['."\n". |
&Apache::loncommon::display_filter_js('docslog')."\n". |
&Apache::loncommon::display_filter_js('docslog')."\n". |
&editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag, |
&editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag, |
$coursedom,$coursenum,$canedit,\$navmap)."\n". |
$coursedom,$coursenum,'','',$canedit,'',\$navmap)."\n". |
&history_tab_js()."\n". |
&history_tab_js()."\n". |
&Apache::lonratedt::editscript('simple')."\n". |
&Apache::lonratedt::editscript('simple')."\n". |
'// ]]>'."\n". |
'// ]]>'."\n". |
Line 862 sub docs_change_log {
|
Line 1018 sub docs_change_log {
|
if ($supplementalflag) { |
if ($supplementalflag) { |
$tid = 2; |
$tid = 2; |
} |
} |
my ($breadcrumbtrail) = |
my ($breadcrumbtrail) = |
&Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1); |
&Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1); |
$r->print($breadcrumbtrail. |
$r->print($breadcrumbtrail. |
&generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto, |
&generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto, |
Line 884 sub docs_change_log {
|
Line 1040 sub docs_change_log {
|
'encrypturl' => 'URL hidden', |
'encrypturl' => 'URL hidden', |
'randompick' => 'Randomly pick', |
'randompick' => 'Randomly pick', |
'randomorder' => 'Randomly ordered', |
'randomorder' => 'Randomly ordered', |
|
'gradable' => 'Grade can be assigned to External Tool', |
'set' => 'set to', |
'set' => 'set to', |
'del' => 'deleted'); |
'del' => 'deleted'); |
my $filter = &Apache::loncommon::display_filter('docslog')."\n". |
my $filter = &Apache::loncommon::display_filter('docslog')."\n". |
Line 991 sub docs_change_log {
|
Line 1148 sub docs_change_log {
|
$r->print('</ul>'); |
$r->print('</ul>'); |
if ($docslog{$id}{'logentry'}{'parameter_res'}) { |
if ($docslog{$id}{'logentry'}{'parameter_res'}) { |
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>'); |
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>'); |
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') { |
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder','gradable') { |
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) { |
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) { |
# FIXME: internationalization seems wrong here |
# FIXME: internationalization seems wrong here |
$r->print('<li>'. |
$r->print('<li>'. |
Line 1061 sub update_paste_buffer {
|
Line 1218 sub update_paste_buffer {
|
foreach my $suffix (@currpaste) { |
foreach my $suffix (@currpaste) { |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
|
my $mapidx = $env{'docs.markedcopy_map_'.$suffix}; |
if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && |
if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && |
($url ne '')) { |
($url ne '')) { |
$pasteurls{$cid.'_'.$url} = 1; |
$pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1; |
} |
} |
} |
} |
} |
} |
|
|
# Mark items for copying (skip any items already in user's paste buffer) |
# Mark items for copying (skip any items already in user's paste buffer) |
my %addtoenv; |
my %addtoenv; |
|
|
|
my @pathitems = split(/\&/,$env{'form.folderpath'}); |
|
my @folderconf = split(/\:/,$pathitems[-1]); |
|
my $ispage = $folderconf[4]; |
|
|
foreach my $item (@possibles) { |
foreach my $item (@possibles) { |
my ($orderidx,$cmd) = split(/:/,$item); |
my ($orderidx,$cmd) = split(/:/,$item); |
next if ($orderidx =~ /\D/); |
next if ($orderidx =~ /\D/); |
next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove')); |
next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove')); |
|
my $mapidx = $folder.':'.$orderidx.':'.$ispage; |
my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]); |
my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]); |
my %denied = &action_restrictions($coursenum,$coursedom, |
my %denied = &action_restrictions($coursenum,$coursedom, |
&LONCAPA::map::qtescape($url), |
&LONCAPA::map::qtescape($url), |
$env{'form.folderpath'},\%curr_groups); |
$env{'form.folderpath'},\%curr_groups); |
next if ($denied{'copy'}); |
next if ($denied{'copy'}); |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url})); |
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx})); |
my ($suffix,$errortxt,$locknotfreed) = |
my ($suffix,$errortxt,$locknotfreed) = |
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); |
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); |
if ($suffix ne '') { |
if ($suffix ne '') { |
Line 1100 sub update_paste_buffer {
|
Line 1263 sub update_paste_buffer {
|
$addtoenv{'docs.markedcopy_url_'.$suffix} = $url, |
$addtoenv{'docs.markedcopy_url_'.$suffix} = $url, |
$addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd, |
$addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd, |
$addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'}; |
$addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'}; |
|
$addtoenv{'docs.markedcopy_map_'.$suffix} = $mapidx; |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { |
my $prefix = $1; |
my $prefix = $1; |
my $subdir =$2; |
my $subdir =$2; |
Line 1108 sub update_paste_buffer {
|
Line 1271 sub update_paste_buffer {
|
$subdir = $prefix; |
$subdir = $prefix; |
} |
} |
my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps); |
my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps); |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps, |
&contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap, |
\%hierarchy,\%titles,\%allmaps); |
\%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps); |
if (ref($hierarchy{$url}) eq 'HASH') { |
if (ref($hierarchy{$url}) eq 'HASH') { |
my ($nested,$nestednames); |
my ($nested,$nestednames); |
&recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames); |
&recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames); |
Line 1178 sub print_paste_buffer {
|
Line 1341 sub print_paste_buffer {
|
next if ($suffix =~ /\D/); |
next if ($suffix =~ /\D/); |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
|
my $mapidx = $env{'docs.markedcopy_map_'.$suffix}; |
if (($cid =~ /^$match_domain\_$match_courseid$/) && |
if (($cid =~ /^$match_domain\_$match_courseid$/) && |
($url ne '')) { |
($url ne '')) { |
$clipboardcount ++; |
$clipboardcount ++; |
my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent, |
my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent, |
$canpaste,$nopaste,$othercrs,$areachange); |
$canpaste,$nopaste,$othercrs,$areachange,$is_exttool); |
my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1]; |
my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1]; |
if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
$is_external = 1; |
$is_external = 1; |
|
} elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) { |
|
$is_exttool = 1; |
} |
} |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
$canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix}); |
$canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix}); |
Line 1217 sub print_paste_buffer {
|
Line 1383 sub print_paste_buffer {
|
} |
} |
$is_uploaded_map = 1; |
$is_uploaded_map = 1; |
} |
} |
} elsif ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg)$}) { |
} elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) || |
|
($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) { |
if ($cid ne $env{'request.course.id'}) { |
if ($cid ne $env{'request.course.id'}) { |
my ($srcdom,$srcnum) = split(/_/,$cid); |
my ($srcdom,$srcnum) = split(/_/,$cid); |
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
$othercrs = '<br />'.&mt('(from another course)'); |
if (($is_exttool) && ($srcdom ne $coursedom)) { |
|
$canpaste = 0; |
|
$nopaste = &mt('Paste from another domain unavailable.'); |
|
} else { |
|
$othercrs = '<br />'.&mt('(from another course)'); |
|
} |
} else { |
} else { |
$canpaste = 0; |
$canpaste = 0; |
$nopaste = &mt('Paste from another course unavailable.'); |
$nopaste = &mt('Paste from another course unavailable.'); |
Line 1237 sub print_paste_buffer {
|
Line 1409 sub print_paste_buffer {
|
$buffer = &mt('External Resource').': '. |
$buffer = &mt('External Resource').': '. |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('. |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('. |
&LONCAPA::map::qtescape($url).')'; |
&LONCAPA::map::qtescape($url).')'; |
|
} elsif ($is_exttool) { |
|
$buffer = &mt('External Tool').': '. |
|
&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}); |
} else { |
} else { |
my $icon = &Apache::loncommon::icon($extension); |
my $icon = &Apache::loncommon::icon($extension); |
if ($extension eq 'sequence' && |
if ($extension eq 'sequence' && |
Line 1289 sub print_paste_buffer {
|
Line 1464 sub print_paste_buffer {
|
my $value = &mt('Paste to current folder'); |
my $value = &mt('Paste to current folder'); |
if ($container eq 'page') { |
if ($container eq 'page') { |
$value = &mt('Paste to current page'); |
$value = &mt('Paste to current page'); |
} |
} |
$buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2); |
$buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2); |
} |
} |
$buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Clear selected').'" />'.(' 'x2); |
$buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2); |
if ($clipboardcount > 1) { |
if ($clipboardcount > 1) { |
$buttons .= |
$buttons .= |
'<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2). |
'<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2). |
Line 1393 sub supp_pasteable {
|
Line 1568 sub supp_pasteable {
|
(($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) || |
(($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) || |
($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) || |
($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) || |
($url =~ m{^/adm/$match_domain/$match_username/aboutme}) || |
($url =~ m{^/adm/$match_domain/$match_username/aboutme}) || |
($url =~ m{^/public/$match_domain/$match_courseid/syllabus})) { |
($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) || |
|
($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) { |
return 1; |
return 1; |
} |
} |
return; |
return; |
Line 1465 function checkClipboard() {
|
Line 1641 function checkClipboard() {
|
if (document.pasteform.pasting.length > 1) { |
if (document.pasteform.pasting.length > 1) { |
for (var i=0; i<document.pasteform.pasting.length; i++) { |
for (var i=0; i<document.pasteform.pasting.length; i++) { |
document.pasteform.pasting[i].checked = true; |
document.pasteform.pasting[i].checked = true; |
} |
} |
} |
} |
return; |
return; |
} |
} |
Line 1515 sub do_paste_from_buffer {
|
Line 1691 sub do_paste_from_buffer {
|
return(); |
return(); |
} |
} |
|
|
my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate, |
my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate, |
%prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult); |
%prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult); |
|
|
foreach my $suffix (@topaste) { |
foreach my $suffix (@topaste) { |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
|
my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix}); |
# Supplemental content may only include certain types of content |
# Supplemental content may only include certain types of content |
# Early out if pasted content is not supported in Supplemental area |
# Early out if pasted content is not supported in Supplemental area |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
Line 1542 sub do_paste_from_buffer {
|
Line 1719 sub do_paste_from_buffer {
|
} |
} |
$srcdom{$suffix} = $srcd; |
$srcdom{$suffix} = $srcd; |
$srcnum{$suffix} = $srcn; |
$srcnum{$suffix} = $srcn; |
} elsif ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) { |
} elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) || |
|
($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) || |
|
($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) { |
my ($srcd,$srcn) = split(/_/,$cid); |
my ($srcd,$srcn) = split(/_/,$cid); |
# When paste buffer was populated using an active role in a different course |
# When paste buffer was populated using an active role in a different course |
# check for mdc privilege in the course from which the resource was pasted |
# check for mdc privilege in the course from which the resource was pasted |
Line 1552 sub do_paste_from_buffer {
|
Line 1731 sub do_paste_from_buffer {
|
next; |
next; |
} |
} |
} |
} |
|
# When buffer was populated using an active role in a different course |
|
# disallow pasting of External Tool if course is in a different domain. |
|
if (($url =~ m{/ext\.tool$}) && ($srcd ne $coursedom)) { |
|
$notindom{$suffix} = 1; |
|
next; |
|
} |
$srcdom{$suffix} = $srcd; |
$srcdom{$suffix} = $srcd; |
$srcnum{$suffix} = $srcn; |
$srcnum{$suffix} = $srcn; |
} |
} |
|
$srcmapidx{$suffix} = $mapidx; |
push(@dopaste,$suffix); |
push(@dopaste,$suffix); |
if ($url=~/\.(page|sequence)$/) { |
if ($url=~/\.(page|sequence)$/) { |
$is_map{$suffix} = 1; |
$is_map{$suffix} = 1; |
} |
} |
|
|
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) { |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) { |
my $oldprefix = $1; |
my $oldprefix = $1; |
# When pasting content from Main Content to Supplemental Content and vice versa |
# When pasting content from Main Content to Supplemental Content and vice versa |
# URLs will contain different paths (which depend on whether pasted item is |
# URLs will contain different paths (which depend on whether pasted item is |
# a folder/page or a document. |
# a folder/page or a document). |
if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) { |
if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) { |
$prefixchg{$suffix} = 'docstosupp'; |
$prefixchg{$suffix} = 'docstosupp'; |
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
Line 1604 sub do_paste_from_buffer {
|
Line 1789 sub do_paste_from_buffer {
|
%msgs = &Apache::lonlocal::texthash ( |
%msgs = &Apache::lonlocal::texthash ( |
notinsupp => 'Paste failed: content type is not supported within Supplemental Content', |
notinsupp => 'Paste failed: content type is not supported within Supplemental Content', |
notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.', |
notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.', |
|
notindom => 'Paste failed: Item is an external tool from a course in a different donain.', |
duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.', |
duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.', |
); |
); |
|
|
Line 1632 sub do_paste_from_buffer {
|
Line 1818 sub do_paste_from_buffer {
|
# Retrieve information about all course maps in main content area |
# Retrieve information about all course maps in main content area |
|
|
my $allmaps = {}; |
my $allmaps = {}; |
my (@toclear,%mapurls,%lockerrs,%msgerrs,%results,$donechk); |
if ($folder =~ /^default/) { |
|
$allmaps = |
|
&Apache::loncommon::allmaps_incourse($coursedom,$coursenum, |
|
$env{"course.$env{'request.course.id'}.home"}, |
|
$env{'request.course.id'}); |
|
} |
|
|
|
my (@toclear,%mapurls,%lockerrs,%msgerrs,%results); |
|
|
# Loop over the items to paste |
# Loop over the items to paste |
foreach my $suffix (@dopaste) { |
foreach my $suffix (@dopaste) { |
# Maps need to be copied first |
# Maps need to be copied first |
my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies, |
my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies, |
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir, |
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir, |
%newurls,%tomove); |
%newurls,%tomove,%resdatacopy); |
if (ref($marktomove{$suffix}) eq 'ARRAY') { |
if (ref($marktomove{$suffix}) eq 'ARRAY') { |
map { $tomove{$_} = 1; } @{$marktomove{$suffix}}; |
map { $tomove{$_} = 1; } @{$marktomove{$suffix}}; |
} |
} |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}); |
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
my $oldurl = $url; |
my $oldurl = $url; |
if ($is_map{$suffix}) { |
if ($is_map{$suffix}) { |
# If pasting a map, check if map contains other maps |
# If pasting a map, check if map contains other maps |
my (%hierarchy,%titles); |
my (%hierarchy,%titles); |
if (($folder =~ /^default/) && (!$donechk)) { |
&contained_map_check($url,$folder,$coursenum,$coursedom, |
$allmaps = |
\%removefrommap,\%removeparam,\%addedmaps, |
&Apache::loncommon::allmaps_incourse($coursedom,$coursenum, |
\%hierarchy,\%titles,$allmaps); |
$env{"course.$env{'request.course.id'}.home"}, |
|
$env{'request.course.id'}); |
|
$donechk = 1; |
|
} |
|
&contained_map_check($url,$folder,\%removefrommap,\%removeparam, |
|
\%addedmaps,\%hierarchy,\%titles,$allmaps); |
|
if ($url=~ m{^/uploaded/}) { |
if ($url=~ m{^/uploaded/}) { |
my $newurl; |
my $newurl; |
unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') { |
unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') { |
Line 1688 sub do_paste_from_buffer {
|
Line 1875 sub do_paste_from_buffer {
|
\%retitles,\%copies,\%dbcopies, |
\%retitles,\%copies,\%dbcopies, |
\%zombies,\%params,\%mapmoves, |
\%zombies,\%params,\%mapmoves, |
\%mapchanges,\%tomove,\%newsubdir, |
\%mapchanges,\%tomove,\%newsubdir, |
\%newurls)) { |
\%newurls,\%resdatacopy)) { |
$mapmoves{$url} = 1; |
$mapmoves{$url} = 1; |
} |
} |
$url = $newurl; |
$url = $newurl; |
Line 1697 sub do_paste_from_buffer {
|
Line 1884 sub do_paste_from_buffer {
|
$coursenum,$srcdom{$suffix},$srcnum{$suffix}, |
$coursenum,$srcdom{$suffix},$srcnum{$suffix}, |
$allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
$allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
\%zombies,\%params,\%mapmoves,\%mapchanges, |
\%zombies,\%params,\%mapmoves,\%mapchanges, |
\%tomove,\%newsubdir,\%newurls); |
\%tomove,\%newsubdir,\%newurls,\%resdatacopy); |
} |
} |
} elsif ($url=~m {^/res/}) { |
} elsif ($url=~m {^/res/}) { |
# published map can only exists once, so remove from paste buffer when done |
# published map can only exist once, so remove from paste buffer when done |
push(@toclear,$suffix); |
push(@toclear,$suffix); |
# if pasting published map (main content area only) check map not already in course |
# if pasting published map (main content area only) check map not already in course |
if ($folder =~ /^default/) { |
if ($folder =~ /^default/) { |
Line 1711 sub do_paste_from_buffer {
|
Line 1898 sub do_paste_from_buffer {
|
} |
} |
} |
} |
} |
} |
if ($url=~ m{/(bulletinboard|smppg)$}) { |
if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) { |
my $prefix = $1; |
my $prefix = $1; |
my $fromothercrs; |
my $fromothercrs; |
#need to copy the db contents to a new one, unless this is a move. |
#need to copy the db contents to a new one, unless this is a move. |
Line 1720 sub do_paste_from_buffer {
|
Line 1907 sub do_paste_from_buffer {
|
cdom => $coursedom, |
cdom => $coursedom, |
cnum => $coursenum, |
cnum => $coursenum, |
); |
); |
|
if ($prefix eq 'ext.tool') { |
|
if ($prefixchg{$suffix} eq 'docstosupp') { |
|
$info{'delgradable'} = 1; |
|
} |
|
} |
if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) { |
if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) { |
unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) { |
unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) { |
$fromothercrs = 1; |
$fromothercrs = 1; |
Line 1728 sub do_paste_from_buffer {
|
Line 1920 sub do_paste_from_buffer {
|
} |
} |
} |
} |
unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) { |
unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) { |
my (%lockerr,$msg); |
my (%lockerr,$msg); |
my ($newurl,$result,$errtext) = |
my ($newurl,$result,$errtext) = |
&dbcopy(\%info,$coursedom,$coursenum,\%lockerr); |
&dbcopy(\%info,$coursedom,$coursenum,\%lockerr); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
Line 1739 sub do_paste_from_buffer {
|
Line 1931 sub do_paste_from_buffer {
|
$msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext; |
$msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext; |
} elsif ($prefix eq 'bulletinboard') { |
} elsif ($prefix eq 'bulletinboard') { |
$msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext; |
$msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext; |
|
} elsif ($prefix eq 'ext.tool') { |
|
$msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext; |
} |
} |
$results{$suffix} = $result; |
$results{$suffix} = $result; |
$msgerrs{$suffix} = $msg; |
$msgerrs{$suffix} = $msg; |
Line 1746 sub do_paste_from_buffer {
|
Line 1940 sub do_paste_from_buffer {
|
next; |
next; |
} |
} |
if ($lockerr{$prefix}) { |
if ($lockerr{$prefix}) { |
$lockerrs{$suffix} = $lockerr{$prefix}; |
$lockerrs{$suffix} = $lockerr{$prefix}; |
} |
} |
} |
} |
} |
} |
Line 1786 sub do_paste_from_buffer {
|
Line 1980 sub do_paste_from_buffer {
|
$newdocsdir = 'default'; |
$newdocsdir = 'default'; |
} |
} |
if (($prefixchg{$suffix}) || |
if (($prefixchg{$suffix}) || |
($srcdom{$suffix} ne $coursedom) || |
($srcdom{$suffix} ne $coursedom) || |
($srcnum{$suffix} ne $coursenum) || |
($srcnum{$suffix} ne $coursenum) || |
($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) { |
($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) { |
my $newpath = "$newprefix/$newdocsdir/$newidx/$rem"; |
my $newpath = "$newprefix/$newdocsdir/$newidx/$rem"; |
Line 1803 sub do_paste_from_buffer {
|
Line 1997 sub do_paste_from_buffer {
|
} |
} |
} |
} |
} |
} |
|
} elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) { |
|
my $template = $1; |
|
if ($newidx) { |
|
©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix}, |
|
$coursedom,$coursenum,$template,$newidx,"$folder.$container"); |
|
} |
|
} elsif ($url =~ /ext\.tool$/) { |
|
if (($newidx) && ($folder=~/^default/)) { |
|
my $marker = (split(m{/},$url))[4]; |
|
my %toolsettings = &Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); |
|
my $val = 'no'; |
|
if ($toolsettings{'gradable'}) { |
|
$val = 'yes'; |
|
} |
|
&LONCAPA::map::storeparameter($newidx,'parameter_0_gradable',$val, |
|
'string_yesno'); |
|
&remember_parms($newidx,'gradable','set',$val); |
|
} |
} |
} |
$LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url). |
$LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url). |
':'.$ext.':normal:res'; |
':'.$ext.':normal:res'; |
Line 1816 sub do_paste_from_buffer {
|
Line 2028 sub do_paste_from_buffer {
|
} |
} |
} |
} |
|
|
# Apply any changes to maps, or copy dependencies for uploaded HTML pages |
# Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update |
|
# resourcedata for simpleproblems copied from another course |
unless ($allresult eq 'fail') { |
unless ($allresult eq 'fail') { |
my %updated = ( |
my %updated = ( |
rewrites => \%rewrites, |
rewrites => \%rewrites, |
Line 1824 sub do_paste_from_buffer {
|
Line 2037 sub do_paste_from_buffer {
|
removefrommap => \%removefrommap, |
removefrommap => \%removefrommap, |
removeparam => \%removeparam, |
removeparam => \%removeparam, |
dbcopies => \%dbcopies, |
dbcopies => \%dbcopies, |
|
resdatacopy => \%resdatacopy, |
retitles => \%retitles, |
retitles => \%retitles, |
); |
); |
my %info = ( |
my %info = ( |
Line 1990 sub dbcopy {
|
Line 2204 sub dbcopy {
|
my ($url,$result,$errtext); |
my ($url,$result,$errtext); |
if (ref($dbref) eq 'HASH') { |
if (ref($dbref) eq 'HASH') { |
$url = $dbref->{'src'}; |
$url = $dbref->{'src'}; |
if ($url =~ m{/(smppg|bulletinboard)$}) { |
if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) { |
my $prefix = $1; |
my $prefix = $1; |
if (($dbref->{'cdom'} =~ /^$match_domain$/) && |
if ($prefix eq 'ext.tool') { |
|
$prefix = 'exttool'; |
|
} |
|
if (($dbref->{'cdom'} =~ /^$match_domain$/) && |
($dbref->{'cnum'} =~ /^$match_courseid$/)) { |
($dbref->{'cnum'} =~ /^$match_courseid$/)) { |
my $db_name; |
my $db_name; |
my $marker = (split(m{/},$url))[4]; |
my $marker = (split(m{/},$url))[4]; |
Line 2002 sub dbcopy {
|
Line 2219 sub dbcopy {
|
&Apache::lonsimplepage::get_db_name($url,$marker, |
&Apache::lonsimplepage::get_db_name($url,$marker, |
$dbref->{'cdom'}, |
$dbref->{'cdom'}, |
$dbref->{'cnum'}); |
$dbref->{'cnum'}); |
|
} elsif ($dbref->{'src'} =~ m{/ext\.tool$}) { |
|
$db_name = 'exttool_'.$marker; |
} else { |
} else { |
$db_name = 'bulletinpage_'.$marker; |
$db_name = 'bulletinpage_'.$marker; |
} |
} |
Line 2012 sub dbcopy {
|
Line 2231 sub dbcopy {
|
if (!$suffix) { |
if (!$suffix) { |
if ($prefix eq 'smppg') { |
if ($prefix eq 'smppg') { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url); |
|
} elsif ($prefix eq 'exttool') { |
|
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url); |
} else { |
} else { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url); |
} |
} |
Line 2032 sub dbcopy {
|
Line 2253 sub dbcopy {
|
my $content = &Apache::lonnet::getfile($photo); |
my $content = &Apache::lonnet::getfile($photo); |
unless ($content eq '-1') { |
unless ($content eq '-1') { |
$env{'form.'.$suffix.'.photourl'} = $content; |
$env{'form.'.$suffix.'.photourl'} = $content; |
$newphoto = |
$newphoto = |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname"); |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname"); |
delete($env{'form.'.$suffix.'.photourl'}); |
delete($env{'form.'.$suffix.'.photourl'}); |
} |
} |
Line 2042 sub dbcopy {
|
Line 2263 sub dbcopy {
|
} |
} |
} |
} |
$db_name =~ s{_\d*$ }{_$suffix}x; |
$db_name =~ s{_\d*$ }{_$suffix}x; |
|
if (($prefix eq 'exttool') && ($dbref->{'delgradable'}) && ($contents{'gradable'})) { |
|
delete($contents{'gradable'}); |
|
} |
$result=&Apache::lonnet::put($db_name,\%contents, |
$result=&Apache::lonnet::put($db_name,\%contents, |
$coursedom,$coursenum); |
$coursedom,$coursenum); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$url =~ s{/(\d*)/(smppg|bulletinboard)$}{/$suffix/$2}x; |
$url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x; |
} |
} |
} |
} |
if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) { |
if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) { |
Line 2055 sub dbcopy {
|
Line 2279 sub dbcopy {
|
if ($prefix eq 'smppg') { |
if ($prefix eq 'smppg') { |
$lockerrorsref->{$prefix} .= |
$lockerrorsref->{$prefix} .= |
' '.&mt('This will prevent creation of additional simple pages in this course.'); |
' '.&mt('This will prevent creation of additional simple pages in this course.'); |
|
} elsif ($prefix eq 'exttool') { |
|
$lockerrorsref->{$prefix} .= |
|
' '.&mt('This will prevent addition of more external tools to this course.'); |
} else { |
} else { |
$lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.'); |
$lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.'); |
} |
} |
Line 2080 sub dbcopy {
|
Line 2307 sub dbcopy {
|
return ($url,$result,$errtext); |
return ($url,$result,$errtext); |
} |
} |
|
|
|
sub copy_templated_files { |
|
my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_; |
|
my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo); |
|
my $srccontainer = 'sequence'; |
|
if ($srcwaspage) { |
|
$srccontainer = 'page'; |
|
} |
|
my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer". |
|
'___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl); |
|
my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb; |
|
my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix); |
|
my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'. |
|
$template.'.problem'; |
|
my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb; |
|
if ($template eq 'simpleproblem') { |
|
$srcprefix .= '.0.'; |
|
my $weightprefix = $newprefix; |
|
$newprefix .= '.0.'; |
|
my @simpleprobqtypes = qw(radio option string essay numerical); |
|
my $qtype=$srcparms{$srcprefix.'questiontype'}; |
|
if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) { |
|
my %newdata; |
|
foreach my $type (@simpleprobqtypes) { |
|
if ($type eq $qtype) { |
|
$newdata{"$weightprefix.$type.weight"}=1; |
|
} else { |
|
$newdata{"$weightprefix.$type.weight"}=0; |
|
} |
|
} |
|
$newdata{$newprefix.'hiddenparts'} = '!'.$qtype; |
|
$newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'}; |
|
$newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'}; |
|
if ($qtype eq 'numerical') { |
|
$newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'}; |
|
$newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'}; |
|
$newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'}; |
|
$newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'}; |
|
} elsif (($qtype eq 'option') || ($qtype eq 'radio')) { |
|
my $maxfoils=$srcparms{$srcprefix.'maxfoils'}; |
|
unless (defined($maxfoils)) { $maxfoils=10; } |
|
unless ($maxfoils=~/^\d+$/) { $maxfoils=10; } |
|
if ($maxfoils<=0) { $maxfoils=10; } |
|
my $randomize=$srcparms{$srcprefix.'randomize'}; |
|
unless (defined($randomize)) { $randomize='yes'; } |
|
unless ($randomize eq 'no') { $randomize='yes'; } |
|
$newdata{$newprefix.'maxfoils'} = $maxfoils; |
|
$newdata{$newprefix.'randomize'} = $randomize; |
|
if ($qtype eq 'option') { |
|
$newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'}; |
|
} |
|
for (my $i=1; $i<=10; $i++) { |
|
$newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i}; |
|
$newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i}; |
|
$newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i}; |
|
} |
|
|
|
} elsif (($qtype eq 'option') || ($qtype eq 'radio')) { |
|
my $maxfoils=$srcparms{$srcprefix.'maxfoils'}; |
|
unless (defined($maxfoils)) { $maxfoils=10; } |
|
unless ($maxfoils=~/^\d+$/) { $maxfoils=10; } |
|
if ($maxfoils<=0) { $maxfoils=10; } |
|
my $randomize=$srcparms{$srcprefix.'randomize'}; |
|
unless (defined($randomize)) { $randomize='yes'; } |
|
unless ($randomize eq 'no') { $randomize='yes'; } |
|
$newdata{$newprefix.'maxfoils'} = $maxfoils; |
|
$newdata{$newprefix.'randomize'} = $randomize; |
|
if ($qtype eq 'option') { |
|
$newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'}; |
|
} |
|
for (my $i=1; $i<=10; $i++) { |
|
$newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i}; |
|
$newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i}; |
|
$newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i}; |
|
} |
|
} elsif ($qtype eq 'string') { |
|
$newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'}; |
|
$newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'}; |
|
} |
|
if (keys(%newdata)) { |
|
my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom, |
|
$coursenum); |
|
if ($putres eq 'ok') { |
|
&Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
sub uniqueness_check { |
sub uniqueness_check { |
my ($newurl) = @_; |
my ($newurl) = @_; |
my $unique = 1; |
my $unique = 1; |
Line 2095 sub uniqueness_check {
|
Line 2411 sub uniqueness_check {
|
} |
} |
|
|
sub contained_map_check { |
sub contained_map_check { |
my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles, |
my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps, |
$allmaps) = @_; |
$hierarchy,$titles,$allmaps) = @_; |
my $content = &Apache::lonnet::getfile($url); |
my $content = &Apache::lonnet::getfile($url); |
unless ($content eq '-1') { |
unless ($content eq '-1') { |
my $parser = HTML::TokeParser->new(\$content); |
my $parser = HTML::TokeParser->new(\$content); |
Line 2106 sub contained_map_check {
|
Line 2422 sub contained_map_check {
|
if ($token->[1] eq 'resource') { |
if ($token->[1] eq 'resource') { |
next if ($token->[2]->{'type'} eq 'zombie'); |
next if ($token->[2]->{'type'} eq 'zombie'); |
my $ressrc = $token->[2]->{'src'}; |
my $ressrc = $token->[2]->{'src'}; |
if ($folder =~ /^supplemental/) { |
if ($ressrc =~ m{^/adm/($match_domain)/$match_courseid/\d+/ext\.tool$}) { |
|
my $srcdom = $1; |
|
unless ($srcdom eq $coursedom) { |
|
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
|
next; |
|
} |
|
} elsif ($folder =~ /^supplemental/) { |
unless (&supp_pasteable($ressrc)) { |
unless (&supp_pasteable($ressrc)) { |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
next; |
next; |
Line 2125 sub contained_map_check {
|
Line 2447 sub contained_map_check {
|
$addedmaps->{$ressrc} = [$url]; |
$addedmaps->{$ressrc} = [$url]; |
} |
} |
} |
} |
&contained_map_check($ressrc,$folder,$removefrommap,$removeparam, |
&contained_map_check($ressrc,$folder,$coursenum,$coursedom,$removefrommap, |
$addedmaps,$hierarchy,$titles,$allmaps); |
$removeparam,$addedmaps,$hierarchy,$titles,$allmaps); |
} |
} |
} elsif ($token->[1] eq 'param') { |
} elsif ($token->[1] eq 'param') { |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
Line 2145 sub contained_map_check {
|
Line 2467 sub contained_map_check {
|
sub url_paste_fixups { |
sub url_paste_fixups { |
my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps, |
my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps, |
$rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves, |
$rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves, |
$mapchanges,$tomove,$newsubdir,$newurls) = @_; |
$mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_; |
my $checktitle; |
my $checktitle; |
if (($prefixchg) && |
if (($prefixchg) && |
($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) { |
($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) { |
Line 2177 sub url_paste_fixups {
|
Line 2499 sub url_paste_fixups {
|
} |
} |
next if ($token->[2]->{'type'} eq 'external'); |
next if ($token->[2]->{'type'} eq 'external'); |
if ($token->[2]->{'type'} eq 'zombie') { |
if ($token->[2]->{'type'} eq 'zombie') { |
next if ($skip); |
next if ($skip); |
$zombies->{$oldurl}{$id} = $ressrc; |
$zombies->{$oldurl}{$id} = $ressrc; |
$changed = 1; |
$changed = 1; |
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
Line 2194 sub url_paste_fixups {
|
Line 2516 sub url_paste_fixups {
|
$srcdom,$srcnum,$allmaps,$rewrites, |
$srcdom,$srcnum,$allmaps,$rewrites, |
$retitles,$copies,$dbcopies,$zombies, |
$retitles,$copies,$dbcopies,$zombies, |
$params,$mapmoves,$mapchanges,$tomove, |
$params,$mapmoves,$mapchanges,$tomove, |
$newsubdir,$newurls); |
$newsubdir,$newurls,$resdatacopy); |
next; |
next; |
} else { |
} else { |
($newurl,my $error) = |
($newurl,my $error) = |
Line 2218 sub url_paste_fixups {
|
Line 2540 sub url_paste_fixups {
|
$cnum,$srcdom,$srcnum,$allmaps, |
$cnum,$srcdom,$srcnum,$allmaps, |
$rewrites,$retitles,$copies,$dbcopies, |
$rewrites,$retitles,$copies,$dbcopies, |
$zombies,$params,$mapmoves,$mapchanges, |
$zombies,$params,$mapmoves,$mapchanges, |
$tomove,$newsubdir,$newurls)) { |
$tomove,$newsubdir,$newurls,$resdatacopy)) { |
$mapmoves->{$ressrc} = 1; |
$mapmoves->{$ressrc} = 1; |
} |
} |
$changed = 1; |
$changed = 1; |
Line 2228 sub url_paste_fixups {
|
Line 2550 sub url_paste_fixups {
|
$changed = 1; |
$changed = 1; |
} |
} |
} |
} |
} elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) { |
} elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) { |
next if ($skip); |
next if ($skip); |
my $srcdom = $1; |
my $srcdom = $1; |
my $srcnum = $2; |
my $srcnum = $2; |
|
my $rem = $3; |
|
my ($is_exttool,$exttoolchg); |
|
if ($rem =~ m{\d+/ext\.tool$}) { |
|
$is_exttool = 1; |
|
} |
if (($srcdom ne $cdom) || ($srcnum ne $cnum)) { |
if (($srcdom ne $cdom) || ($srcnum ne $cnum)) { |
$rewrites->{$oldurl}{$id} = $ressrc; |
$rewrites->{$oldurl}{$id} = $ressrc; |
$dbcopies->{$oldurl}{$id}{'src'} = $ressrc; |
$dbcopies->{$oldurl}{$id}{'src'} = $ressrc; |
$dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom; |
$dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom; |
$dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum; |
$dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum; |
$changed = 1; |
$changed = 1; |
|
if ($is_exttool) { |
|
$exttoolchg = 1; |
|
} |
|
} elsif (($rem =~ m{\d+/ext\.tool$}) && |
|
($env{'form.docs.markedcopy_options'} ne 'move')) { |
|
$dbcopies->{$oldurl}{$id}{'src'} = $ressrc; |
|
$dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom; |
|
$dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum; |
|
$changed = 1; |
|
$exttoolchg = 1; |
|
} |
|
if (($is_exttool) && ($prefixchg)) { |
|
if ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/default}) { |
|
if ($exttoolchg) { |
|
$dbcopies->{$oldurl}{$id}{'delgradable'} = 1; |
|
} |
|
} |
} |
} |
} elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) { |
} elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) { |
if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) || |
if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) || |
Line 2247 sub url_paste_fixups {
|
Line 2591 sub url_paste_fixups {
|
$dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum; |
$dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum; |
$changed = 1; |
$changed = 1; |
} |
} |
|
} elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') { |
|
if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) { |
|
$resdatacopy->{$oldurl}{$id}{'src'} = $ressrc; |
|
$resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom; |
|
$resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum; |
|
} |
} elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) { |
} elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) { |
next if ($skip); |
next if ($skip); |
my $srcdom = $1; |
my $srcdom = $1; |
Line 2278 sub apply_fixups {
|
Line 2628 sub apply_fixups {
|
$oldurl,$url,$caller) = @_; |
$oldurl,$url,$caller) = @_; |
my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles, |
my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles, |
%params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs, |
%params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs, |
%lockerrors,$lockmsg); |
%resdatacopy,%lockerrors,$lockmsg); |
if (ref($updated) eq 'HASH') { |
if (ref($updated) eq 'HASH') { |
if (ref($updated->{'rewrites'}) eq 'HASH') { |
if (ref($updated->{'rewrites'}) eq 'HASH') { |
%rewrites = %{$updated->{'rewrites'}}; |
%rewrites = %{$updated->{'rewrites'}}; |
Line 2298 sub apply_fixups {
|
Line 2648 sub apply_fixups {
|
if (ref($updated->{'retitles'}) eq 'HASH') { |
if (ref($updated->{'retitles'}) eq 'HASH') { |
%retitles = %{$updated->{'retitles'}}; |
%retitles = %{$updated->{'retitles'}}; |
} |
} |
|
if (ref($updated->{'resdatacopy'}) eq 'HASH') { |
|
%resdatacopy = %{$updated->{'resdatacopy'}}; |
|
} |
} |
} |
if (ref($info) eq 'HASH') { |
if (ref($info) eq 'HASH') { |
if (ref($info->{'newsubdir'}) eq 'HASH') { |
if (ref($info->{'newsubdir'}) eq 'HASH') { |
Line 2448 sub apply_fixups {
|
Line 2801 sub apply_fixups {
|
} |
} |
} |
} |
} |
} |
|
if (ref($resdatacopy{$key}) eq 'HASH') { |
|
if ($newsubdir{$key}) { |
|
|
|
} |
|
foreach my $idx (keys(%{$resdatacopy{$key}})) { |
|
if (ref($resdatacopy{$key}{$idx}) eq 'HASH') { |
|
my $srcurl = $resdatacopy{$key}{$idx}{'src'}; |
|
if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) { |
|
my $template = $1; |
|
if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) && |
|
($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) { |
|
my $srcdom = $resdatacopy{$key}{$idx}{'cdom'}; |
|
my $srcnum = $resdatacopy{$key}{$idx}{'cnum'}; |
|
my ($newmapname) = ($key =~ m{/([^/]+)$}); |
|
my ($srcfolder,$srccontainer) = split(/\./,$newmapname); |
|
my $srcmapinfo = $srcfolder.':'.$idx; |
|
if ($srccontainer eq 'page') { |
|
$srcmapinfo .= ':1'; |
|
} |
|
if ($newsubdir{$key}) { |
|
$newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/; |
|
} |
|
©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom, |
|
$cnum,$template,$idx,$newmapname); |
|
} |
|
} |
|
} |
|
} |
|
} |
if (ref($params{$key}) eq 'HASH') { |
if (ref($params{$key}) eq 'HASH') { |
%currparam = %{$params{$key}}; |
%currparam = %{$params{$key}}; |
} |
} |
Line 2651 sub update_parameter {
|
Line 3033 sub update_parameter {
|
foreach my $which (keys(%allchecked)) { |
foreach my $which (keys(%allchecked)) { |
if (($which eq 'randompick' || $which eq 'randomorder')) { |
if (($which eq 'randompick' || $which eq 'randomorder')) { |
next if (!$is_map); |
next if (!$is_map); |
} |
} |
my $oldvalue = 0; |
my $oldvalue = 0; |
my $newvalue = 0; |
my $newvalue = 0; |
if ($allchecked{$which}{$res}) { |
if ($allchecked{$which}{$res}) { |
Line 2703 sub update_parameter {
|
Line 3085 sub update_parameter {
|
$oldvalue = 1; |
$oldvalue = 1; |
} |
} |
if ($env{'form.'.$which.'_'.$idx}) { |
if ($env{'form.'.$which.'_'.$idx}) { |
$newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx} |
$newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx} |
: 1; |
: 1; |
} |
} |
if ($oldvalue ne $newvalue) { |
if ($oldvalue ne $newvalue) { |
$haschanges = 1; |
$haschanges = 1; |
Line 2713 sub update_parameter {
|
Line 3095 sub update_parameter {
|
if ($which eq 'randompick') { |
if ($which eq 'randompick') { |
$storeval = $newvalue; |
$storeval = $newvalue; |
} |
} |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval, |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval, |
$parameter_type{$which}); |
$parameter_type{$which}); |
&remember_parms($idx,$which,'set',$storeval); |
&remember_parms($idx,$which,'set',$storeval); |
} else { |
} else { |
&LONCAPA::map::delparameter($idx,'parameter_'.$which); |
&LONCAPA::map::delparameter($idx,'parameter_'.$which); |
&remember_parms($idx,$which,'del'); |
&remember_parms($idx,$which,'del'); |
} |
} |
} |
} |
return $haschanges; |
return $haschanges; |
} |
} |
return; |
|
} |
} |
|
|
sub handle_edit_cmd { |
sub handle_edit_cmd { |
my ($coursenum,$coursedom) =@_; |
my ($coursenum,$coursedom) =@_; |
|
my $haschanges = 0; |
if ($env{'form.cmd'} eq '') { |
if ($env{'form.cmd'} eq '') { |
return 0; |
return $haschanges; |
} |
} |
my ($cmd,$idx)=split('_',$env{'form.cmd'}); |
my ($cmd,$idx)=split('_',$env{'form.cmd'}); |
|
|
Line 2744 sub handle_edit_cmd {
|
Line 3126 sub handle_edit_cmd {
|
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
} |
} |
splice(@LONCAPA::map::order, $idx, 1); |
splice(@LONCAPA::map::order, $idx, 1); |
|
$haschanges = 1; |
} elsif ($cmd eq 'cut') { |
} elsif ($cmd eq 'cut') { |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
splice(@LONCAPA::map::order, $idx, 1); |
splice(@LONCAPA::map::order, $idx, 1); |
|
$haschanges = 1; |
} elsif ($cmd eq 'up' |
} elsif ($cmd eq 'up' |
&& ($idx) && (defined($LONCAPA::map::order[$idx-1]))) { |
&& ($idx) && (defined($LONCAPA::map::order[$idx-1]))) { |
@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1]; |
@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1]; |
|
$haschanges = 1; |
} elsif ($cmd eq 'down' |
} elsif ($cmd eq 'down' |
&& defined($LONCAPA::map::order[$idx+1])) { |
&& defined($LONCAPA::map::order[$idx+1])) { |
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1]; |
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1]; |
|
$haschanges = 1; |
} elsif ($cmd eq 'rename') { |
} elsif ($cmd eq 'rename') { |
my $comment = &LONCAPA::map::qtunescape($env{'form.title'}); |
my $comment = &LONCAPA::map::qtunescape($env{'form.title'}); |
if ($comment=~/\S/) { |
if ($comment=~/\S/) { |
Line 2766 sub handle_edit_cmd {
|
Line 3148 sub handle_edit_cmd {
|
# Devalidate title cache |
# Devalidate title cache |
my $renamed_url=&LONCAPA::map::qtescape($url); |
my $renamed_url=&LONCAPA::map::qtescape($url); |
&Apache::lonnet::devalidate_title_cache($renamed_url); |
&Apache::lonnet::devalidate_title_cache($renamed_url); |
|
$haschanges = 1; |
} else { |
} elsif ($cmd eq 'setalias') { |
return 0; |
my $newvalue = $env{'form.alias'}; |
|
if ($newvalue ne '') { |
|
unless (Apache::lonnet::get_symb_from_alias($newvalue)) { |
|
&LONCAPA::map::storeparameter($idx,'parameter_0_mapalias',$newvalue, |
|
'string'); |
|
&remember_parms($idx,'mapalias','set',$newvalue); |
|
$haschanges = 1; |
|
} |
|
} |
|
} elsif ($cmd eq 'delalias') { |
|
my $current = (&LONCAPA::map::getparameter($idx,'parameter_0_mapalias'))[0]; |
|
if ($current ne '') { |
|
&LONCAPA::map::delparameter($idx,'parameter_0_mapalias'); |
|
&remember_parms($idx,'mapalias','del'); |
|
$haschanges = 1; |
|
} |
} |
} |
return 1; |
return $haschanges; |
} |
} |
|
|
sub editor { |
sub editor { |
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype, |
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype, |
$supplementalflag,$orderhash,$iconpath,$pathitem,$canedit,$navmapref, |
$supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref, |
$hiddentop)=@_; |
$canedit,$hostname,$navmapref,$hiddentop)=@_; |
my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container); |
my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container); |
if ($allowed) { |
if ($allowed) { |
(my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain, |
(my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain, |
Line 2808 sub editor {
|
Line 3205 sub editor {
|
undef(@LONCAPA::map::zombies); |
undef(@LONCAPA::map::zombies); |
} |
} |
$folder = 'default'; |
$folder = 'default'; |
$container = 'sequence'; |
$container = 'sequence'; |
} else { |
} else { |
($errtext,$fatal) = &mapread($coursenum,$coursedom, |
($errtext,$fatal) = &mapread($coursenum,$coursedom, |
$folder.'.'.$container); |
$folder.'.'.$container); |
return $errtext if ($fatal); |
return $errtext if ($fatal); |
} |
} |
|
|
Line 2894 sub editor {
|
Line 3291 sub editor {
|
# Rename, cut, copy or remove a single resource |
# Rename, cut, copy or remove a single resource |
if (&handle_edit_cmd($coursenum,$coursedom)) { |
if (&handle_edit_cmd($coursenum,$coursedom)) { |
my $contentchg; |
my $contentchg; |
if ($env{'form.cmd'} =~ m{^(remove|cut)_}) { |
if ($env{'form.cmd'} =~ m{^(remove|cut|setalias|delalias)_}) { |
$contentchg = 1; |
$contentchg = 1; |
} |
} |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); |
Line 2987 sub editor {
|
Line 3384 sub editor {
|
} else { |
} else { |
return $errortxt; |
return $errortxt; |
} |
} |
|
} elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) { |
|
my ($suffix,$errortxt,$locknotfreed) = |
|
&new_timebased_suffix($coursedom,$coursenum,'exttool'); |
|
if ($locknotfreed) { |
|
$r->print($locknotfreed); |
|
} |
|
if ($suffix) { |
|
$url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix}; |
|
} else { |
|
return $errortxt; |
|
} |
} elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) { |
} elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) { |
if ($supplementalflag) { |
if ($supplementalflag) { |
next unless ($1 eq 'supplemental'); |
next unless ($1 eq 'supplemental'); |
Line 3009 sub editor {
|
Line 3417 sub editor {
|
} |
} |
($errtext,$fatal,my $fixuperrors) = |
($errtext,$fatal,my $fixuperrors) = |
&group_import($coursenum, $coursedom, $folder,$container, |
&group_import($coursenum, $coursedom, $folder,$container, |
'londocs',@imports); |
'londocs',$ltitoolsref,@imports); |
return $errtext if ($fatal); |
return $errtext if ($fatal); |
if ($fixuperrors) { |
if ($fixuperrors) { |
$r->print($fixuperrors); |
$r->print($fixuperrors); |
Line 3095 sub editor {
|
Line 3503 sub editor {
|
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$coursenum,$coursedom,$crstype, |
$coursenum,$coursedom,$crstype, |
$pathitem,$supplementalflag,$container, |
$pathitem,$supplementalflag,$container, |
\%filters,\%curr_groups,$canedit, |
\%filters,\%curr_groups,$ltitoolsref,$canedit, |
$isencrypted,$navmapref); |
$isencrypted,$navmapref,$hostname); |
$idx++; |
$idx++; |
$shown++; |
$shown++; |
} |
} |
Line 3123 sub editor {
|
Line 3531 sub editor {
|
.&Apache::loncommon::start_data_table(undef,'contentlist') |
.&Apache::loncommon::start_data_table(undef,'contentlist') |
.&Apache::loncommon::start_data_table_header_row() |
.&Apache::loncommon::start_data_table_header_row() |
.'<th colspan="2">'.&mt('Move').'</th>' |
.'<th colspan="2">'.&mt('Move').'</th>' |
.'<th colspan="2">'.&mt('Actions').'</th>' |
.'<th colspan="3">'.&mt('Actions').'</th>' |
.'<th>'.&mt('Document').'</th>'; |
.'<th>'.&mt('Document').'</th>'; |
if ($folder !~ /^supplemental/) { |
if ($folder !~ /^supplemental/) { |
$to_show .= '<th colspan="4">'.&mt('Settings').'</th>'; |
$to_show .= '<th colspan="2">'.&mt('Settings').'</th>'; |
} |
} |
$to_show .= &Apache::loncommon::end_data_table_header_row(); |
$to_show .= &Apache::loncommon::end_data_table_header_row(); |
if ($folder !~ /^supplemental/) { |
if ($folder !~ /^supplemental/) { |
Line 3154 sub editor {
|
Line 3562 sub editor {
|
'<td>'. |
'<td>'. |
&multiple_check_form('actions',\%lists,$canedit). |
&multiple_check_form('actions',\%lists,$canedit). |
'</td>'. |
'</td>'. |
'<td> </td>'. |
'<td colspan="3"> </td>'. |
'<td> </td>'. |
'<td colspan="2">'. |
'<td colspan="4">'. |
|
&multiple_check_form('settings',\%lists,$canedit). |
&multiple_check_form('settings',\%lists,$canedit). |
'</td>'. |
'</td>'. |
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
Line 3180 sub editor {
|
Line 3587 sub editor {
|
} |
} |
my $noresmsg; |
my $noresmsg; |
if ($allowed && $hiddentop && !$supplementalflag) { |
if ($allowed && $hiddentop && !$supplementalflag) { |
$noresmsg = &mt('Main Content Hidden'); |
$noresmsg = &mt('Main Content Hidden'); |
} else { |
} else { |
$noresmsg = &mt('Currently empty'); |
$noresmsg = &mt('Currently empty'); |
} |
} |
Line 3225 sub multiple_check_form {
|
Line 3632 sub multiple_check_form {
|
return unless (ref($listsref) eq 'HASH'); |
return unless (ref($listsref) eq 'HASH'); |
my $disabled; |
my $disabled; |
unless ($canedit) { |
unless ($canedit) { |
$disabled = 'disabled="disabled"'; |
$disabled = 'disabled="disabled"'; |
} |
} |
my $output = |
my $output = |
'<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'. |
'<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'. |
Line 3263 sub multiple_check_form {
|
Line 3670 sub multiple_check_form {
|
'</label></span></td>'."\n". |
'</label></span></td>'."\n". |
'<td class="LC_docs_entry_parameter">'. |
'<td class="LC_docs_entry_parameter">'. |
'<span class="LC_nobreak LC_docs_copy">'. |
'<span class="LC_nobreak LC_docs_copy">'. |
'<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy'). |
'<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'. $disabled.' />'.&mt('Copy'). |
'</label></span></td>'. |
'</label></span></td>'. |
'</tr></table>'."\n"; |
'</tr></table>'."\n"; |
} |
} |
Line 3305 sub process_file_upload {
|
Line 3712 sub process_file_upload {
|
my $quotatype = 'unofficial'; |
my $quotatype = 'unofficial'; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$quotatype = 'community'; |
$quotatype = 'community'; |
|
} elsif ($crstype eq 'Placement') { |
|
$quotatype = 'placement'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
$quotatype = 'official'; |
$quotatype = 'official'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
Line 3394 sub process_file_upload {
|
Line 3803 sub process_file_upload {
|
my $uploadphase = 'upload_embedded'; |
my $uploadphase = 'upload_embedded'; |
my $primaryurl = &HTML::Entities::encode($url,'<>&"'); |
my $primaryurl = &HTML::Entities::encode($url,'<>&"'); |
my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx); |
my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx); |
my ($embedded,$num) = |
my ($embedded,$num) = |
&Apache::loncommon::ask_for_embedded_content( |
&Apache::loncommon::ask_for_embedded_content( |
'/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url}); |
'/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url}); |
if ($embedded) { |
if ($embedded) { |
Line 3475 sub is_supplemental_title {
|
Line 3884 sub is_supplemental_title {
|
sub entryline { |
sub entryline { |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, |
$crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups, |
$crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups, |
$canedit,$isencrypted,$navmapref)=@_; |
$ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname)=@_; |
my ($foldertitle,$renametitle,$oldtitle); |
my ($foldertitle,$renametitle,$oldtitle); |
if (&is_supplemental_title($title)) { |
if (&is_supplemental_title($title)) { |
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); |
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); |
Line 3498 sub entryline {
|
Line 3907 sub entryline {
|
$renametitle=~s/"/%22/g; |
$renametitle=~s/"/%22/g; |
$renametitle=~s/ /%20/g; |
$renametitle=~s/ /%20/g; |
$oldtitle = $renametitle; |
$oldtitle = $renametitle; |
$renametitle=~s/\'\;/\\\'/g; |
$renametitle=~s/\'/\\\'/g; |
my $line=&Apache::loncommon::start_data_table_row(); |
my $line=&Apache::loncommon::start_data_table_row(); |
my ($form_start,$form_end,$form_common,$form_param); |
my ($form_start,$form_end,$form_common,$form_param); |
# Edit commands |
# Edit commands |
my ($esc_path, $path, $symb); |
my ($esc_path, $path, $symb, $curralias); |
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
$esc_path=&escape($env{'form.folderpath'}); |
$esc_path=&escape($env{'form.folderpath'}); |
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
Line 3571 END
|
Line 3980 END
|
'ct' => 'Cut', |
'ct' => 'Cut', |
'rn' => 'Rename', |
'rn' => 'Rename', |
'cp' => 'Copy', |
'cp' => 'Copy', |
|
'da' => 'Unset alias', |
|
'sa' => 'Set alias', |
'ex' => 'External Resource', |
'ex' => 'External Resource', |
|
'et' => 'External Tool', |
'ed' => 'Edit', |
'ed' => 'Edit', |
'pr' => 'Preview', |
'pr' => 'Preview', |
'sv' => 'Save', |
'sv' => 'Save', |
'ul' => 'URL', |
'ul' => 'URL', |
'ti' => 'Title', |
'ti' => 'Title', |
'er' => 'Editing rights unavailable for your current role.', |
'er' => 'Editing rights unavailable for your current role.', |
); |
); |
my %denied = &action_restrictions($coursenum,$coursedom,$url, |
my %denied = &action_restrictions($coursenum,$coursedom,$url, |
$env{'form.folderpath'}, |
$env{'form.folderpath'}, |
Line 3591 END
|
Line 4003 END
|
|/aboutme$ |
|/aboutme$ |
|/navmaps$ |
|/navmaps$ |
|/bulletinboard$ |
|/bulletinboard$ |
|
|/ext\.tool$ |
|\.html$)}x) |
|\.html$)}x) |
|| $isexternal) { |
|| $isexternal) { |
$skip_confirm = 1; |
$skip_confirm = 1; |
Line 3599 END
|
Line 4012 END
|
($url!~/$LONCAPA::assess_page_seq_re/)) { |
($url!~/$LONCAPA::assess_page_seq_re/)) { |
$confirm_removal = 1; |
$confirm_removal = 1; |
} |
} |
|
if ($url =~ /$LONCAPA::assess_re/) { |
|
$curralias = (&LONCAPA::map::getparameter($orderidx,'parameter_0_mapalias'))[0]; |
|
} |
|
|
if ($denied{'copy'}) { |
if ($denied{'copy'}) { |
$copylink=(<<ENDCOPY) |
$copylink=(<<ENDCOPY) |
Line 3740 END
|
Line 4156 END
|
} elsif ($url!~/\.(sequence|page)$/) { |
} elsif ($url!~/\.(sequence|page)$/) { |
$url='/adm/coursedocs/showdoc'.$url; |
$url='/adm/coursedocs/showdoc'.$url; |
} |
} |
} elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) { |
} elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) { |
my $wrapped = $1; |
my $wrapped = $1; |
my $exturl = $2; |
my $exturl = $2; |
if ($wrapped eq '') { |
if ($wrapped eq '') { |
Line 3749 END
|
Line 4165 END
|
if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) { |
if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) { |
$nomodal = 1; |
$nomodal = 1; |
} |
} |
|
} elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) { |
|
$url='/adm/wrapper'.$url; |
} elsif ($url eq "/public/$coursedom/$coursenum/syllabus") { |
} elsif ($url eq "/public/$coursedom/$coursenum/syllabus") { |
if (($ENV{'SERVER_PORT'} == 443) && |
if (($ENV{'SERVER_PORT'} == 443) && |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
|
$url .= '?usehttp=1'; |
$nomodal = 1; |
$nomodal = 1; |
} |
} |
} |
} |
if (&Apache::lonnet::symbverify($symb,$url)) { |
if (&Apache::lonnet::symbverify($symb,$url)) { |
my $shownsymb = $symb; |
my $shownsymb = $symb; |
if ($isexternal) { |
if ($isexternal) { |
Line 3789 END
|
Line 4208 END
|
} |
} |
if (ref($$navmapref)) { |
if (ref($$navmapref)) { |
if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') { |
if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') { |
$checkencrypt = 1; |
$checkencrypt = 1; |
} |
} |
} |
} |
} |
} |
Line 3797 END
|
Line 4216 END
|
my $shownsymb = &Apache::lonenc::encrypted($symb); |
my $shownsymb = &Apache::lonenc::encrypted($symb); |
my $shownurl = &Apache::lonenc::encrypted($url); |
my $shownurl = &Apache::lonenc::encrypted($url); |
if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) { |
if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) { |
$url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&'); |
$url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb); |
if ($env{'request.enc'} ne '') { |
if ($env{'request.enc'} ne '') { |
delete($env{'request.enc'}); |
delete($env{'request.enc'}); |
} |
} |
Line 3817 END
|
Line 4236 END
|
$url = $1; |
$url = $1; |
$anchor = $2; |
$anchor = $2; |
if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) { |
if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) { |
|
if ($hostname ne '') { |
|
$url = 'http://'.$hostname.$url; |
|
} |
$nomodal = 1; |
$nomodal = 1; |
} |
} |
} |
} |
} elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { |
} elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { |
if (($ENV{'SERVER_PORT'} == 443) && |
if (($ENV{'SERVER_PORT'} == 443) && |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
|
if ($hostname ne '') { |
|
$url = 'http://'.$hostname.$url; |
|
} |
|
$url .= (($url =~ /\?/) ? '&':'?').'usehttp=1'; |
$nomodal = 1; |
$nomodal = 1; |
} |
} |
} |
} |
Line 3855 END
|
Line 4281 END
|
my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1); |
my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1); |
unless (@resources) { |
unless (@resources) { |
$hiddenmap = 1; |
$hiddenmap = 1; |
unless ($env{'request.role.adv'}) { |
unless ($env{'request.role.adv'}) { |
$url = ''; |
$url = ''; |
$hiddenfolder = 1; |
$hiddenfolder = 1; |
} |
} |
Line 3874 END
|
Line 4300 END
|
|
|
# Append randompick number, hidden, and encrypted with ":" to foldername, |
# Append randompick number, hidden, and encrypted with ":" to foldername, |
# so it gets transferred between levels |
# so it gets transferred between levels |
$folderpath.=$containerarg.'&'.$foldername. |
$folderpath.=$containerarg.'&'.$foldername. |
':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage; |
':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage; |
unless ($url eq '') { |
unless ($url eq '') { |
$url.='folderpath='.&escape($folderpath); |
$url.='folderpath='.&escape($folderpath); |
Line 3910 $form_common."\n".
|
Line 4336 $form_common."\n".
|
$form_param."\n". |
$form_param."\n". |
$form_common."\n". |
$form_common."\n". |
'<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'. |
'<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'. |
$form_end; |
$form_end; |
} |
} |
} elsif ($supplementalflag && !$allowed) { |
} elsif ($supplementalflag && !$allowed) { |
|
my $isexttool; |
|
if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) { |
|
$url='/adm/wrapper'.$url; |
|
$isexttool = 1; |
|
} |
$url .= ($url =~ /\?/) ? '&':'?'; |
$url .= ($url =~ /\?/) ? '&':'?'; |
$url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"'); |
$url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"'); |
if ($title) { |
if ($title) { |
$url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"'); |
$url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"'); |
} |
} |
if ($isexternal && $orderidx) { |
if ((($isexternal) || ($isexttool)) && $orderidx) { |
$url .= '&idx='.$orderidx; |
$url .= '&idx='.$orderidx; |
} |
} |
if ($anchor ne '') { |
if ($anchor ne '') { |
Line 3927 $form_end;
|
Line 4358 $form_end;
|
} |
} |
my ($tdalign,$tdwidth); |
my ($tdalign,$tdwidth); |
if ($allowed) { |
if ($allowed) { |
my $fileloc = |
my $fileloc = |
&Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url)); |
&Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url)); |
if ($isexternal) { |
if ($isexternal) { |
($editlink,$extresform) = |
($editlink,$extresform) = |
&Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem, |
&Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem, |
undef,undef,undef,$disabled); |
undef,undef,undef,undef,undef,undef, |
|
undef,$disabled); |
|
} elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) { |
|
($editlink,$extresform) = |
|
&Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem, |
|
undef,undef,undef,'tool',$coursedom, |
|
$coursenum,$ltitoolsref,$disabled); |
} elsif (!$isfolder && !$ispage) { |
} elsif (!$isfolder && !$ispage) { |
my ($cfile,$home,$switchserver,$forceedit,$forceview) = |
my ($cfile,$home,$switchserver,$forceedit,$forceview) = |
&Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); |
&Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); |
Line 3941 $form_end;
|
Line 4378 $form_end;
|
if ($supplementalflag) { |
if ($supplementalflag) { |
$suppanchor = $anchor; |
$suppanchor = $anchor; |
} |
} |
my $jscall = |
my $jscall = |
&Apache::lonhtmlcommon::jump_to_editres($cfile,$home, |
&Apache::lonhtmlcommon::jump_to_editres($cfile,$home, |
$switchserver, |
$switchserver, |
$forceedit, |
$forceedit, |
undef,$symb, |
undef,$symb, |
&escape($env{'form.folderpath'}), |
&escape($env{'form.folderpath'}), |
$renametitle,'','',1,$suppanchor); |
$renametitle,$hostname, |
|
'','',1,$suppanchor); |
if ($jscall) { |
if ($jscall) { |
$editlink = '<a class="LC_docs_ext_edit" href="javascript:'. |
$editlink = '<a class="LC_docs_ext_edit" href="javascript:'. |
$jscall.'" >'.&mt('Edit').'</a> '."\n"; |
$jscall.'" >'.&mt('Edit').'</a> '."\n"; |
Line 3964 $form_end;
|
Line 4402 $form_end;
|
$reinit = &mt('(re-initialize course to access)'); |
$reinit = &mt('(re-initialize course to access)'); |
} |
} |
$line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink; |
$line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink; |
|
if ($orig_url =~ /$LONCAPA::assess_re/) { |
|
$line.= '<br />'; |
|
if ($curralias ne '') { |
|
$line.='<span class="LC_nobreak"><a href="javascript:delalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'. |
|
$lt{'da'}.'</a></span>'; |
|
} else { |
|
$line.='<span class="LC_nobreak"><a href="javascript:setalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'. |
|
$lt{'sa'}.'</a></span>'; |
|
} |
|
} |
|
$line.='</td><td>'; |
my $link; |
my $link; |
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { |
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { |
$line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>'; |
$line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>'; |
Line 3975 $form_end;
|
Line 4424 $form_end;
|
$anchor = '#'.&HTML::Entities::encode($anchor,'"<>&'); |
$anchor = '#'.&HTML::Entities::encode($anchor,'"<>&'); |
} |
} |
} |
} |
$link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'. |
if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) { |
|
$link = 'http://'.$hostname.$url; |
|
} else { |
|
$link = $url; |
|
} |
|
$link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'. |
(($anchor ne '')?$anchor:'')); |
(($anchor ne '')?$anchor:'')); |
if ($nomodal) { |
if ($nomodal) { |
$line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'. |
$line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'. |
Line 4002 $form_end;
|
Line 4456 $form_end;
|
} else { |
} else { |
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; |
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; |
} |
} |
$line.="$extresform</td>"; |
if (($allowed) && ($curralias ne '')) { |
|
$line .= '<br /><span class="LC_docs_alias_name">('.$curralias.')</span>'; |
|
} else { |
|
$line .= $extresform; |
|
} |
|
$line .= '</td>'; |
$rand_pick_text = ' ' if ($rand_pick_text eq ''); |
$rand_pick_text = ' ' if ($rand_pick_text eq ''); |
$rand_order_text = ' ' if ($rand_order_text eq ''); |
$rand_order_text = ' ' if ($rand_order_text eq ''); |
if (($allowed) && ($folder!~/^supplemental/)) { |
if (($allowed) && ($folder!~/^supplemental/)) { |
Line 4056 sub action_restrictions {
|
Line 4515 sub action_restrictions {
|
if ($url=~ m{^/res/.+\.(page|sequence)$}) { |
if ($url=~ m{^/res/.+\.(page|sequence)$}) { |
# no copy for published maps |
# no copy for published maps |
$denied{'copy'} = 1; |
$denied{'copy'} = 1; |
} elsif ($url=~m{^/res/lib/templates/}) { |
} elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) { |
$denied{'copy'} = 1; |
unless ($1 eq 'simpleproblem') { |
$denied{'cut'} = 1; |
$denied{'copy'} = 1; |
|
} |
|
$denied{'cut'} = 1; |
} elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") { |
} elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") { |
if ($folderpath =~ /^default&[^\&]+$/) { |
if ($folderpath =~ /^default&[^\&]+$/) { |
if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) { |
if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) { |
Line 4135 sub new_timebased_suffix {
|
Line 4596 sub new_timebased_suffix {
|
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.'); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.'); |
} elsif ($type eq 'smppg') { |
} elsif ($type eq 'smppg') { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.'); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.'); |
|
} elsif ($type eq 'exttool') { |
|
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.'); |
} else { |
} else { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.'); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.'); |
} |
} |
Line 4151 sub new_timebased_suffix {
|
Line 4614 sub new_timebased_suffix {
|
$locknotfreed = |
$locknotfreed = |
'<div class="LC_error">'. |
'<div class="LC_error">'. |
&mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '. |
&mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '. |
|
|
&mt('As a result addition of items to the clipboard will be unavailable until your next log-in.'); |
&mt('As a result addition of items to the clipboard will be unavailable until your next log-in.'); |
} else { |
} else { |
$locknotfreed .= |
$locknotfreed .= |
&mt('This will prevent addition of items to the clipboard until your next log-in.'); |
&mt('This will prevent addition of items to the clipboard until your next log-in.'); |
} |
} |
Line 4163 sub new_timebased_suffix {
|
Line 4626 sub new_timebased_suffix {
|
} elsif ($type eq 'smppg') { |
} elsif ($type eq 'smppg') { |
$locknotfreed .= |
$locknotfreed .= |
&mt('This will prevent creation of additional simple pages in this course.'); |
&mt('This will prevent creation of additional simple pages in this course.'); |
|
} elsif ($type eq 'exttool') { |
|
$locknotfreed .= |
|
&mt('This will prevent creation of additional external tools in this course.'); |
} else { |
} else { |
$locknotfreed .= |
$locknotfreed .= |
&mt('This will prevent creation of additional discussion boards in this course.'); |
&mt('This will prevent creation of additional discussion boards in this course.'); |
Line 4397 sub verifycontent {
|
Line 4863 sub verifycontent {
|
$r->print(&endContentScreen()); |
$r->print(&endContentScreen()); |
} |
} |
|
|
|
|
sub devalidateversioncache { |
sub devalidateversioncache { |
my $src=shift; |
my $src=shift; |
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. |
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. |
Line 4461 sub checkversions {
|
Line 4926 sub checkversions {
|
} |
} |
if ($haschanged) { |
if ($haschanged) { |
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
$r->print(&Apache::loncommon::confirmwrapper( |
$r->print(&Apache::loncommon::confirmwrapper( |
&Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved')))); |
&Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved')))); |
} else { |
} else { |
Line 4594 ENDHEADERS
|
Line 5059 ENDHEADERS
|
return; |
return; |
} |
} |
$r->print( |
$r->print( |
'<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'. |
'<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'. |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th>'.&mt('Resources').'</th>'. |
'<th>'.&mt('Resources').'</th>'. |
Line 4637 ENDHEADERS
|
Line 5102 ENDHEADERS
|
$setversions{$linkurl}, |
$setversions{$linkurl}, |
'set_version_'.$linkurl, |
'set_version_'.$linkurl, |
{'select_form_order' => ['',1..$currentversion,'mostrecent'], |
{'select_form_order' => ['',1..$currentversion,'mostrecent'], |
'' => '', |
'' => '', |
'mostrecent' => &mt('most recent'), |
'mostrecent' => &mt('most recent'), |
map {$_,$_} (1..$currentversion)},'',$readonly)); |
map {$_,$_} (1..$currentversion)},'',$readonly)); |
my $lastold=1; |
my $lastold=1; |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
my $url=$root.'.'.$prevvers.'.'.$extension; |
my $url=$root.'.'.$prevvers.'.'.$extension; |
Line 4776 sub startContentScreen {
|
Line 5241 sub startContentScreen {
|
if (($mode eq 'navmaps') || ($mode eq 'supplemental')) { |
if (($mode eq 'navmaps') || ($mode eq 'supplemental')) { |
$output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n"; |
|
$output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n"; |
$output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>'; |
$output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>'; |
} else { |
} else { |
$output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n"; |
$output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n"; |
Line 4813 sub handler {
|
Line 5279 sub handler {
|
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
|
|
# get docroot |
|
my $londocroot = $r->dir_config('lonDocRoot'); |
|
|
# graphics settings |
# graphics settings |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/'); |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/'); |
|
|
# |
# |
# --------------------------------------------- Initialize help topics for this |
# --------------------------------------------- Initialize help topics for this |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', |
'Adding_External_Resource','Navigate_Content', |
'Adding_External_Resource','Adding_External_Tool', |
'Adding_Folders','Docs_Overview', 'Load_Map', |
'Navigate_Content','Adding_Folders','Docs_Overview', |
'Supplemental','Score_Upload_Form','Adding_Pages', |
'Load_Map','Supplemental','Score_Upload_Form', |
'Importing_LON-CAPA_Resource','Importing_IMS_Course', |
'Adding_Pages','Importing_LON-CAPA_Resource', |
'Uploading_From_Harddrive','Course_Roster','Web_Page', |
'Importing_IMS_Course','Uploading_From_Harddrive', |
'Dropbox','Simple_Problem') { |
'Course_Roster','Web_Page','Dropbox','Simple_Problem') { |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
} |
} |
# Composite help files |
# Composite help files |
Line 4839 sub handler {
|
Line 5308 sub handler {
|
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); |
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); |
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
|
|
my ($allowed,$canedit,$canview,$disabled); |
my ($allowed,$canedit,$canview,$noendpage,$disabled); |
# URI is /adm/supplemental when viewing supplemental docs in non-edit mode. |
# URI is /adm/supplemental when viewing supplemental docs in non-edit mode. |
unless ($r->uri eq '/adm/supplemental') { |
unless ($r->uri eq '/adm/supplemental') { |
# does this user have privileges to modify content. |
# does this user have privileges to modify content. |
Line 4891 sub handler {
|
Line 5360 sub handler {
|
} elsif ($canedit && $env{'form.dumpcourse'}) { |
} elsif ($canedit && $env{'form.dumpcourse'}) { |
&init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space'); |
&init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space'); |
&dumpcourse($r); |
&dumpcourse($r); |
} elsif ($allowed && $env{'form.exportcourse'}) { |
} elsif ($canedit && $env{'form.exportcourse'}) { |
&init_breadcrumbs('exportcourse','IMS Export'); |
&init_breadcrumbs('exportcourse','IMS Export'); |
&Apache::imsexport::exportcourse($r); |
&Apache::imsexport::exportcourse($r); |
} else { |
} else { |
|
if ($canedit && $env{'form.authorrole'}) { |
|
$noendpage = 1; |
|
my ($redirect,$error) = &makenewproblem($r,$coursedom,$coursenum); |
|
if ($redirect) { |
|
if (($env{'form.newresourceadd'}) && ($env{'form.folderpath'})) { |
|
my $container = 'sequence'; |
|
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain, |
|
$is_random_order,$container) = |
|
&Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1); |
|
my (@folders)=split('&',$env{'form.folderpath'}); |
|
$env{'form.foldername'}=&unescape(pop(@folders)); |
|
my $folder=pop(@folders); |
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
|
$folder.'.'.$container); |
|
my $warning; |
|
if ($fatal) { |
|
if ($container eq 'page') { |
|
$warning = &mt('An error occurred retrieving the contents of the current page.'); |
|
} else { |
|
$warning = &mt('An error occurred retrieving the contents of the current folder.'); |
|
} |
|
} else { |
|
my $url = $redirect; |
|
my $srcfile = $londocroot.$url; |
|
$url =~ s{^/priv/}{/res/}; |
|
my $targetfile = $londocroot.$url; |
|
my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes')); |
|
my $output = &Apache::lonpublisher::batchpublish($r,$srcfile,$targetfile,$nokeyref,1); |
|
$env{'form.folder'} = $folder; |
|
&snapshotbefore(); |
|
my $title = &LONCAPA::map::qtunescape($env{'form.newresourcetitle'}); |
|
my $ext = 'false'; |
|
my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url)); |
|
$LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url). |
|
':'.$ext.':normal:res'; |
|
push(@LONCAPA::map::order,$newidx); |
|
&LONCAPA::map::storeparameter($newidx,'parameter_hiddenresource','yes', |
|
'string_yesno'); |
|
&remember_parms($newidx,'hiddenresource','set','yes'); |
|
($errtext,$fatal) = |
|
&storemap($coursenum, $coursedom, $folder.'.'.$container,1); |
|
&log_differences($plain); |
|
&mark_hash_old(); |
|
$r->internal_redirect($redirect); |
|
return OK; |
|
} |
|
} |
|
} |
|
} |
# |
# |
# Done catching special calls |
# Done catching special calls |
# The whole rest is for course and supplemental documents and utilities menu |
# The whole rest is for course and supplemental documents and utilities menu |
Line 4920 sub handler {
|
Line 5438 sub handler {
|
|
|
if ($env{'form.symb'}) { |
if ($env{'form.symb'}) { |
my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) { |
unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) { |
delete($env{'form.symb'}); |
delete($env{'form.symb'}); |
} |
} |
} |
} |
Line 4970 sub handler {
|
Line 5488 sub handler {
|
for (my $i=0; $i<@items; $i++) { |
for (my $i=0; $i<@items; $i++) { |
my $odd = $i%2; |
my $odd = $i%2; |
if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) { |
if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) { |
$badpath = 1; |
$badpath = 1; |
} |
} |
last if ($badpath); |
last if ($badpath); |
} |
} |
Line 4985 sub handler {
|
Line 5503 sub handler {
|
my $container; |
my $container; |
my $containertag; |
my $containertag; |
my $pathitem; |
my $pathitem; |
|
my %ltitools; |
my $hiddentop; |
my $hiddentop; |
my $navmap; |
my $navmap; |
my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) }; |
my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) }; |
Line 5027 sub handler {
|
Line 5546 sub handler {
|
|
|
if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) { |
if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) { |
if ($supplementalflag) { |
if ($supplementalflag) { |
undef($env{'form.folderpath'}) if ($1 eq 'default'); |
undef($env{'form.folderpath'}) if ($1 eq 'default'); |
} else { |
} else { |
undef($env{'form.folderpath'}) if ($1 eq 'supplemental'); |
undef($env{'form.folderpath'}) if ($1 eq 'supplemental'); |
} |
} |
Line 5048 sub handler {
|
Line 5567 sub handler {
|
.'&'. |
.'&'. |
$env{'form.folderpath'}; |
$env{'form.folderpath'}; |
} |
} |
# If allowed and user's role is not advanced check folderpath is not hidden |
# If allowed and user's role is not advanced check folderpath is not hidden |
if (($allowed) && (!$env{'request.role.adv'}) && |
if (($allowed) && (!$env{'request.role.adv'}) && |
($env{'form.folderpath'} ne '') && (!$supplementalflag)) { |
($env{'form.folderpath'} ne '') && (!$supplementalflag)) { |
my $folderurl; |
my $folderurl; |
my @pathitems = split(/\&/,$env{'form.folderpath'}); |
my @pathitems = split(/\&/,$env{'form.folderpath'}); |
Line 5162 sub handler {
|
Line 5681 sub handler {
|
} |
} |
} |
} |
my $tabidstr = join("','",@tabids); |
my $tabidstr = join("','",@tabids); |
$script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum, |
%ltitools = &Apache::lonnet::get_domain_lti($coursedom,'consumer'); |
$canedit,\$navmap). |
my $posslti = keys(%ltitools); |
|
my $hostname = $r->hostname(); |
|
$script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti, |
|
$londocroot,$canedit,$hostname,\$navmap). |
&history_tab_js(). |
&history_tab_js(). |
&inject_data_js(). |
&inject_data_js(). |
&Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid). |
&Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid). |
&Apache::lonextresedit::extedit_javascript(); |
&Apache::lonextresedit::extedit_javascript(\%ltitools); |
$addentries = { |
$addentries = { |
onload => "javascript:resize_scrollbox('contentscroll','1','1');", |
onload => "javascript:resize_scrollbox('contentscroll','1','1');", |
}; |
}; |
Line 5183 sub handler {
|
Line 5705 sub handler {
|
.'// <![CDATA['."\n" |
.'// <![CDATA['."\n" |
.$script."\n" |
.$script."\n" |
.'// ]]>'."\n" |
.'// ]]>'."\n" |
.'</script>'."\n"; |
.'</script>'."\n" |
|
.'<script type="text/javascript" |
|
src="/res/adm/includes/file_upload.js"></script>'."\n"; |
|
|
# Breadcrumbs |
# Breadcrumbs |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
Line 5261 sub handler {
|
Line 5785 sub handler {
|
my ($destination,$dir_root) = &embedded_destination(); |
my ($destination,$dir_root) = &embedded_destination(); |
my $url_root = '/uploaded/'.$docudom.'/'.$docuname; |
my $url_root = '/uploaded/'.$docudom.'/'.$docuname; |
my $actionurl = '/adm/coursedocs'; |
my $actionurl = '/adm/coursedocs'; |
my ($result,$flag) = |
my ($result,$flag) = |
&Apache::loncommon::upload_embedded('coursedoc',$destination, |
&Apache::loncommon::upload_embedded('coursedoc',$destination, |
$docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state, |
$docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state, |
$actionurl); |
$actionurl); |
Line 5272 sub handler {
|
Line 5796 sub handler {
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my ($destination,$dir_root) = &embedded_destination(); |
my ($destination,$dir_root) = &embedded_destination(); |
my $result = |
my $result = |
&Apache::loncommon::modify_html_refs('coursedoc',$destination, |
&Apache::loncommon::modify_html_refs('coursedoc',$destination, |
$docuname,$docudom,undef, |
$docuname,$docudom,undef, |
$dir_root); |
$dir_root); |
$r->print($result.&return_to_editor()); |
$r->print($result.&return_to_editor()); |
} elsif ($env{'form.phase'} eq 'decompress_uploaded') { |
} elsif ($env{'form.phase'} eq 'decompress_uploaded') { |
$uploadphase = 'decompress_phase_one'; |
$uploadphase = 'decompress_phase_one'; |
$r->print(&decompression_phase_one(). |
$r->print(&decompression_phase_one(). |
Line 5302 sub handler {
|
Line 5826 sub handler {
|
'impo' => 'Import', |
'impo' => 'Import', |
'lnks' => 'Import from Stored Links', |
'lnks' => 'Import from Stored Links', |
'impm' => 'Import from Assembled Map', |
'impm' => 'Import from Assembled Map', |
|
'imcr' => 'Import from Course Resources', |
|
'extr' => 'External Resource', |
|
'extt' => 'External Tool', |
'selm' => 'Select Map', |
'selm' => 'Select Map', |
'load' => 'Load Map', |
'load' => 'Load Map', |
'newf' => 'New Folder', |
'newf' => 'New Folder', |
Line 5311 sub handler {
|
Line 5838 sub handler {
|
'sipa' => 'Simple Course Page', |
'sipa' => 'Simple Course Page', |
'sipr' => 'Simple Problem', |
'sipr' => 'Simple Problem', |
'webp' => 'Blank Web Page (editable)', |
'webp' => 'Blank Web Page (editable)', |
|
'stpr' => 'Standard Problem', |
|
'news' => 'New sub-directory', |
|
'crpr' => 'Create Problem', |
'drbx' => 'Drop Box', |
'drbx' => 'Drop Box', |
'scuf' => 'External Scores (handgrade, upload, clicker)', |
'scuf' => 'External Scores (handgrade, upload, clicker)', |
'bull' => 'Discussion Board', |
'bull' => 'Discussion Board', |
Line 5324 sub handler {
|
Line 5854 sub handler {
|
'se' => 'Select', |
'se' => 'Select', |
'file' => 'File', |
'file' => 'File', |
'title' => 'Title', |
'title' => 'Title', |
|
'addp' => 'Add Placeholder to course?', |
|
'uste' => 'Use Template?', |
|
'fnam' => 'File Name:', |
|
'loca' => 'Location:', |
|
'dire' => 'Directory:', |
|
'cate' => 'Category:', |
|
'tmpl' => 'Template:', |
'comment' => 'Comment', |
'comment' => 'Comment', |
'parse' => 'Upload embedded images/multimedia files if HTML file', |
'parse' => 'Upload embedded images/multimedia files if HTML file', |
'bb5' => 'Blackboard 5', |
'bb5' => 'Blackboard 5', |
'bb6' => 'Blackboard 6', |
'bb6' => 'Blackboard 6', |
'angel5' => 'ANGEL 5.5', |
'angel5' => 'ANGEL 5.5', |
'webctce4' => 'WebCT 4 Campus Edition', |
'webctce4' => 'WebCT 4 Campus Edition', |
|
'yes' => 'Yes', |
|
'no' => 'No', |
'er' => 'Editing rights unavailable for your current role.', |
'er' => 'Editing rights unavailable for your current role.', |
); |
); |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
# Calculate free quota space for a user or course. |
|
|
# Calculate free quota space for a user or course. A javascript function checks |
|
# file size to determine if upload should be allowed. |
my $quotatype = 'unofficial'; |
my $quotatype = 'unofficial'; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$quotatype = 'community'; |
$quotatype = 'community'; |
|
} elsif ($crstype eq 'Placement') { |
|
$quotatype = 'placement'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
$quotatype = 'official'; |
$quotatype = 'official'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
Line 5367 sub handler {
|
Line 5910 sub handler {
|
my $fileupload=(<<FIUP); |
my $fileupload=(<<FIUP); |
$quotainfo |
$quotainfo |
$lt{'file'}:<br /> |
$lt{'file'}:<br /> |
<input type="file" name="uploaddoc" size="40" $disabled /> |
<input type="file" name="uploaddoc" class="flUpload" size="40" $disabled /> |
|
<input type="hidden" id="free_space" value="$free_space" /> |
FIUP |
FIUP |
|
|
my $checkbox=(<<CHBO); |
my $checkbox=(<<CHBO); |
Line 5414 IMSFORM
|
Line 5958 IMSFORM
|
<fieldset id="uploaddocform" style="display: none;"> |
<fieldset id="uploaddocform" style="display: none;"> |
<legend>$lt{'upfi'}</legend> |
<legend>$lt{'upfi'}</legend> |
<input type="hidden" name="active" value="aa" /> |
<input type="hidden" name="active" value="aa" /> |
$fileupload |
$fileupload |
<br /> |
<br /> |
$lt{'title'}:<br /> |
$lt{'title'}:<br /> |
<input type="text" size="60" name="comment" $disabled /> |
<input type="text" size="60" name="comment" $disabled /> |
Line 5432 FUFORM
|
Line 5976 FUFORM
|
|
|
my $mapimportjs; |
my $mapimportjs; |
if ($canedit) { |
if ($canedit) { |
$mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');"; |
$mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');"; |
} else { |
} else { |
$mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');"; |
$mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');"; |
} |
} |
Line 5453 FUFORM
|
Line 5997 FUFORM
|
</form> |
</form> |
|
|
SEDFFORM |
SEDFFORM |
|
my $importcrsresform; |
|
my ($numdirs,$pickfile) = |
|
&Apache::loncommon::import_crsauthor_form('crsresimportform','coursepath','coursefile', |
|
"resize_scrollbox('contentscroll','1','0');", |
|
undef,'res'); |
|
if ($pickfile) { |
|
$importcrsresform=(<<CRSFORM); |
|
<a class="LC_menubuttons_link" href="javascript:toggleImportCrsres('res','$numdirs');"> |
|
$lt{'imcr'}</a>$help{'Course_Resources'} |
|
<form action="/adm/coursedocs" method="post" name="crsresimportform" onsubmit="return validImportCrsRes();"> |
|
<fieldset id="importcrsresform" style="display: none;"> |
|
<legend>$lt{'imcr'}</legend> |
|
<input type="hidden" name="active" value="bb" /> |
|
$pickfile |
|
<p> |
|
$lt{'title'}: <input type="textbox" name="crsrestitle" value="" $disabled /> |
|
</p> |
|
<input type="hidden" name="importdetail" value="" /> |
|
<input type="submit" name="crsres" value="$lt{'impo'}" $disabled /> |
|
</fieldset> |
|
</form> |
|
CRSFORM |
|
} |
|
|
my $fromstoredjs; |
my $fromstoredjs; |
if ($canedit) { |
if ($canedit) { |
$fromstoredjs = 'open_StoredLinks_Import()'; |
$fromstoredjs = 'open_StoredLinks_Import()'; |
} else { |
} else { |
$fromstoredjs = "alert('".&js_escape($lt{'er'})."')"; |
$fromstoredjs = "alert('".&js_escape($lt{'er'})."')"; |
} |
} |
Line 5465 SEDFFORM
|
Line 6032 SEDFFORM
|
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:'.$fromstoredjs.';" />' => '<a class="LC_menubuttons_link" href="javascript:'.$fromstoredjs.';">'.$lt{'lnks'}.'</a>' }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:'.$fromstoredjs.';" />' => '<a class="LC_menubuttons_link" href="javascript:'.$fromstoredjs.';">'.$lt{'lnks'}.'</a>' }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform } |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }, |
); |
); |
|
if ($pickfile) { |
|
push(@importpubforma,{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{imcr}.'" onclick="javascript:toggleImportCrsres(\'res\','."'$numdirs'".');"/>' => $importcrsresform}); |
|
} |
$importpubform = &create_form_ul(&create_list_elements(@importpubforma)); |
$importpubform = &create_form_ul(&create_list_elements(@importpubforma)); |
my $extresourcesform = |
my $extresourcesform = |
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, |
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, |
$help{'Adding_External_Resource'}, |
$help{'Adding_External_Resource'}, |
undef,undef,$disabled); |
undef,undef,undef,undef,undef,undef,$disabled); |
|
my $exttoolform = |
|
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, |
|
$help{'Adding_External_Tool'},undef, |
|
undef,'tool',$coursedom,$coursenum, |
|
\%ltitools,$disabled); |
if ($allowed) { |
if ($allowed) { |
my $folder = $env{'form.folder'}; |
my $folder = $env{'form.folder'}; |
if ($folder eq '') { |
if ($folder eq '') { |
Line 5491 SEDFFORM
|
Line 6066 SEDFFORM
|
<input type="hidden" name="copyfolder" /> |
<input type="hidden" name="copyfolder" /> |
$containertag |
$containertag |
</form> |
</form> |
|
<form name="aliasform" method="post" action="/adm/coursedocs"> |
|
<input type="hidden" name="alias" /> |
|
<input type="hidden" name="cmd" /> |
|
$containertag |
|
</form> |
|
|
HIDDENFORM |
HIDDENFORM |
$r->print(&makesimpleeditform($pathitem)."\n". |
$r->print(&makesimpleeditform($pathitem)."\n". |
Line 5513 HIDDENFORM
|
Line 6093 HIDDENFORM
|
} |
} |
|
|
# |
# |
|
my $hostname = $r->hostname(); |
my $savefolderpath; |
my $savefolderpath; |
|
|
if ($allowed) { |
if ($allowed) { |
Line 5651 NROSTFORM
|
Line 6231 NROSTFORM
|
$help{'Web_Page'} |
$help{'Web_Page'} |
</form> |
</form> |
NWEBFORM |
NWEBFORM |
|
|
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
my %select_menus; |
|
my $numauthor = 0; |
|
my $numcrsdirs = 0; |
|
my $toppath = "/priv/$env{'user.domain'}/$env{'user.name'}"; |
|
if ($env{'user.author'}) { |
|
$numauthor ++; |
|
$select_menus{'author'}->{'text'} = &Apache::lonnet::plaintext('au'); |
|
if (grep(/^\Q$env{'user.home'}\E$/,@ids)) { |
|
my $is_home = 1; |
|
my %subdirs; |
|
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
|
$select_menus{'author'}->{'default'} = '/'; |
|
$select_menus{'author'}->{'select2'}->{'/'} = '/'; |
|
my @ordered = ('/'); |
|
foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
|
$select_menus{'author'}->{'select2'}->{$relpath} = $relpath; |
|
push(@ordered,$relpath); |
|
} |
|
$select_menus{'author'}->{'order'} = \@ordered; |
|
} else { |
|
$select_menus{'author'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
|
$select_menus{'author'}->{'default'} = 'switch'; |
|
$select_menus{'author'}->{'order'} = ['switch']; |
|
} |
|
} |
|
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
|
['active'],['ca','aa']); |
|
my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
|
my %by_roletype; |
|
if (keys(%roleshash)) { |
|
foreach my $entry (keys(%roleshash)) { |
|
my ($auname,$audom,$roletype) = split(/:/,$entry); |
|
my $key = $entry; |
|
$key =~ s/:/___/g; |
|
$by_roletype{$roletype}{$auname.'___'.$audom} = 1; |
|
$select_menus{$key}->{'text'} = &Apache::lonnet::plaintext($roletype)." ($audom/$auname)"; |
|
my $rolehome = &Apache::lonnet::homeserver($auname,$audom); |
|
if (grep(/^\Q$rolehome\E$/,@ids)) { |
|
my $is_home = 1; |
|
my (%subdirs,@ordered); |
|
my $toppath="/priv/$audom/$auname"; |
|
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
|
$select_menus{$key}->{'default'} = '/'; |
|
$select_menus{$key}->{'select2'}->{'/'} = '/'; |
|
my @ordered = ('/'); |
|
foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
|
$select_menus{$key}->{'select2'}->{$relpath} = $relpath; |
|
push(@ordered,$relpath); |
|
} |
|
$select_menus{$key}->{'order'} = \@ordered; |
|
} else { |
|
$select_menus{$key}->{'select2'}->{'switch'} = &mt('Switch server required'); |
|
$select_menus{$key}->{'default'} = 'switch'; |
|
$select_menus{$key}->{'order'} = ['switch']; |
|
} |
|
$numauthor ++; |
|
} |
|
} |
|
my ($pickdir,$showtitle); |
|
if ($numauthor) { |
|
my @order; |
|
my $defrole; |
|
if ($env{'user.author'}) { |
|
push(@order,'author'); |
|
$defrole = 'author'; |
|
} |
|
if (keys(%by_roletype)) { |
|
foreach my $possrole ('ca','aa') { |
|
if (ref($by_roletype{$possrole}) eq 'HASH') { |
|
foreach my $author (sort { lc($a) cmp lc($b) } (keys(%{$by_roletype{$possrole}}))) { |
|
unless ($defrole) { |
|
$defrole = $author; |
|
} |
|
push(@order,$author.'___'.$possrole); |
|
} |
|
} |
|
} |
|
} |
|
$select_menus{'course'}->{'text'} = &mt('Course Resource'); |
|
if (grep(/^\Q$crshome\E$/,@ids)) { |
|
my $is_home = 1; |
|
my %subdirs; |
|
my $toppath="/priv/$coursedom/$coursenum"; |
|
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
|
$numcrsdirs = keys(%subdirs); |
|
$select_menus{'course'}->{'default'} = '/'; |
|
$select_menus{'course'}->{'select2'}->{'/'} = '/'; |
|
my @ordered = ('/'); |
|
foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
|
$select_menus{'course'}->{'select2'}->{$relpath} = $relpath; |
|
push(@ordered,$relpath); |
|
} |
|
$select_menus{'course'}->{'order'} = \@ordered; |
|
} else { |
|
$select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
|
$select_menus{'course'}->{'default'} = 'switch'; |
|
$select_menus{'course'}->{'order'} = ['switch']; |
|
} |
|
push(@order,'course'); |
|
$pickdir = $lt{'loca'}. |
|
&Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'dire'}, |
|
$defrole,'authorrole','authorpath', |
|
\%select_menus,\@order,'toggleCrsResTitle();', |
|
'','priv').'<br />'; |
|
$showtitle = 'none'; |
|
} else { |
|
my $is_home; |
|
$showtitle = 'inline'; |
|
if (grep(/^\Q$crshome\E$/,@ids)) { |
|
$is_home = 1; |
|
$pickdir .= '<input type="hidden" name="authorrole" value="course" />'; |
|
my $toppath="/priv/$coursedom/$coursenum'}"; |
|
my %subdirs; |
|
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
|
$numcrsdirs = keys(%subdirs); |
|
if ($numcrsdirs) { |
|
$pickdir .= &mt('Directory: ').'<select name="authorpath">'."\n". |
|
'<option value="/">/</option>'."\n"; |
|
foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
|
$pickdir .= '<option value="'.$key.'">'.$key.'</option>'."\n"; |
|
} |
|
$pickdir .= '</select>'; |
|
} else { |
|
$pickdir .= '<input type="hidden" name="authorpath" value="/" />'."\n"; |
|
} |
|
} |
|
} |
|
|
|
my %seltemplate_menus; |
|
my @files = &Apache::lonhomework::get_template_list('problem'); |
|
my @noexamplelink = ('blank.problem','blank.library','script.library'); |
|
my $currentcategory = ''; |
|
my @ordered = (''); |
|
my %templatehelp; |
|
my $defcategory = ''; |
|
my @catorder = ($defcategory); |
|
$seltemplate_menus{$defcategory}->{'order'} = ['']; |
|
$seltemplate_menus{$defcategory}->{'text'} = ''; |
|
foreach my $file (@files) { |
|
if (ref($file) eq 'ARRAY') { |
|
my ($path,$title,$category,$help) = @{$file}; |
|
next if ($title !~ /\S/); |
|
if (&js_escape($category) ne $currentcategory) { |
|
$currentcategory = &js_escape($category); |
|
push(@catorder,&js_escape($currentcategory)); |
|
$seltemplate_menus{$currentcategory}->{'text'} = $category; |
|
$seltemplate_menus{$currentcategory}->{'default'} = ''; |
|
$seltemplate_menus{$currentcategory}->{'select2'}->{''} = ''; |
|
push(@{$seltemplate_menus{$currentcategory}->{'order'}},''); |
|
} |
|
if ($path) { |
|
$seltemplate_menus{$currentcategory}->{'select2'}->{&js_escape($path)} = $title; |
|
push(@{$seltemplate_menus{$currentcategory}->{'order'}},&js_escape($path)); |
|
if ($help) { |
|
$templatehelp{$path} = $help; |
|
} |
|
} |
|
} |
|
} |
|
|
|
my $templates = $lt{'cate'}.' '. |
|
&Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'tmpl'}.' ', |
|
$defcategory,'tempcategory','template', |
|
\%seltemplate_menus,\@catorder, |
|
"resize_scrollbox('contentscroll','1','0');", |
|
"toggleExampleText();",'template').'<br />'; |
|
my $templatepreview = '<a href="#" target="sample" onclick="javascript:getExample(600,420,\'yes\',true); return false;">'. |
|
'<span id="newresexample">'.&mt('Example').'<span></a>'; |
|
my $crsresform=(<<RESFORM); |
|
<a class="LC_menubuttons_link" href="javascript:toggleCrsRes('res','$numauthor','$numcrsdirs');"> |
|
$lt{'stpr'}</a>$help{'Course_Resource'} |
|
<form action="/adm/coursedocs" method="post" name="courseresform"> |
|
<fieldset id="crsresform" style="display:none;"> |
|
<legend>$lt{'stpr'}</legend> |
|
<input type="hidden" name="active" value="ee" /> |
|
<p> |
|
$pickdir |
|
<span class="LC_nobreak">$lt{'news'}? |
|
<label><input type="radio" name="newsubdir" value="0" onclick="toggleNewsubdir(this.form);" checked="checked" $disabled />No</label> |
|
|
|
<label><input type="radio" name="newsubdir" value="1" onclick="toggleNewsubdir(this.form);" $disabled />Yes</label> |
|
</span><span id="newsubdir"></span> |
|
<input type="hidden" name="newsubdirname" id="newsubdirname" value="" autocomplete="off" /> |
|
</p> |
|
$lt{'fnam'} |
|
<input type="text" size="20" name="newresourcename" autocomplete="off" $disabled /> |
|
<p> |
|
<div id="newresource" style="display:$showtitle"> |
|
$lt{'addp'} |
|
<label><input type="radio" name="newresourceadd" value="0" checked="checked" onclick="toggleNewInCourse(this.form);" $disabled /> |
|
$lt{'no'}</label> |
|
<label><input type="radio" name="newresourceadd" value="1" onclick="toggleNewInCourse(this.form);" $disabled /> |
|
$lt{'yes'}</label> |
|
<span id="newrestitle"></span> |
|
<input type="hidden" size="20" name="newresourcetitle" id="newresourcetitle" autocomplete="off" $disabled /> |
|
</div> |
|
</p> |
|
<p> |
|
$lt{'uste'} |
|
<label><input type="radio" name="newresusetemp" value="0" checked="checked" onclick="toggleWithTemplate(this.form);" $disabled /> |
|
$lt{'no'}</label> |
|
<label><input type="radio" name="newresusetemp" value="1" onclick="toggleWithTemplate(this.form);" $disabled /> |
|
$lt{'yes'}</label> |
|
<div id="newrestemplate" style="display:none"> |
|
$templates |
|
$templatepreview |
|
</div> |
|
</p> |
|
<span class="LC_nobreak"> |
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
|
<input type="submit" name="newcrs" value="$lt{'crpr'}" $disabled /> |
|
</span> |
|
</fieldset> |
|
</form> |
|
|
|
RESFORM |
|
|
my $specialdocumentsform; |
my $specialdocumentsform; |
my @specialdocumentsforma; |
my @specialdocumentsforma; |
Line 5719 NGFFORM
|
Line 6516 NGFFORM
|
my @importdoc = ( |
my @importdoc = ( |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform} |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform} |
); |
); |
|
if (keys(%ltitools)) { |
|
push(@importdoc, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform}, |
|
); |
|
} |
unless ($container eq 'page') { |
unless ($container eq 'page') { |
push(@importdoc, |
push(@importdoc, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform} |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform} |
Line 5733 NGFFORM
|
Line 6535 NGFFORM
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform}, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{stpr}.'" onclick="javascript:toggleCrsRes(\'res\','."'$numauthor','$numcrsdirs'".');" />'=>$crsresform}, |
); |
); |
$gradingform = &create_form_ul(&create_list_elements(@gradingforma)); |
$gradingform = &create_form_ul(&create_list_elements(@gradingforma)); |
|
|
Line 5761 unless ($container eq 'page') {
|
Line 6563 unless ($container eq 'page') {
|
unless (($supplementalflag || $toolsflag)) { |
unless (($supplementalflag || $toolsflag)) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
$supplementalflag,\%orderhash,$iconpath,$pathitem, |
$supplementalflag,\%orderhash,$iconpath,$pathitem, |
$canedit,\$navmap,$hiddentop); |
\%ltitools,$canedit,$hostname,\$navmap,$hiddentop); |
undef($navmap); |
undef($navmap); |
if ($error) { |
if ($error) { |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
} |
} |
if ($hadchanges) { |
if ($hadchanges) { |
unless (&is_hash_old()) { |
unless (&is_hash_old()) { |
&mark_hash_old(); |
&mark_hash_old(); |
} |
} |
} |
} |
|
|
&changewarning($r,''); |
&changewarning($r,''); |
} |
} |
Line 5800 unless ($container eq 'page') {
|
Line 6602 unless ($container eq 'page') {
|
<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data"> |
<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data"> |
<fieldset id="uploadsuppdocform" style="display: none;"> |
<fieldset id="uploadsuppdocform" style="display: none;"> |
<legend>$lt{'upfi'}</legend> |
<legend>$lt{'upfi'}</legend> |
<input type="hidden" name="active" value="ee" /> |
<input type="hidden" name="active" value="ee" /> |
$fileupload |
$fileupload |
<br /> |
<br /> |
<br /> |
<br /> |
Line 5830 SNFFORM
|
Line 6632 SNFFORM
|
my $supextform = |
my $supextform = |
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
$help{'Adding_External_Resource'}, |
$help{'Adding_External_Resource'}, |
undef,undef,$disabled); |
undef,undef,undef,undef,undef,undef, |
|
$disabled); |
|
|
|
my $supexttoolform = |
|
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
|
$help{'Adding_External_Tool'}, |
|
undef,undef,'tool',$coursedom, |
|
$coursenum,\%ltitools,$disabled); |
|
|
my $supnewsylform=(<<SNSFORM); |
my $supnewsylform=(<<SNSFORM); |
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
Line 5885 my @specialdocs = (
|
Line 6694 my @specialdocs = (
|
); |
); |
my @supimportdoc = ( |
my @supimportdoc = ( |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />' |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />' |
=>$supextform}, |
=>$supextform}); |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />' |
if (keys(%ltitools)) { |
|
push(@supimportdoc, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />' |
|
=>$supexttoolform}); |
|
} |
|
push(@supimportdoc, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />' |
=>$supupdocform}, |
=>$supupdocform}, |
); |
); |
|
|
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)); |
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)); |
my %suporderhash = ( |
my %suporderhash = ( |
Line 5899 my %suporderhash = (
|
Line 6714 my %suporderhash = (
|
if ($supplementalflag) { |
if ($supplementalflag) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
$supplementalflag,\%suporderhash,$iconpath,$pathitem, |
$supplementalflag,\%suporderhash,$iconpath,$pathitem, |
$canedit); |
\%ltitools,$canedit,$hostname); |
if ($error) { |
if ($error) { |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
} else { |
} else { |
Line 5919 my %suporderhash = (
|
Line 6734 my %suporderhash = (
|
} |
} |
} elsif ($supplementalflag) { |
} elsif ($supplementalflag) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
$supplementalflag,'',$iconpath,$pathitem); |
$supplementalflag,'',$iconpath,$pathitem,'','',$hostname); |
if ($error) { |
if ($error) { |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
} |
} |
Line 5946 my %suporderhash = (
|
Line 6761 my %suporderhash = (
|
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); |
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); |
} |
} |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
unless ($noendpage) { |
|
$r->print(&Apache::loncommon::end_page()); |
|
} |
return OK; |
return OK; |
} |
} |
|
|
Line 6024 sub decompression_phase_one {
|
Line 6841 sub decompression_phase_one {
|
$error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'}); |
$error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'}); |
} else { |
} else { |
my $file = $1; |
my $file = $1; |
$output = |
$output = |
&Apache::loncommon::process_decompression($docudom,$docuname,$file, |
&Apache::loncommon::process_decompression($docudom,$docuname,$file, |
$destination,$dir_root, |
$destination,$dir_root, |
$hiddenelem); |
$hiddenelem); |
Line 6299 END
|
Line 7116 END
|
} |
} |
|
|
sub editing_js { |
sub editing_js { |
my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$canedit,$navmapref) = @_; |
my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti, |
|
$londocroot,$canedit,$hostname,$navmapref) = @_; |
my %js_lt = &Apache::lonlocal::texthash( |
my %js_lt = &Apache::lonlocal::texthash( |
p_mnf => 'Name of New Folder', |
p_mnf => 'Name of New Folder', |
t_mnf => 'New Folder', |
t_mnf => 'New Folder', |
Line 6311 sub editing_js {
|
Line 7129 sub editing_js {
|
p_mdb => 'Title for the Drop Box', |
p_mdb => 'Title for the Drop Box', |
p_mbb => 'Title for the Discussion Board', |
p_mbb => 'Title for the Discussion Board', |
p_mwp => 'Title for Web Page', |
p_mwp => 'Title for Web Page', |
|
p_mnr => 'Title for the Resource', |
p_mab => "Enter user:domain for User's Personal Information Page", |
p_mab => "Enter user:domain for User's Personal Information Page", |
p_mab2 => 'Personal Information Page of ', |
p_mab2 => 'Personal Information Page of ', |
p_mab_alrt1 => 'Not a valid user:domain', |
p_mab_alrt1 => 'Not a valid user:domain', |
Line 6329 sub editing_js {
|
Line 7148 sub editing_js {
|
p_ctr2b => '?', |
p_ctr2b => '?', |
p_ctr3a => 'Cut those', |
p_ctr3a => 'Cut those', |
p_ctr3b => 'items?', |
p_ctr3b => 'items?', |
|
setal => 'Enter a (unique) alias', |
|
delal => 'Are you sure you want to eliminate the alias?', |
rpck => 'Enter number to pick (e.g., 3)', |
rpck => 'Enter number to pick (e.g., 3)', |
imsfile => 'You must choose an IMS package for import', |
imsfile => 'You must choose an IMS package for import', |
imscms => 'You must select which Course Management System was the source of the IMS package', |
imscms => 'You must select which Course Management System was the source of the IMS package', |
Line 6339 sub editing_js {
|
Line 7160 sub editing_js {
|
noor => 'No actions selected or changes to settings specified.', |
noor => 'No actions selected or changes to settings specified.', |
noch => 'No changes to settings specified.', |
noch => 'No changes to settings specified.', |
noac => 'No actions selected.', |
noac => 'No actions selected.', |
|
nofi => 'No file selected', |
|
tinc => 'Title in course', |
|
sunm => 'Sub-directory name', |
edri => 'Editing rights unavailable for your current role.', |
edri => 'Editing rights unavailable for your current role.', |
); |
); |
|
|
&js_escape(\%js_lt); |
&js_escape(\%js_lt); |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); |
my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); |
Line 6371 sub editing_js {
|
Line 7194 sub editing_js {
|
} else { |
} else { |
$url = $res; |
$url = $res; |
} |
} |
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='. |
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"'); |
&HTML::Entities::encode($caller,'<>&"'); |
if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) { |
|
$backtourl .= '?navmap=1'; |
|
} else { |
|
$backtourl .= '?symb='. |
|
&HTML::Entities::encode($caller,'<>&"'); |
|
} |
|
if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { |
|
if (($ENV{'SERVER_PORT'} == 443) && |
|
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
|
if ($hostname ne '') { |
|
$backtourl = 'http://'.$hostname.$backtourl; |
|
} |
|
$backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1'; |
|
} |
|
} elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) { |
|
if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) { |
|
$backtourl = 'http://'.$hostname.$backtourl; |
|
} |
|
} |
if ($anchor ne '') { |
if ($anchor ne '') { |
$backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"'); |
$backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"'); |
} |
} |
$backtourl = &Apache::loncommon::escape_single($backtourl); |
$backtourl = &Apache::loncommon::escape_single($backtourl); |
} else { |
} else { |
$backtourl = '/adm/navmaps'; |
$backtourl = '/adm/navmaps'; |
} |
} |
Line 6390 sub editing_js {
|
Line 7231 sub editing_js {
|
} |
} |
|
|
my $fieldsets = "'ext','doc'"; |
my $fieldsets = "'ext','doc'"; |
|
if ($posslti) { |
|
$fieldsets .= ",'tool'"; |
|
} |
unless ($main_container_page) { |
unless ($main_container_page) { |
$fieldsets .=",'ims'"; |
$fieldsets .=",'ims'"; |
} |
} |
if ($supplementalflag) { |
if ($supplementalflag) { |
$fieldsets = "'suppext','suppdoc'"; |
$fieldsets = "'suppext','suppdoc'"; |
|
if ($posslti) { |
|
$fieldsets .= ",'supptool'"; |
|
} |
} |
} |
|
|
my $jsmakefunctions; |
my $jsmakefunctions; |
if ($canedit) { |
if ($canedit) { |
$jsmakefunctions = <<ENDNEWSCRIPT; |
$jsmakefunctions = <<ENDNEWSCRIPT; |
Line 6443 function makewebpage(type) {
|
Line 7290 function makewebpage(type) {
|
formname = this.document.forms.newwebpage; |
formname = this.document.forms.newwebpage; |
} |
} |
if (title) { |
if (title) { |
var webpage = formname.importdetail.value; |
var webpage = formname.importdetail.value; |
formname.importdetail.value = escape(title)+'='+webpage; |
formname.importdetail.value = escape(title)+'='+webpage; |
formname.submit(); |
formname.submit(); |
} |
} |
Line 6510 function changename(folderpath,index,old
|
Line 7357 function changename(folderpath,index,old
|
} |
} |
} |
} |
|
|
|
function setalias(folderpath,index) { |
|
var alias = prompt('$js_lt{"setal"}'); |
|
if ((alias != null) && (alias != '')) { |
|
this.document.forms.aliasform.alias.value=alias; |
|
this.document.forms.aliasform.cmd.value='setalias_'+index; |
|
this.document.forms.aliasform.folderpath.value=folderpath; |
|
this.document.forms.aliasform.submit(); |
|
} |
|
} |
|
|
|
function delalias(folderpath,index) { |
|
if (confirm('$js_lt{"delal"}')) { |
|
this.document.forms.aliasform.cmd.value='delalias_'+index; |
|
this.document.forms.aliasform.folderpath.value=folderpath; |
|
this.document.forms.aliasform.submit(); |
|
} |
|
} |
|
|
ENDNEWSCRIPT |
ENDNEWSCRIPT |
} else { |
} else { |
$jsmakefunctions = <<ENDNEWSCRIPT; |
$jsmakefunctions = <<ENDNEWSCRIPT; |
Line 6554 function changename() {
|
Line 7419 function changename() {
|
alert("$js_lt{'edri'}"); |
alert("$js_lt{'edri'}"); |
} |
} |
|
|
|
function setalias() { |
|
alert("$js_lt{'edri'}"); |
|
} |
|
|
|
function delalias() { |
|
alert("$js_lt{'edri'}"); |
|
} |
|
|
function makenew() { |
function makenew() { |
alert("$js_lt{'edri'}"); |
alert("$js_lt{'edri'}"); |
} |
} |
Line 6591 function toggleUpload(caller) {
|
Line 7464 function toggleUpload(caller) {
|
} |
} |
} |
} |
document.getElementById('upload'+blocks[i]+'form').style.display=disp; |
document.getElementById('upload'+blocks[i]+'form').style.display=disp; |
|
if ((caller == 'tool') || (caller == 'supptool')) { |
|
if (disp == 'block') { |
|
if (document.getElementById('LC_exttoolid')) { |
|
var toolselector = document.getElementById('LC_exttoolid'); |
|
var suppflag = 0; |
|
if (caller == 'supptool') { |
|
suppflag = 1; |
|
} |
|
currForm = document.getElementById('new'+caller); |
|
updateExttool(toolselector,currForm,suppflag); |
|
} |
|
} |
|
} |
} |
} |
resize_scrollbox('contentscroll','1','1'); |
resize_scrollbox('contentscroll','1','1'); |
return; |
return; |
Line 6611 function toggleMap(caller) {
|
Line 7497 function toggleMap(caller) {
|
return; |
return; |
} |
} |
|
|
|
function toggleCrsRes(caller,numauthorrole,numcrsdirs) { |
|
var disp = 'none'; |
|
if (document.getElementById('crsresform')) { |
|
if (caller == 'res') { |
|
var curr = document.getElementById('crsresform').style.display; |
|
if (curr == 'none') { |
|
disp='block'; |
|
numauthor = parseInt(numauthorrole); |
|
if (numauthor > 0) { |
|
document.courseresform.authorrole.selectedIndex = 0; |
|
select1priv_changed(); |
|
document.courseresform.authorpath.selectedIndex = 0; |
|
document.courseresform.newresourceadd.selectedIndex = 0; |
|
toggleNewInCourse(document.courseresform); |
|
if (document.getElementById('newresource')) { |
|
document.getElementById('newresource').style.display = 'none'; |
|
} |
|
} else { |
|
if (numcrsdirs) { |
|
document.courseresform.authorpath.selectedIndex = 0; |
|
} |
|
} |
|
if (document.courseresform.newresusetemp.length) { |
|
document.courseresform.newresusetemp[0].checked = true; |
|
toggleWithTemplate(document.courseresform); |
|
} |
|
document.courseresform.newresourcename.value = ''; |
|
} |
|
} |
|
if (document.courseresform.newsubdir.length) { |
|
for (var j=0; j<document.courseresform.newsubdir.length; j++) { |
|
if (document.courseresform.newsubdir[j].value == 0) { |
|
document.courseresform.newsubdir[j].checked = true; |
|
} |
|
break; |
|
} |
|
if (document.getElementById('newsubdirname')) { |
|
document.getElementById('newsubdirname').type = "hidden"; |
|
document.getElementById('newsubdirname').value = ""; |
|
} |
|
if (document.getElementById('newsubdir')) { |
|
document.getElementById('newsubdir').innerHTML = ""; |
|
} |
|
} |
|
document.getElementById('crsresform').style.display=disp; |
|
resize_scrollbox('contentscroll','1','0'); |
|
} |
|
return; |
|
} |
|
|
|
function toggleNewsubdir(form) { |
|
if (form.newsubdir.length) { |
|
for (var j=0; j<form.newsubdir.length; j++) { |
|
if (form.newsubdir[j].checked) { |
|
if (document.getElementById('newsubdirname')) { |
|
if (form.newsubdir[j].value == '1') { |
|
document.getElementById('newsubdirname').type = "text"; |
|
if (document.getElementById('newsubdir')) { |
|
document.getElementById('newsubdir').innerHTML = '<br />$js_lt{'sunm'}'; |
|
} |
|
} else { |
|
document.getElementById('newsubdirname').type = "hidden"; |
|
document.getElementById('newsubdirname').value = ""; |
|
document.getElementById('newsubdir').innerHTML = ""; |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function toggleCrsResTitle() { |
|
if (document.getElementById('newresource')) { |
|
if (document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value == 'course') { |
|
document.getElementById('newresource').style.display = 'inline'; |
|
document.courseresform.newresourceadd[0].checked = true; |
|
toggleNewInCourse(document.courseresform); |
|
} else { |
|
document.getElementById('newresource').style.display = 'none'; |
|
} |
|
} |
|
} |
|
|
|
function toggleNewInCourse(form) { |
|
if (form.newresourceadd.length) { |
|
for (var i=0; i<form.newresourceadd.length; i++) { |
|
if (form.newresourceadd[i].checked) { |
|
if (document.getElementById('newresourcetitle')) { |
|
if (form.newresourceadd[i].value == '1') { |
|
document.getElementById('newresourcetitle').type = 'text'; |
|
if (document.getElementById('newrestitle')) { |
|
document.getElementById('newrestitle').innerHTML = "<br />$js_lt{'tinc'}"; |
|
} |
|
} else { |
|
document.getElementById('newresourcetitle').type = 'hidden'; |
|
document.getElementById('newresourcetitle').value = ''; |
|
if (document.getElementById('newrestitle')) { |
|
document.getElementById('newrestitle').innerHTML = ''; |
|
} |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function toggleWithTemplate(form) { |
|
if (form.newresusetemp.length) { |
|
for (var i=0; i<form.newresusetemp.length; i++) { |
|
if (form.newresusetemp[i].checked) { |
|
if (document.getElementById('newrestemplate')) { |
|
if (form.newresusetemp[i].value == '1') { |
|
document.getElementById('newrestemplate').style.display = 'inline'; |
|
toggleExampleText(); |
|
} else { |
|
form.tempcategory.selectedIndex = 0; |
|
select1template_changed(); |
|
document.getElementById('newrestemplate').style.display = 'none'; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
function toggleExampleText() { |
|
if (document.getElementById('newresexample')) { |
|
var url = document.courseresform.template.options[document.courseresform.template.selectedIndex].value; |
|
if (url == '') { |
|
document.getElementById('newresexample').style.fontWeight = 'normal'; |
|
} else { |
|
document.getElementById('newresexample').style.fontWeight = 'bold'; |
|
} |
|
} |
|
} |
|
|
|
function getExample(width,height,scrolling,transparency) { |
|
var url; |
|
if (document.courseresform.newresusetemp.length) { |
|
for (var i=0; i<document.courseresform.newresusetemp.length; i++) { |
|
if (document.courseresform.newresusetemp[i].checked) { |
|
if (document.courseresform.newresusetemp[i].value == '1') { |
|
var url = document.courseresform.template.options[document.courseresform.template.selectedIndex].value; |
|
if (url == '') { |
|
alert('Pick a category and template'); |
|
} else { |
|
url = url.replace("$londocroot",""); |
|
url += '?inhibitmenu=yes'; |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
if (url != '') { |
|
openMyModal(url,width,height,scrolling,transparency,''); |
|
} |
|
} |
|
|
|
function toggleImportCrsres(caller,dircount) { |
|
var disp = 'none'; |
|
if (document.getElementById('importcrsresform')) { |
|
if (caller == 'res') { |
|
var numdirs = parseInt(dircount); |
|
var curr = document.getElementById('importcrsresform').style.display; |
|
if (curr == 'none') { |
|
disp='block'; |
|
if (numdirs > 1) { |
|
select1res_changed(); |
|
} |
|
} |
|
} |
|
document.getElementById('importcrsresform').style.display=disp; |
|
resize_scrollbox('contentscroll','1','0'); |
|
} |
|
return; |
|
} |
|
|
function makeims(imsform) { |
function makeims(imsform) { |
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |
alert("$js_lt{'imsfile'}"); |
alert("$js_lt{'imsfile'}"); |
Line 6917 for (i = 0; i < currentLis.length; i++)
|
Line 7983 for (i = 0; i < currentLis.length; i++)
|
|
|
function hideAll(current, nav, data) { |
function hideAll(current, nav, data) { |
unselectInactive(nav); |
unselectInactive(nav); |
if (current) { |
if (current) { |
if (current.className == 'right'){ |
if (current.className == 'right'){ |
current.className = 'right active' |
current.className = 'right active' |
} else { |
} else { |
current.className = 'active'; |
current.className = 'active'; |
} |
} |
} |
} |
currentData = document.getElementById(data); |
currentData = document.getElementById(data); |
Line 6959 function showPage(current, pageId, nav,
|
Line 8025 function showPage(current, pageId, nav,
|
unselectInactive(nav); |
unselectInactive(nav); |
if ((currstate == 'active') || (currstate == 'right active')) { |
if ((currstate == 'active') || (currstate == 'right active')) { |
if (currstate == 'active') { |
if (currstate == 'active') { |
current.className = ''; |
current.className = ''; |
} else { |
} else { |
current.className = 'right'; |
current.className = 'right'; |
} |
} |
activeTab = ''; |
activeTab = ''; |
toggleUpload(); |
toggleUpload(); |
toggleMap(); |
toggleMap(); |
|
toggleCrsRes(); |
|
toggleImportCrsres(); |
resize_scrollbox('contentscroll','1','0'); |
resize_scrollbox('contentscroll','1','0'); |
return; |
return; |
} else { |
} else { |
Line 6976 function showPage(current, pageId, nav,
|
Line 8044 function showPage(current, pageId, nav,
|
activeTab = pageId; |
activeTab = pageId; |
toggleUpload(); |
toggleUpload(); |
toggleMap(); |
toggleMap(); |
|
toggleCrsRes(); |
|
toggleImportCrsres(); |
if (nav == 'mainnav') { |
if (nav == 'mainnav') { |
var storedpath = "$docs_folderpath"; |
var storedpath = "$docs_folderpath"; |
var storedpage = "$main_container_page"; |
var storedpage = "$main_container_page"; |
Line 7339 function setBoxes(value) {
|
Line 8409 function setBoxes(value) {
|
return; |
return; |
} |
} |
|
|
|
function validImportCrsRes() { |
|
var path = document.crsresimportform.coursepath.options[document.crsresimportform.coursepath.selectedIndex].value; |
|
var fname = document.crsresimportform.coursefile.options[document.crsresimportform.coursefile.selectedIndex].value; |
|
if ((fname == '') || (fname == null)) { |
|
alert("$js_lt{'nofi'}"); |
|
return false; |
|
} |
|
var url = '/res/$coursedom/$coursenum/'; |
|
if (path && path != '/') { |
|
url += path+'/'; |
|
} |
|
if (fname != '') { |
|
url += fname; |
|
} |
|
var title = document.crsresimportform.crsrestitle.value; |
|
document.crsresimportform.importdetail.value=escape(title)+'='+escape(url); |
|
return true; |
|
} |
|
|
|
function validateNewRes(caller) { |
|
if (caller == 'single') { |
|
var role = document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value; |
|
var authorpath = document.courseresform.authorpath.options[document.courseresform.authorpath.selectedIndex].value; |
|
var resname = document.courseresform.newresourcename.value; |
|
} |
|
} |
|
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
Line 7469 sub makesimpleeditform {
|
Line 8566 sub makesimpleeditform {
|
SIMPFORM |
SIMPFORM |
} |
} |
|
|
|
sub makenewproblem { |
|
my ($r,$coursedom,$coursenum) = @_; |
|
# Creating a new problem |
|
my ($redirect,$error); |
|
if ($env{'form.authorrole'}) { |
|
my ($newsubdir,$filename); |
|
if ($env{'form.newsubdir'}) { |
|
if ($env{'form.newsubdirname'} ne '') { |
|
$newsubdir = $env{'form.newsubdirname'}; |
|
} |
|
} |
|
if ($env{'form.newresourcename'}) { |
|
$filename = $env{'form.newresourcename'}; |
|
$filename =~ s/\.(\d+)(\.\w+)$/$2/; |
|
$filename =~ s/`//g; |
|
$filename =~ s{/\.\./}{_}g; |
|
$filename =~ s/\.+/./g; |
|
$filename =~ s{/+}{_}g; |
|
if ($filename ne '') { |
|
my ($name,$ext) = ($filename =~ /(.+)\.([^.]+)$/); |
|
if (($ext) && ($ext ne '.problem')) { |
|
$filename = $name.'.problem'; |
|
} elsif ($ext eq '') { |
|
$filename .= '.problem'; |
|
} |
|
my $docroot = $r->dir_config('lonDocRoot'); |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
if ($env{'form.authorrole'} eq 'author') { |
|
if ($env{'user.author'}) { |
|
if ($env{'user.home'} && grep(/^\Q$env{'user.home'}\E$/,@ids)) { |
|
my $url = "/priv/$env{'user.domain'}/$env{'user.name'}"; |
|
my $path = $docroot.$url; |
|
my $subdir = $env{'form.authorpath'}; |
|
$redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename); |
|
} |
|
} |
|
} elsif ($env{'form.authorrole'} eq 'course') { |
|
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
|
if ($chome && grep(/^\Q$chome\E$/,@ids)) { |
|
my $url = "/priv/$coursedom/$coursenum"; |
|
my $path=$docroot.$url; |
|
my $subdir = $env{'form.authorpath'}; |
|
$redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename); |
|
if ($redirect) { |
|
my $rightsfile = 'default.rights'; |
|
my $sourcerights = "$path/$rightsfile"; |
|
my $targetrights = $docroot."/res/$coursedom/$coursenum/$rightsfile"; |
|
my $now = time; |
|
if (!-e $sourcerights) { |
|
my $cid = $coursedom.'_'.$coursenum; |
|
if (open(my $fh,">$sourcerights")) { |
|
print $fh <<END; |
|
<accessrule effect="deny" realm="" type="course" role="" /> |
|
<accessrule effect="allow" realm="$cid" type="course" role="" /> |
|
END |
|
close($fh); |
|
} |
|
} |
|
if (!-e "$sourcerights.meta") { |
|
if (open(my $fh,">$sourcerights.meta")) { |
|
my $author=$env{'environment.firstname'}.' '. |
|
$env{'environment.middlename'}.' '. |
|
$env{'environment.lastname'}.' '. |
|
$env{'environment.generation'}; |
|
$author =~ s/\s+$//; |
|
print $fh <<"END"; |
|
|
|
<abstract></abstract> |
|
<author>$author</author> |
|
<authorspace>$coursenum:$coursedom</authorspace> |
|
<copyright>private</copyright> |
|
<creationdate>$now</creationdate> |
|
<customdistributionfile></customdistributionfile> |
|
<dependencies></dependencies> |
|
<domain>$coursedom</domain> |
|
<highestgradelevel>0</highestgradelevel> |
|
<keywords></keywords> |
|
<language>notset </language> |
|
<lastrevisiondate>$now</lastrevisiondate> |
|
<lowestgradelevel>0</lowestgradelevel> |
|
<mime>rights</mime> |
|
<modifyinguser>$env{'user.name'}:$env{'user.domain'}</modifyinguser> |
|
<notes></notes> |
|
<obsolete></obsolete> |
|
<obsoletereplacement></obsoletereplacement> |
|
<owner>$coursenum:$coursedom</owner> |
|
<rule>deny:::course,allow:$cid::course</rule> |
|
<sourceavail></sourceavail> |
|
<standards></standards> |
|
<subject></subject> |
|
<title></title> |
|
END |
|
close($fh); |
|
} |
|
if ((-e $sourcerights) && (-e "$sourcerights.meta")) { |
|
if (!-e "$docroot/res/$coursedom") { |
|
mkdir("$docroot/res/$coursedom",0755); |
|
} |
|
if (!-e "$docroot/res/$coursedom/$coursenum") { |
|
mkdir("$docroot/res/$coursedom/$coursenum",0755); |
|
} |
|
if ((-e "$docroot/res/$coursedom/$coursenum") && (!-e $targetrights)) { |
|
my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes')); |
|
my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1); |
|
} |
|
} |
|
} |
|
if ($env{'form.newresourceadd'}) { |
|
my $template = $env{'form.template'}; |
|
my $source = $docroot.$redirect; |
|
my $target = $redirect; |
|
$target =~ s{^/priv/}{/res/}; |
|
$target = $docroot.$target; |
|
if (!-e $source) { |
|
my $copyfrom; |
|
if ($template) { |
|
my %templates; |
|
my @files = &Apache::lonhomework::get_template_list('problem'); |
|
foreach my $poss (@files) { |
|
if (ref($poss) eq 'ARRAY') { |
|
if ($template eq $poss->[0]) { |
|
$templates{$template} = 1; |
|
last; |
|
} |
|
} |
|
} |
|
if ($templates{$template}) { |
|
$copyfrom = $template; |
|
} |
|
} |
|
unless ($copyfrom) { |
|
$copyfrom = $r->dir_config('lonIncludes').'/templates/blank.problem'; |
|
} |
|
&File::Copy::copy($copyfrom,$source); |
|
} |
|
if (!-e "$source.meta") { |
|
my $cid = $coursedom.'_'.$coursenum; |
|
my $now = time; |
|
if (open(my $fh,">$source.meta")) { |
|
my $author=$env{'environment.firstname'}.' '. |
|
$env{'environment.middlename'}.' '. |
|
$env{'environment.lastname'}.' '. |
|
$env{'environment.generation'}; |
|
$author =~ s/\s+$//; |
|
my $title = $env{'form.newresourcetitle'}; |
|
$title =~ s/^\s+|\s+$//g; |
|
print $fh <<END; |
|
|
|
<abstract></abstract> |
|
<author>$author</author> |
|
<authorspace>$coursenum:$coursedom</authorspace> |
|
<copyright>custom</copyright> |
|
<creationdate>$now</creationdate> |
|
<customdistributionfile>/res/$coursedom/$coursenum/default.rights</customdistributionfile> |
|
<dependencies></dependencies> |
|
<domain>$coursedom</domain> |
|
<highestgradelevel>0</highestgradelevel> |
|
<keywords></keywords> |
|
<language>notset </language> |
|
<lastrevisiondate>$now</lastrevisiondate> |
|
<lowestgradelevel>0</lowestgradelevel> |
|
<mime>problem</mime> |
|
<modifyinguser>$coursenum:$coursedom</modifyinguser> |
|
<notes></notes> |
|
<obsolete></obsolete> |
|
<obsoletereplacement></obsoletereplacement> |
|
<owner>$coursenum:$coursedom</owner> |
|
<sourceavail></sourceavail> |
|
<standards></standards> |
|
<subject></subject> |
|
<title>$title</title> |
|
END |
|
close($fh); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} else { |
|
my ($auname,$audom,$role) = split('___',$env{'form.authorrole'}); |
|
my $rolehome = &Apache::lonnet::homeserver($auname,$audom); |
|
if (grep(/^\Q$rolehome\E$/,@ids)) { |
|
my $now = time; |
|
if (exists($env{'user.role.'.$role.'./'.$audom.'/'.$auname})) { |
|
my ($start,$end) = split(/\./,$env{'user.role.'.$role.'./'.$audom.'/'.$auname}); |
|
if (($start <= $now) && (($end == 0) || ($end >= $now))) { |
|
my $url = "/priv/$audom/$auname"; |
|
my $path = $r->dir_config('lonDocRoot').$url; |
|
my $subdir = $env{'form.authorpath'}; |
|
$redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return ($redirect,$error); |
|
} |
|
|
|
sub finishnewprob { |
|
my ($url,$path,$subdir,$newsubdir,$filename) = @_; |
|
unless (-d $path) { |
|
unless (mkdir($path,02770)) { |
|
return; |
|
} |
|
} |
|
my $redirect; |
|
if ($subdir ne '/') { |
|
$subdir = &cleandir($subdir); |
|
if (($subdir ne '') && (-d "$path/$subdir")) { |
|
$path .= "/$subdir"; |
|
$url .= "/$subdir"; |
|
} |
|
} |
|
my $dest; |
|
if ($newsubdir ne '') { |
|
$newsubdir = &cleandir($newsubdir); |
|
} |
|
if ($newsubdir ne '') { |
|
if (-d "$path/$newsubdir") { |
|
$dest = "$path/$newsubdir/$filename"; |
|
} else { |
|
my $dirok; |
|
unless (-e "$path/$newsubdir") { |
|
if (mkdir("$path/$newsubdir",02770)) { |
|
if (chmod(02770,"$path/$newsubdir")) { |
|
$dirok = 1; |
|
} |
|
} |
|
} |
|
if ($dirok) { |
|
$dest = "$path/$newsubdir/$filename"; |
|
} |
|
} |
|
if (($dest ne '') && (!-e $dest)) { |
|
$redirect = "$url/$newsubdir/$filename"; |
|
} |
|
} else { |
|
$dest = "$path/$filename"; |
|
if (($dest ne '') && (!-e $dest)) { |
|
$redirect = "$url/$filename"; |
|
} |
|
} |
|
return $redirect; |
|
} |
|
|
|
sub cleandir { |
|
my ($dir) = @_; |
|
$dir =~ s/^\s+//; |
|
$dir =~ s/\s+$//; |
|
$dir =~ s/\.+//g; |
|
$dir =~ s/[\#\?&%\":]//g; |
|
return $dir; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
Line 7568 check on this
|
Line 8921 check on this
|
|
|
Verify Content |
Verify Content |
|
|
=item devalidateversioncache() |
=item devalidateversioncache() |
|
|
=item checkversions() |
=item checkversions() |
|
|